harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r590139 [5/5] - /harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/
Date Tue, 30 Oct 2007 16:48:29 GMT
Modified: harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/ReplaceTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/ReplaceTest.java?rev=590139&r1=590138&r2=590139&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/ReplaceTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/ReplaceTest.java
Tue Oct 30 09:48:16 2007
@@ -16,71 +16,75 @@
 
 package org.apache.harmony.tests.java.util.regex;
 
-import junit.framework.TestCase;
-import java.util.regex.Pattern;
 import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
 
+import junit.framework.TestCase;
+
+@SuppressWarnings("nls")
 public class ReplaceTest extends TestCase {
-	
-	public void testSimpleReplace() throws PatternSyntaxException {
-		String target, pattern, repl;
-
-		target = "foobarfobarfoofo1";
-		pattern = "fo[^o]";
-		repl = "xxx";
+
+    public void testSimpleReplace() throws PatternSyntaxException {
+        String target, pattern, repl;
+
+        target = "foobarfobarfoofo1";
+        pattern = "fo[^o]";
+        repl = "xxx";
 
         Pattern p = Pattern.compile(pattern);
         Matcher m = p.matcher(target);
 
         assertEquals("foobarxxxarfoofo1", m.replaceFirst(repl));
         assertEquals("foobarxxxarfooxxx", m.replaceAll(repl));
-	}
+    }
 
-	public void testCaptureReplace() {
-		String target, pattern, repl, s;
-		Pattern p = null;
-		Matcher m;
-
-		target = "[31]foo;bar[42];[99]xyz";
-		pattern = "\\[([0-9]+)\\]([a-z]+)";
-		repl = "$2[$1]";
-
-		p = Pattern.compile(pattern);
-		m = p.matcher(target);
-		s = m.replaceFirst(repl);
-		assertEquals("foo[31];bar[42];[99]xyz", s);
-		s = m.replaceAll(repl);
-		assertEquals("foo[31];bar[42];xyz[99]", s);
-
-		target = "[31]foo(42)bar{63}zoo;[12]abc(34)def{56}ghi;{99}xyz[88]xyz(77)xyz;";
-		pattern = "\\[([0-9]+)\\]([a-z]+)\\(([0-9]+)\\)([a-z]+)\\{([0-9]+)\\}([a-z]+)";
-		repl = "[$5]$6($3)$4{$1}$2";
-		p = Pattern.compile(pattern);
-		m = p.matcher(target);
-		s = m.replaceFirst(repl);
-		// System.out.println(s);
-		assertEquals("[63]zoo(42)bar{31}foo;[12]abc(34)def{56}ghi;{99}xyz[88]xyz(77)xyz;", s
-				);
-		s = m.replaceAll(repl);
-		// System.out.println(s);
-		assertEquals("[63]zoo(42)bar{31}foo;[56]ghi(34)def{12}abc;{99}xyz[88]xyz(77)xyz;", s
-				);
-	}
-
-	public void testEscapeReplace() {
-		String target, pattern, repl, s;
-
-		target = "foo'bar''foo";
-		pattern = "'";
-		repl = "\\'";
-		s = target.replaceAll(pattern, repl);
-		assertEquals("foo'bar''foo", s);
-		repl = "\\\\'";
-		s = target.replaceAll(pattern, repl);
-		assertEquals("foo\\'bar\\'\\'foo", s);
-		repl = "\\$3";
-		s = target.replaceAll(pattern, repl);
-		assertEquals("foo$3bar$3$3foo", s);
-	}
+    public void testCaptureReplace() {
+        String target, pattern, repl, s;
+        Pattern p = null;
+        Matcher m;
+
+        target = "[31]foo;bar[42];[99]xyz";
+        pattern = "\\[([0-9]+)\\]([a-z]+)";
+        repl = "$2[$1]";
+
+        p = Pattern.compile(pattern);
+        m = p.matcher(target);
+        s = m.replaceFirst(repl);
+        assertEquals("foo[31];bar[42];[99]xyz", s);
+        s = m.replaceAll(repl);
+        assertEquals("foo[31];bar[42];xyz[99]", s);
+
+        target = "[31]foo(42)bar{63}zoo;[12]abc(34)def{56}ghi;{99}xyz[88]xyz(77)xyz;";
+        pattern = "\\[([0-9]+)\\]([a-z]+)\\(([0-9]+)\\)([a-z]+)\\{([0-9]+)\\}([a-z]+)";
+        repl = "[$5]$6($3)$4{$1}$2";
+        p = Pattern.compile(pattern);
+        m = p.matcher(target);
+        s = m.replaceFirst(repl);
+        // System.out.println(s);
+        assertEquals(
+                "[63]zoo(42)bar{31}foo;[12]abc(34)def{56}ghi;{99}xyz[88]xyz(77)xyz;",
+                s);
+        s = m.replaceAll(repl);
+        // System.out.println(s);
+        assertEquals(
+                "[63]zoo(42)bar{31}foo;[56]ghi(34)def{12}abc;{99}xyz[88]xyz(77)xyz;",
+                s);
+    }
+
+    public void testEscapeReplace() {
+        String target, pattern, repl, s;
+
+        target = "foo'bar''foo";
+        pattern = "'";
+        repl = "\\'";
+        s = target.replaceAll(pattern, repl);
+        assertEquals("foo'bar''foo", s);
+        repl = "\\\\'";
+        s = target.replaceAll(pattern, repl);
+        assertEquals("foo\\'bar\\'\\'foo", s);
+        repl = "\\$3";
+        s = target.replaceAll(pattern, repl);
+        assertEquals("foo$3bar$3$3foo", s);
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/SplitTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/SplitTest.java?rev=590139&r1=590138&r2=590139&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/SplitTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/SplitTest.java
Tue Oct 30 09:48:16 2007
@@ -17,154 +17,155 @@
 
 package org.apache.harmony.tests.java.util.regex;
 
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
 
 import junit.framework.TestCase;
-import java.util.regex.*;
 
 /**
  * TODO Type description
- * 
  */
+@SuppressWarnings("nls")
 public class SplitTest extends TestCase {
-	
-	public void testSimple() {
-		Pattern p = Pattern.compile("/");
-		String[] results = p.split("have/you/done/it/right");
-		String[] expected = new String[] { "have", "you", "done", "it", "right" };
-		assertEquals(expected.length, results.length);
-		for (int i = 0; i < expected.length; i++) {
-			assertEquals(results[i], expected[i]);
-		}
-	}
-
-	public void testSplit1() throws PatternSyntaxException {
-		Pattern p = Pattern.compile(" ");
-
-		String input = "poodle zoo";
-		String tokens[];
-
-		tokens = p.split(input, 1);
-		assertEquals(1, tokens.length);
-		assertTrue(tokens[0].equals(input));
-		tokens = p.split(input, 2);
-		assertEquals(2, tokens.length);
-		assertEquals("poodle", tokens[0]);
-		assertEquals("zoo", tokens[1]);
-		tokens = p.split(input, 5);
-		assertEquals(2, tokens.length);
-		assertEquals("poodle", tokens[0]);
-		assertEquals("zoo", tokens[1]);
-		tokens = p.split(input, -2);
-		assertEquals(2, tokens.length);
-		assertEquals("poodle", tokens[0]);
-		assertEquals("zoo", tokens[1]);
-		tokens = p.split(input, 0);
-		assertEquals(2, tokens.length);
-		assertEquals("poodle", tokens[0]);
-		assertEquals("zoo", tokens[1]);
-		tokens = p.split(input);
-		assertEquals(2, tokens.length);
-		assertEquals("poodle", tokens[0]);
-		assertEquals("zoo", tokens[1]);
-
-		p = Pattern.compile("d");
-
-		tokens = p.split(input, 1);
-		assertEquals(1, tokens.length);
-		assertTrue(tokens[0].equals(input));
-		tokens = p.split(input, 2);
-		assertEquals(2, tokens.length);
-		assertEquals("poo", tokens[0]);
-		assertEquals("le zoo", tokens[1]);
-		tokens = p.split(input, 5);
-		assertEquals(2, tokens.length);
-		assertEquals("poo", tokens[0]);
-		assertEquals("le zoo", tokens[1]);
-		tokens = p.split(input, -2);
-		assertEquals(2, tokens.length);
-		assertEquals("poo", tokens[0]);
-		assertEquals("le zoo", tokens[1]);
-		tokens = p.split(input, 0);
-		assertEquals(2, tokens.length);
-		assertEquals("poo", tokens[0]);
-		assertEquals("le zoo", tokens[1]);
-		tokens = p.split(input);
-		assertEquals(2, tokens.length);
-		assertEquals("poo", tokens[0]);
-		assertEquals("le zoo", tokens[1]);
-
-		p = Pattern.compile("o");
-
-		tokens = p.split(input, 1);
-		assertEquals(1, tokens.length);
-		assertTrue(tokens[0].equals(input));
-		tokens = p.split(input, 2);
-		assertEquals(2, tokens.length);
-		assertEquals("p", tokens[0]);
-		assertEquals("odle zoo", tokens[1]);
-		tokens = p.split(input, 5);
-		assertEquals(5, tokens.length);
-		assertEquals("p", tokens[0]);
-		assertTrue(tokens[1].equals(""));
-		assertEquals("dle z", tokens[2]);
-		assertTrue(tokens[3].equals(""));
-		assertTrue(tokens[4].equals(""));
-		tokens = p.split(input, -2);
-		assertEquals(5, tokens.length);
-		assertEquals("p", tokens[0]);
-		assertTrue(tokens[1].equals(""));
-		assertEquals("dle z", tokens[2]);
-		assertTrue(tokens[3].equals(""));
-		assertTrue(tokens[4].equals(""));
-		tokens = p.split(input, 0);
-		assertEquals(3, tokens.length);
-		assertEquals("p", tokens[0]);
-		assertTrue(tokens[1].equals(""));
-		assertEquals("dle z", tokens[2]);
-		tokens = p.split(input);
-		assertEquals(3, tokens.length);
-		assertEquals("p", tokens[0]);
-		assertTrue(tokens[1].equals(""));
-		assertEquals("dle z", tokens[2]);
-	}
-
-	public void testSplit2() {
-		Pattern p = Pattern.compile("");
-		String s[];
-		s = p.split("a", -1);
-		assertEquals(3, s.length);
-		assertEquals("", s[0]);
-		assertEquals("a", s[1]);
-		assertEquals("", s[2]);
-
-		s = p.split("", -1);
-		assertEquals(1, s.length);
-		assertEquals("", s[0]);
-
-		s = p.split("abcd", -1);
-		assertEquals(6, s.length);
-		assertEquals("", s[0]);
-		assertEquals("a", s[1]);
-		assertEquals("b", s[2]);
-		assertEquals("c", s[3]);
-		assertEquals("d", s[4]);
-		assertEquals("", s[5]);
+
+    public void testSimple() {
+        Pattern p = Pattern.compile("/");
+        String[] results = p.split("have/you/done/it/right");
+        String[] expected = new String[] { "have", "you", "done", "it", "right" };
+        assertEquals(expected.length, results.length);
+        for (int i = 0; i < expected.length; i++) {
+            assertEquals(results[i], expected[i]);
+        }
+    }
+
+    public void testSplit1() throws PatternSyntaxException {
+        Pattern p = Pattern.compile(" ");
+
+        String input = "poodle zoo";
+        String tokens[];
+
+        tokens = p.split(input, 1);
+        assertEquals(1, tokens.length);
+        assertTrue(tokens[0].equals(input));
+        tokens = p.split(input, 2);
+        assertEquals(2, tokens.length);
+        assertEquals("poodle", tokens[0]);
+        assertEquals("zoo", tokens[1]);
+        tokens = p.split(input, 5);
+        assertEquals(2, tokens.length);
+        assertEquals("poodle", tokens[0]);
+        assertEquals("zoo", tokens[1]);
+        tokens = p.split(input, -2);
+        assertEquals(2, tokens.length);
+        assertEquals("poodle", tokens[0]);
+        assertEquals("zoo", tokens[1]);
+        tokens = p.split(input, 0);
+        assertEquals(2, tokens.length);
+        assertEquals("poodle", tokens[0]);
+        assertEquals("zoo", tokens[1]);
+        tokens = p.split(input);
+        assertEquals(2, tokens.length);
+        assertEquals("poodle", tokens[0]);
+        assertEquals("zoo", tokens[1]);
+
+        p = Pattern.compile("d");
+
+        tokens = p.split(input, 1);
+        assertEquals(1, tokens.length);
+        assertTrue(tokens[0].equals(input));
+        tokens = p.split(input, 2);
+        assertEquals(2, tokens.length);
+        assertEquals("poo", tokens[0]);
+        assertEquals("le zoo", tokens[1]);
+        tokens = p.split(input, 5);
+        assertEquals(2, tokens.length);
+        assertEquals("poo", tokens[0]);
+        assertEquals("le zoo", tokens[1]);
+        tokens = p.split(input, -2);
+        assertEquals(2, tokens.length);
+        assertEquals("poo", tokens[0]);
+        assertEquals("le zoo", tokens[1]);
+        tokens = p.split(input, 0);
+        assertEquals(2, tokens.length);
+        assertEquals("poo", tokens[0]);
+        assertEquals("le zoo", tokens[1]);
+        tokens = p.split(input);
+        assertEquals(2, tokens.length);
+        assertEquals("poo", tokens[0]);
+        assertEquals("le zoo", tokens[1]);
+
+        p = Pattern.compile("o");
+
+        tokens = p.split(input, 1);
+        assertEquals(1, tokens.length);
+        assertTrue(tokens[0].equals(input));
+        tokens = p.split(input, 2);
+        assertEquals(2, tokens.length);
+        assertEquals("p", tokens[0]);
+        assertEquals("odle zoo", tokens[1]);
+        tokens = p.split(input, 5);
+        assertEquals(5, tokens.length);
+        assertEquals("p", tokens[0]);
+        assertTrue(tokens[1].equals(""));
+        assertEquals("dle z", tokens[2]);
+        assertTrue(tokens[3].equals(""));
+        assertTrue(tokens[4].equals(""));
+        tokens = p.split(input, -2);
+        assertEquals(5, tokens.length);
+        assertEquals("p", tokens[0]);
+        assertTrue(tokens[1].equals(""));
+        assertEquals("dle z", tokens[2]);
+        assertTrue(tokens[3].equals(""));
+        assertTrue(tokens[4].equals(""));
+        tokens = p.split(input, 0);
+        assertEquals(3, tokens.length);
+        assertEquals("p", tokens[0]);
+        assertTrue(tokens[1].equals(""));
+        assertEquals("dle z", tokens[2]);
+        tokens = p.split(input);
+        assertEquals(3, tokens.length);
+        assertEquals("p", tokens[0]);
+        assertTrue(tokens[1].equals(""));
+        assertEquals("dle z", tokens[2]);
+    }
+
+    public void testSplit2() {
+        Pattern p = Pattern.compile("");
+        String s[];
+        s = p.split("a", -1);
+        assertEquals(3, s.length);
+        assertEquals("", s[0]);
+        assertEquals("a", s[1]);
+        assertEquals("", s[2]);
+
+        s = p.split("", -1);
+        assertEquals(1, s.length);
+        assertEquals("", s[0]);
+
+        s = p.split("abcd", -1);
+        assertEquals(6, s.length);
+        assertEquals("", s[0]);
+        assertEquals("a", s[1]);
+        assertEquals("b", s[2]);
+        assertEquals("c", s[3]);
+        assertEquals("d", s[4]);
+        assertEquals("", s[5]);
     }
 
     public void testSplitSupplementaryWithEmptyString() {
-        
+
         /*
-         * See http://www.unicode.org/reports/tr18/#Supplementary_Characters
-         * We have to treat text as code points not code units.
+         * See http://www.unicode.org/reports/tr18/#Supplementary_Characters We
+         * have to treat text as code points not code units.
          */
         Pattern p = Pattern.compile("");
         String s[];
-		s = p.split("a\ud869\uded6b", -1);
+        s = p.split("a\ud869\uded6b", -1);
         assertEquals(5, s.length);
-		assertEquals("", s[0]);
-		assertEquals("a", s[1]);
+        assertEquals("", s[0]);
+        assertEquals("a", s[1]);
         assertEquals("\ud869\uded6", s[2]);
-        assertEquals("b", s[3]);                
-        assertEquals("", s[4]);        
-	}
+        assertEquals("b", s[3]);
+        assertEquals("", s[4]);
+    }
 }



Mime
View raw message