harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r590139 [1/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
Author: tellison
Date: Tue Oct 30 09:48:16 2007
New Revision: 590139

URL: http://svn.apache.org/viewvc?rev=590139&view=rev
Log:
Tidy-up in regex test cases (formatting, compiler warnings, etc).
No functional changes.

Modified:
    harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/Matcher2Test.java
    harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/MatcherTest.java
    harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/ModeTest.java
    harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/Pattern2Test.java
    harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/PatternErrorTest.java
    harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/PatternSyntaxExceptionTest.java
    harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/PatternTest.java
    harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/ReplaceTest.java
    harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/SplitTest.java

Modified: harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/Matcher2Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/Matcher2Test.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/Matcher2Test.java (original)
+++ harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/Matcher2Test.java Tue Oct 30 09:48:16 2007
@@ -16,203 +16,206 @@
 
 package org.apache.harmony.tests.java.util.regex;
 
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
+
 import junit.framework.TestCase;
-import java.util.regex.*;
 
 /**
  * Tests Matcher methods
- * 
  */
+@SuppressWarnings("nls")
 public class Matcher2Test extends TestCase {
-	public void test_toString() {
-		Pattern p = Pattern.compile("foo");
-		Matcher m = p.matcher("bar");
-		assertNotNull(m.toString());
-	}
+    public void test_toString() {
+        Pattern p = Pattern.compile("foo");
+        Matcher m = p.matcher("bar");
+        assertNotNull(m.toString());
+    }
 
-	public void testErrorConditions() throws PatternSyntaxException {
+    public void testErrorConditions() throws PatternSyntaxException {
         // Test match cursors in absence of a match
-		Pattern p = Pattern.compile("foo");
-		Matcher m = p.matcher("bar");
-		assertFalse(m.matches());
-
-		try {
-			m.start();
-			fail("IllegalStateException expected");
-		} catch (IllegalStateException e) {
-		}
-
-		try {
-			m.end();
-			fail("IllegalStateException expected");
-		} catch (IllegalStateException e) {
-		}
-
-		try {
-			m.group();
-			fail("IllegalStateException expected");
-		} catch (IllegalStateException e) {
-		}
-
-		try {
-			m.start(1);
-			fail("IllegalStateException expected");
-		} catch (IllegalStateException e) {
-		}
-
-		try {
-			m.end(1);
-			fail("IllegalStateException expected");
-		} catch (IllegalStateException e) {
-		}
-
-		try {
-			m.group(1);
-			fail("IllegalStateException expected");
-		} catch (IllegalStateException e) {
-		}
-		
-               // regression test for HARMONY-2418
-		try {
-			m.usePattern(null);
-			fail("IllegalArgumentException expected");
-		} catch (IllegalArgumentException e) {
-                 // PASSED
-		}
+        Pattern p = Pattern.compile("foo");
+        Matcher m = p.matcher("bar");
+        assertFalse(m.matches());
+
+        try {
+            m.start();
+            fail("IllegalStateException expected");
+        } catch (IllegalStateException e) {
+        }
+
+        try {
+            m.end();
+            fail("IllegalStateException expected");
+        } catch (IllegalStateException e) {
+        }
+
+        try {
+            m.group();
+            fail("IllegalStateException expected");
+        } catch (IllegalStateException e) {
+        }
+
+        try {
+            m.start(1);
+            fail("IllegalStateException expected");
+        } catch (IllegalStateException e) {
+        }
+
+        try {
+            m.end(1);
+            fail("IllegalStateException expected");
+        } catch (IllegalStateException e) {
+        }
+
+        try {
+            m.group(1);
+            fail("IllegalStateException expected");
+        } catch (IllegalStateException e) {
+        }
+
+        // regression test for HARMONY-2418
+        try {
+            m.usePattern(null);
+            fail("IllegalArgumentException expected");
+        } catch (IllegalArgumentException e) {
+            // PASSED
+        }
     }
 
     public void testErrorConditions2() throws PatternSyntaxException {
-		// Test match cursors in absence of a match
+        // Test match cursors in absence of a match
         Pattern p = Pattern.compile("(foo[0-9])(bar[a-z])");
         Matcher m = p.matcher("foo1barzfoo2baryfoozbar5");
 
-		assertTrue(m.find());
-		assertEquals(0, m.start());
-		assertEquals(8, m.end());
-		assertEquals(0, m.start(1));
-		assertEquals(4, m.end(1));
-		assertEquals(4, m.start(2));
-		assertEquals(8, m.end(2));
-
-		try {
-			m.start(3);
-			fail("IndexOutOfBoundsException expected");
-		} catch (IndexOutOfBoundsException e) {
-		}
-
-		try {
-			m.end(3);
-			fail("IndexOutOfBoundsException expected");
-		} catch (IndexOutOfBoundsException e) {
-		}
-
-		try {
-			m.group(3);
-			fail("IndexOutOfBoundsException expected");
-		} catch (IndexOutOfBoundsException e) {
-		}
-
-		try {
-			m.start(-1);
-			fail("IndexOutOfBoundsException expected");
-		} catch (IndexOutOfBoundsException e) {
-		}
-
-		try {
-			m.end(-1);
-			fail("IndexOutOfBoundsException expected");
-		} catch (IndexOutOfBoundsException e) {
-		}
-
-		try {
-			m.group(-1);
-			fail("IndexOutOfBoundsException expected");
-		} catch (IndexOutOfBoundsException e) {
-		}
-
-		assertTrue(m.find());
-		assertEquals(8, m.start());
-		assertEquals(16, m.end());
-		assertEquals(8, m.start(1));
-		assertEquals(12, m.end(1));
-		assertEquals(12, m.start(2));
-		assertEquals(16, m.end(2));
-
-		try {
-			m.start(3);
-			fail("IndexOutOfBoundsException expected");
-		} catch (IndexOutOfBoundsException e) {
-		}
-
-		try {
-			m.end(3);
-			fail("IndexOutOfBoundsException expected");
-		} catch (IndexOutOfBoundsException e) {
-		}
-
-		try {
-			m.group(3);
-			fail("IndexOutOfBoundsException expected");
-		} catch (IndexOutOfBoundsException e) {
-		}
-
-		try {
-			m.start(-1);
-			fail("IndexOutOfBoundsException expected");
-		} catch (IndexOutOfBoundsException e) {
-		}
-
-		try {
-			m.end(-1);
-			fail("IndexOutOfBoundsException expected");
-		} catch (IndexOutOfBoundsException e) {
-		}
-
-		try {
-			m.group(-1);
-			fail("IndexOutOfBoundsException expected");
-		} catch (IndexOutOfBoundsException e) {
-		}
-
-		assertFalse(m.find());
-
-		try {
-			m.start(3);
-            fail("IllegalStateException expected");
-		} catch (IllegalStateException e) {
-		}
-
-		try {
-			m.end(3);
-			fail("IllegalStateException expected");
-		} catch (IllegalStateException e) {
-		}
-
-		try {
-			m.group(3);
-			fail("IllegalStateException expected");
-		} catch (IllegalStateException e) {
-		}
-
-		try {
-			m.start(-1);
-			fail("IllegalStateException expected");
-		} catch (IllegalStateException e) {
-		}
-
-		try {
-			m.end(-1);
-			fail("IllegalStateException expected");
-		} catch (IllegalStateException e) {
-		}
-
-		try {
-			m.group(-1);
-			fail("IllegalStateException expected");
-		} catch (IllegalStateException e) {
-		}
-	}
-    
+        assertTrue(m.find());
+        assertEquals(0, m.start());
+        assertEquals(8, m.end());
+        assertEquals(0, m.start(1));
+        assertEquals(4, m.end(1));
+        assertEquals(4, m.start(2));
+        assertEquals(8, m.end(2));
+
+        try {
+            m.start(3);
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException e) {
+        }
+
+        try {
+            m.end(3);
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException e) {
+        }
+
+        try {
+            m.group(3);
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException e) {
+        }
+
+        try {
+            m.start(-1);
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException e) {
+        }
+
+        try {
+            m.end(-1);
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException e) {
+        }
+
+        try {
+            m.group(-1);
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException e) {
+        }
+
+        assertTrue(m.find());
+        assertEquals(8, m.start());
+        assertEquals(16, m.end());
+        assertEquals(8, m.start(1));
+        assertEquals(12, m.end(1));
+        assertEquals(12, m.start(2));
+        assertEquals(16, m.end(2));
+
+        try {
+            m.start(3);
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException e) {
+        }
+
+        try {
+            m.end(3);
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException e) {
+        }
+
+        try {
+            m.group(3);
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException e) {
+        }
+
+        try {
+            m.start(-1);
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException e) {
+        }
+
+        try {
+            m.end(-1);
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException e) {
+        }
+
+        try {
+            m.group(-1);
+            fail("IndexOutOfBoundsException expected");
+        } catch (IndexOutOfBoundsException e) {
+        }
+
+        assertFalse(m.find());
+
+        try {
+            m.start(3);
+            fail("IllegalStateException expected");
+        } catch (IllegalStateException e) {
+        }
+
+        try {
+            m.end(3);
+            fail("IllegalStateException expected");
+        } catch (IllegalStateException e) {
+        }
+
+        try {
+            m.group(3);
+            fail("IllegalStateException expected");
+        } catch (IllegalStateException e) {
+        }
+
+        try {
+            m.start(-1);
+            fail("IllegalStateException expected");
+        } catch (IllegalStateException e) {
+        }
+
+        try {
+            m.end(-1);
+            fail("IllegalStateException expected");
+        } catch (IllegalStateException e) {
+        }
+
+        try {
+            m.group(-1);
+            fail("IllegalStateException expected");
+        } catch (IllegalStateException e) {
+        }
+    }
+
     /*
      * Regression test for HARMONY-997
      */
@@ -229,4 +232,3 @@
         }
     }
 }
-

Modified: harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/MatcherTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/MatcherTest.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/MatcherTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/MatcherTest.java Tue Oct 30 09:48:16 2007
@@ -17,654 +17,653 @@
 
 package org.apache.harmony.tests.java.util.regex;
 
-import junit.framework.TestCase;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import junit.framework.TestCase;
+
+@SuppressWarnings("nls")
 public class MatcherTest extends TestCase {
-	String[] testPatterns = {
-			"(a|b)*abb",
-			"(1*2*3*4*)*567",
-			"(a|b|c|d)*aab",
-			"(1|2|3|4|5|6|7|8|9|0)(1|2|3|4|5|6|7|8|9|0)*",
-			"(abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ)*",
-			"(a|b)*(a|b)*A(a|b)*lice.*",
-			"(a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z)(a|b|c|d|e|f|g|h|"
-					+ "i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z)*(1|2|3|4|5|6|7|8|9|0)*|while|for|struct|if|do"
-	};
-
-	String[] groupPatterns = { "(a|b)*aabb", "((a)|b)*aabb", "((a|b)*)a(abb)",
-			"(((a)|(b))*)aabb", "(((a)|(b))*)aa(b)b", "(((a)|(b))*)a(a(b)b)" };
-
-	public void testAppendReplacement() {
-		Pattern pat = Pattern.compile("XX");
-		Matcher m = pat.matcher("Today is XX-XX-XX ...");
-		StringBuffer sb = new StringBuffer();
-
-		for (int i = 0; m.find(); i++) {
-			m.appendReplacement(sb, new Integer(i * 10 + i).toString());
-		}
-		m.appendTail(sb);
-		assertEquals("Today is 0-11-22 ...", sb.toString());
-	}
-
-	public void testAppendReplacementRef() {
-		Pattern p = Pattern.compile("xx (rur|\\$)");
-		Matcher m = p.matcher("xx $ equals to xx rur.");
-		StringBuffer sb = new StringBuffer();
-		for (int i = 1; m.find(); i *= 30) {
-			String rep = new Integer(i).toString() + " $1";
-			m.appendReplacement(sb, rep);
-		}
-		m.appendTail(sb);
-		assertEquals("1 $ equals to 30 rur.", sb.toString());
-	}
-
-	public void testReplaceAll() {
-		String input = "aabfooaabfooabfoob";
-		String pattern = "a*b";
-		Pattern pat = Pattern.compile(pattern);
-		Matcher mat = pat.matcher(input);
-
-		assertEquals("-foo-foo-foo-", mat.replaceAll("-"));
-	}
-
-	/*
-	 * Class under test for Matcher reset(CharSequence)
-	 */
-	public void testResetCharSequence() {
-	}
-
-	public void testAppendSlashes() {
-		Pattern p = Pattern.compile("\\\\");
-		Matcher m = p.matcher("one\\cat\\two\\cats\\in\\the\\yard");
-		StringBuffer sb = new StringBuffer();
-		while (m.find()) {
-			m.appendReplacement(sb, "\\\\");
-		}
-		m.appendTail(sb);
-		assertEquals("one\\cat\\two\\cats\\in\\the\\yard", sb.toString());
-
-	}
-
-	public void testReplaceFirst() {
-		String input = "zzzdogzzzdogzzz";
-		String pattern = "dog";
-		Pattern pat = Pattern.compile(pattern);
-		Matcher mat = pat.matcher(input);
-
-		assertEquals("zzzcatzzzdogzzz", mat.replaceFirst("cat"));
-	}
-
-	public void testPattern() {
-		for (String element : testPatterns) {
-			Pattern test = Pattern.compile(element);
-			assertEquals(test, test.matcher("aaa").pattern());
-		}
-
-		for (String element : testPatterns) {
-			assertEquals(element, Pattern.compile(element)
-					.matcher("aaa").pattern().toString());
-		}
-	}
-
-	/*
-	 * Class under test for Matcher reset()
-	 */
-	public void testReset() {
-	}
-
-	/*
-	 * Class under test for String group(int)
-	 */
-	public void testGroupint() {
-		String positiveTestString = "ababababbaaabb";
-		String negativeTestString = "gjhfgdsjfhgcbv";
-
-		// test IndexOutOfBoundsException
-		// //
-		for (int i = 0; i < groupPatterns.length; i++) {
-			Pattern test = Pattern.compile(groupPatterns[i]);
-			Matcher mat = test.matcher(positiveTestString);
-			mat.matches();
-			try {
-				// groupPattern <index + 1> equals to number of groups
-				// of the specified pattern
-				// //
-				mat.group(i + 2);
-				fail("IndexOutBoundsException expected");
-				mat.group(i + 100);
-				fail("IndexOutBoundsException expected");
-				mat.group(-1);
-				fail("IndexOutBoundsException expected");
-				mat.group(-100);
-				fail("IndexOutBoundsException expected");
-			} catch (IndexOutOfBoundsException iobe) {
-			}
-		}
-
-		String[][] groupResults = { { "a" }, { "a", "a" },
-				{ "ababababba", "a", "abb" }, { "ababababba", "a", "a", "b" },
-				{ "ababababba", "a", "a", "b", "b" },
-				{ "ababababba", "a", "a", "b", "abb", "b" }, };
-
-		for (int i = 0; i < groupPatterns.length; i++) {
-			Pattern test = Pattern.compile(groupPatterns[i]);
-			Matcher mat = test.matcher(positiveTestString);
-			mat.matches();
-			for (int j = 0; j < groupResults[i].length; j++) {
-				assertEquals("i: " + i + " j: " + j, groupResults[i][j], mat
-						.group(j + 1));
-			}
-
-		}
-
-	}
-
-	public void testGroup() {
-		String positiveTestString = "ababababbaaabb";
-		String negativeTestString = "gjhfgdsjfhgcbv";
-		for (String element : groupPatterns) {
-			Pattern test = Pattern.compile(element);
-			Matcher mat = test.matcher(positiveTestString);
-			mat.matches();
-			// test result
-			assertEquals(positiveTestString, mat.group());
-
-			// test equal to group(0) result
-			assertEquals(mat.group(0), mat.group());
-		}
-
-		for (String element : groupPatterns) {
-			Pattern test = Pattern.compile(element);
-			Matcher mat = test.matcher(negativeTestString);
-			mat.matches();
-			try {
-				mat.group();
-				fail("IllegalStateException expected for <false> matches result");
-			} catch (IllegalStateException ise) {
-			}
-		}
-	}
-
-	public void testGroupPossessive() {
-		Pattern pat = Pattern.compile("((a)|(b))++c");
-		Matcher mat = pat.matcher("aac");
-
-		mat.matches();
-		assertEquals("a", mat.group(1));
-	}
-
-	/*
-	 * Class under test for boolean find(int)
-	 */
-	public void testFindint() {
-	}
-
-	/*
-	 * Class under test for int start(int)
-	 */
-	public void testStartint() {
-	}
-
-	/*
-	 * Class under test for int end(int)
-	 */
-	public void testEndint() {
-	}
-
-	public void testMatchesMisc() {
-		String[][] posSeq = {
-				{ "abb", "ababb", "abababbababb", "abababbababbabababbbbbabb" },
-				{ "213567", "12324567", "1234567", "213213567",
-						"21312312312567", "444444567" },
-				{ "abcdaab", "aab", "abaab", "cdaab", "acbdadcbaab" },
-				{ "213234567", "3458", "0987654", "7689546432", "0398576",
-						"98432", "5" },
-				{
-						"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
-						"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
-								+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" },
-				{ "ababbaAabababblice", "ababbaAliceababab", "ababbAabliceaaa",
-						"abbbAbbbliceaaa", "Alice" },
-				{ "a123", "bnxnvgds156", "for", "while", "if", "struct" }
-
-		};
-
-		for (int i = 0; i < testPatterns.length; i++) {
-			Pattern pat = Pattern.compile(testPatterns[i]);
-			for (int j = 0; j < posSeq[i].length; j++) {
-				Matcher mat = pat.matcher(posSeq[i][j]);
-				assertTrue("Incorrect match: " + testPatterns[i] + " vs "
-						+ posSeq[i][j], mat.matches());
-			}
-		}
-	}
-
-	public void testMatchesQuantifiers() {
-		String[] testPatternsSingles = { "a{5}", "a{2,4}", "a{3,}" };
-		String[] testPatternsMultiple = { "((a)|(b)){1,2}abb",
-				"((a)|(b)){2,4}", "((a)|(b)){3,}" };
-
-		String[][] stringSingles = { { "aaaaa", "aaa" },
-				{ "aa", "a", "aaa", "aaaaaa", "aaaa", "aaaaa" },
-				{ "aaa", "a", "aaaa", "aa" }, };
-
-		String[][] stringMultiples = { { "ababb", "aba" },
-				{ "ab", "b", "bab", "ababa", "abba", "abababbb" },
-				{ "aba", "b", "abaa", "ba" }, };
-
-		for (int i = 0; i < testPatternsSingles.length; i++) {
-			Pattern pat = Pattern.compile(testPatternsSingles[i]);
-			for (int j = 0; j < stringSingles.length / 2; j++) {
-				assertTrue("Match expected, but failed: " + pat.pattern()
-						+ " : " + stringSingles[i][j], pat.matcher(
-						stringSingles[i][j * 2]).matches());
-				assertFalse("Match failure expected, but match succeed: "
-						+ pat.pattern() + " : " + stringSingles[i][j * 2 + 1],
-						pat.matcher(stringSingles[i][j * 2 + 1]).matches());
-			}
-		}
-
-		for (int i = 0; i < testPatternsMultiple.length; i++) {
-			Pattern pat = Pattern.compile(testPatternsMultiple[i]);
-			for (int j = 0; j < stringMultiples.length / 2; j++) {
-				assertTrue("Match expected, but failed: " + pat.pattern()
-						+ " : " + stringMultiples[i][j], pat.matcher(
-						stringMultiples[i][j * 2]).matches());
-				assertFalse(
-						"Match failure expected, but match succeed: "
-								+ pat.pattern() + " : "
-								+ stringMultiples[i][j * 2 + 1], pat.matcher(
-								stringMultiples[i][j * 2 + 1]).matches());
-			}
-		}
-	}
-
-	public void testQuantVsGroup() {
-		String patternString = "(d{1,3})((a|c)*)(d{1,3})((a|c)*)(d{1,3})";
-		String testString = "dacaacaacaaddaaacaacaaddd";
-
-		Pattern pat = Pattern.compile(patternString);
-		Matcher mat = pat.matcher(testString);
-
-		mat.matches();
-		assertEquals("dacaacaacaaddaaacaacaaddd", mat.group());
-		assertEquals("d", mat.group(1));
-		assertEquals("acaacaacaa", mat.group(2));
-		assertEquals("dd", mat.group(4));
-		assertEquals("aaacaacaa", mat.group(5));
-		assertEquals("ddd", mat.group(7));
-	}
-
-	public void testLookingAt() {
-	}
-
-	/*
-	 * Class under test for boolean find()
-	 */
-	public void testFind() {
-		String testPattern = "(abb)";
-		String testString = "cccabbabbabbabbabb";
-		Pattern pat = Pattern.compile(testPattern);
-		Matcher mat = pat.matcher(testString);
-		int start = 3;
-		int end = 6;
-		while (mat.find()) {
-			assertEquals(start, mat.start(1));
-			assertEquals(end, mat.end(1));
-
-			start = end;
-			end += 3;
-		}
-
-		testPattern = "(\\d{1,3})";
-		testString = "aaaa123456789045";
-
-		Pattern pat2 = Pattern.compile(testPattern);
-		Matcher mat2 = pat2.matcher(testString);
-		start = 4;
-		int length = 3;
-		while (mat2.find()) {
-			assertEquals(testString.substring(start, start + length), mat2
-					.group(1));
-			start += length;
-		}
-	}
-
-	public void testSEOLsymbols() {
-		Pattern pat = Pattern.compile("^a\\(bb\\[$");
-		Matcher mat = pat.matcher("a(bb[");
-
-		assertTrue(mat.matches());
-	}
-
-	/*
-	 * Class under test for int start()
-	 */
-	public void testStart() {
-	}
-
-	public void testGroupCount() {
-		for (int i = 0; i < groupPatterns.length; i++) {
-			Pattern test = Pattern.compile(groupPatterns[i]);
-			Matcher mat = test.matcher("ababababbaaabb");
-			mat.matches();
-			assertEquals(i + 1, mat.groupCount());
-
-		}
-	}
-
-	public void testRelactantQuantifiers() {
-		Pattern pat = Pattern.compile("(ab*)*b");
-		Matcher mat = pat.matcher("abbbb");
-
-		if (mat.matches()) {
-			assertEquals("abbb", mat.group(1));
-		} else {
-			fail("Match expected: (ab*)*b vs abbbb");
-		}
-	}
-
-	public void testEnhancedFind() {
-		String input = "foob";
-		String pattern = "a*b";
-		Pattern pat = Pattern.compile(pattern);
-		Matcher mat = pat.matcher(input);
-
-		mat.find();
-		assertEquals("b", mat.group());
-	}
-
-	public void _testMatchesURI() {
-		final Pattern pat = Pattern
-				.compile("^(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?");
-		Runnable r1 = new Runnable() {
-			public void run() {
-				Matcher mat = pat
-						.matcher("file:/c:/workspace/api/build.win32/classes/META-INF/"
-								+ "services/javax.xml.parsers.DocumentBuilderFactory");
-				int k1 = 1;
-				while (mat.matches()) {
-				}// System.err.println("1: " + mat.group());
-				System.out.println("1: fail");
-			}
-		};
-
-		Runnable r2 = new Runnable() {
-			public void run() {
-				Matcher mat = pat.matcher("file:/c:/workspace/"
-						+ "services/javax.xml.parsers.DocumentBuilderFactory");
-				int k1 = 1;
-				while (mat.matches()) {
-				}// System.err.println("2: " + mat.group());
-				System.out.println("2: fail");
-			}
-		};
-
-		Thread t1 = new Thread(r1);
-		Thread t2 = new Thread(r2);
-
-		t1.start();
-		t2.start();
-
-		try {
-			t1.join();
-			t2.join();
-		} catch (Exception e) {
-		}
-
-	}
-
-	public void _testUnifiedQuantifiers() {
-		// Pattern pat1 = Pattern.compile("\\s+a");
-		Pattern pat2 = Pattern.compile(" *a");
-
-		Matcher mat = pat2.matcher("      a");
-
-		System.out.println("unified: " + mat.find());
-	}
-
-	public void _testCompositeGroupQuantifiers() {
-		Pattern pat = Pattern.compile("(a|b){0,3}abb");
-		Matcher mat = pat.matcher("ababababababababababaab");
-
-		System.out.println("composite: " + mat.find());
-	}
-
-	public void testPosCompositeGroup() {
-		String[] posExamples = { "aabbcc", "aacc", "bbaabbcc" };
-		String[] negExamples = { "aabb", "bb", "bbaabb" };
-		Pattern posPat = Pattern.compile("(aa|bb){1,3}+cc");
-		Pattern negPat = Pattern.compile("(aa|bb){1,3}+bb");
-
-		Matcher mat;
-		for (String element : posExamples) {
-			mat = posPat.matcher(element);
-			assertTrue(mat.matches());
-		}
-
-		for (String element : negExamples) {
-			mat = negPat.matcher(element);
-			assertFalse(mat.matches());
-		}
-
-		assertTrue(Pattern.matches("(aa|bb){1,3}+bb", "aabbaabb"));
-
-	}
-
-	public void testPosAltGroup() {
-		String[] posExamples = { "aacc", "bbcc", "cc" };
-		String[] negExamples = { "bb", "aa" };
-		Pattern posPat = Pattern.compile("(aa|bb)?+cc");
-		Pattern negPat = Pattern.compile("(aa|bb)?+bb");
-
-		Matcher mat;
-		for (String element : posExamples) {
-			mat = posPat.matcher(element);
-			assertTrue(posPat.toString() + " vs: " + element, mat
-					.matches());
-		}
-
-		for (String element : negExamples) {
-			mat = negPat.matcher(element);
-			assertFalse(mat.matches());
-		}
-
-		assertTrue(Pattern.matches("(aa|bb)?+bb", "aabb"));
-	}
-
-	public void testRelCompGroup() {
-
-		Matcher mat;
-		Pattern pat;
-		String res = "";
-		for (int i = 0; i < 4; i++) {
-			pat = Pattern.compile("((aa|bb){" + i + ",3}?).*cc");
-			mat = pat.matcher("aaaaaacc");
-			assertTrue(pat.toString() + " vs: " + "aaaaaacc", mat.matches());
-			assertEquals(res, mat.group(1));
-			res += "aa";
-		}
-	}
-
-	public void testRelAltGroup() {
-
-		Matcher mat;
-		Pattern pat;
-
-		pat = Pattern.compile("((aa|bb)??).*cc");
-		mat = pat.matcher("aacc");
-		assertTrue(pat.toString() + " vs: " + "aacc", mat.matches());
-		assertEquals("", mat.group(1));
-
-		pat = Pattern.compile("((aa|bb)??)cc");
-		mat = pat.matcher("aacc");
-		assertTrue(pat.toString() + " vs: " + "aacc", mat.matches());
-		assertEquals("aa", mat.group(1));
-	}
-
-	public void testIgnoreCase() {
-		Pattern pat = Pattern.compile("(aa|bb)*", Pattern.CASE_INSENSITIVE);
-		Matcher mat = pat.matcher("aAbb");
-
-		assertTrue(mat.matches());
-
-		pat = Pattern.compile("(a|b|c|d|e)*", Pattern.CASE_INSENSITIVE);
-		mat = pat.matcher("aAebbAEaEdebbedEccEdebbedEaedaebEbdCCdbBDcdcdADa");
-		assertTrue(mat.matches());
-
-		pat = Pattern.compile("[a-e]*", Pattern.CASE_INSENSITIVE);
-		mat = pat.matcher("aAebbAEaEdebbedEccEdebbedEaedaebEbdCCdbBDcdcdADa");
-		assertTrue(mat.matches());
-
-	}
-
-	public void testQuoteReplacement() {
-		assertEquals("\\\\aaCC\\$1", Matcher.quoteReplacement("\\aaCC$1"));
-	}
-
-	public void testOverFlow() {
-		Pattern tp = Pattern.compile("(a*)*");
-		Matcher tm = tp.matcher("aaa");
-		assertTrue(tm.matches());
-		assertEquals("", tm.group(1));
-
-		assertTrue(Pattern.matches("(1+)\\1+", "11"));
-		assertTrue(Pattern.matches("(1+)(2*)\\2+", "11"));
-
-		Pattern pat = Pattern.compile("(1+)\\1*");
-		Matcher mat = pat.matcher("11");
-
-		assertTrue(mat.matches());
-		assertEquals("11", mat.group(1));
-
-		pat = Pattern.compile("((1+)|(2+))(\\2+)");
-		mat = pat.matcher("11");
-
-		assertTrue(mat.matches());
-		assertEquals("1", mat.group(2));
-		assertEquals("1", mat.group(1));
-		assertEquals("1", mat.group(4));
-		assertNull(mat.group(3));
-
-	}
-
-	public void testUnicode() {
-
-		assertTrue(Pattern.matches("\\x61a", "aa"));
-		assertTrue(Pattern.matches("\\u0061a", "aa"));
-		assertTrue(Pattern.matches("\\0141a", "aa"));
-		assertTrue(Pattern.matches("\\0777", "?7"));
-
-	}
-
-	public void testUnicodeCategory() {
-		assertTrue(Pattern.matches("\\p{Ll}", "k")); // Unicode lower case
-		assertTrue(Pattern.matches("\\P{Ll}", "K")); // Unicode non-lower
-														// case
-		assertTrue(Pattern.matches("\\p{Lu}", "K")); // Unicode upper case
-		assertTrue(Pattern.matches("\\P{Lu}", "k")); // Unicode non-upper
-														// case
-		// combinations
-		assertTrue(Pattern.matches("[\\p{L}&&[^\\p{Lu}]]", "k"));
-		assertTrue(Pattern.matches("[\\p{L}&&[^\\p{Ll}]]", "K"));
-		assertFalse(Pattern.matches("[\\p{L}&&[^\\p{Lu}]]", "K"));
-		assertFalse(Pattern.matches("[\\p{L}&&[^\\p{Ll}]]", "k"));
-
-		// category/character combinations
-		assertFalse(Pattern.matches("[\\p{L}&&[^a-z]]", "k"));
-		assertTrue(Pattern.matches("[\\p{L}&&[^a-z]]", "K"));
-
-		assertTrue(Pattern.matches("[\\p{Lu}a-z]", "k"));
-		assertTrue(Pattern.matches("[a-z\\p{Lu}]", "k"));
-
-		assertFalse(Pattern.matches("[\\p{Lu}a-d]", "k"));
-		assertTrue(Pattern.matches("[a-d\\p{Lu}]", "K"));
-
-//		assertTrue(Pattern.matches("[\\p{L}&&[^\\p{Lu}&&[^K]]]", "K"));
-		assertFalse(Pattern.matches("[\\p{L}&&[^\\p{Lu}&&[^G]]]", "K"));
-
-	}
-
-	public void testSplitEmpty() {
-
-		Pattern pat = Pattern.compile("");
-		String[] s = pat.split("", -1);
-
-		assertEquals(1, s.length);
-		assertEquals("", s[0]);
-	}
-
-	public void testFindDollar() {
-		Matcher mat = Pattern.compile("a$").matcher("a\n");
-		assertTrue(mat.find());
-		assertEquals("a", mat.group());
-	}
-
-	/*
-	 * Verify if the Matcher can match the input when region is changed
-	 */
-	public void testMatchesRegionChanged() {
-		// Regression for HARMONY-610
-		String input = " word ";
-		Pattern pattern = Pattern.compile("\\w+");
-		Matcher matcher = pattern.matcher(input);
-		matcher.region(1, 5);
-		assertTrue(matcher.matches());
-	}
-
-        public void testAllCodePoints() {
-                // Regression for HARMONY-3145
-                int[] codePoint = new int[1];
-		Pattern p = Pattern.compile("(\\p{all})+");		
-		boolean res = true;
-		int cnt = 0;
-		String s;
-		for (int i =0; i < 0x110000; i ++) {
-			codePoint[0] = i;
-			s = new String(codePoint, 0, 1);
-			if (!s.matches(p.toString())) {
-				cnt++;
-				res = false;
-			}
-		}
-		assertTrue(res);
-                assertEquals(0, cnt);
-		
-		p = Pattern.compile("(\\P{all})+");		
-		res = true;
-		cnt = 0;
-		
-		for (int i =0; i < 0x110000; i ++) {
-			codePoint[0] = i;
-			s = new String(codePoint, 0, 1);			
-			if (!s.matches(p.toString())) {
-				cnt++;
-				res = false;
-			}
-		}		 
-		
-		assertFalse(res);
-                assertEquals(0x110000, cnt);
-        } 
-
-	/*
-	 * Verify if the Matcher behaves correct when region is changed
-	 */
-	public void testFindRegionChanged() {
-		// Regression for HARMONY-625
-		Pattern pattern = Pattern.compile("(?s).*");
-		Matcher matcher = pattern.matcher("abcde");
-		matcher.find();
-		assertEquals("abcde", matcher.group());
-
-		matcher = pattern.matcher("abcde");
-		matcher.region(0, 2);
-		matcher.find();
-		assertEquals("ab", matcher.group());
+    String[] testPatterns = {
+            "(a|b)*abb",
+            "(1*2*3*4*)*567",
+            "(a|b|c|d)*aab",
+            "(1|2|3|4|5|6|7|8|9|0)(1|2|3|4|5|6|7|8|9|0)*",
+            "(abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ)*",
+            "(a|b)*(a|b)*A(a|b)*lice.*",
+            "(a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z)(a|b|c|d|e|f|g|h|"
+                    + "i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z)*(1|2|3|4|5|6|7|8|9|0)*|while|for|struct|if|do" };
+
+    String[] groupPatterns = { "(a|b)*aabb", "((a)|b)*aabb", "((a|b)*)a(abb)",
+            "(((a)|(b))*)aabb", "(((a)|(b))*)aa(b)b", "(((a)|(b))*)a(a(b)b)" };
+
+    public void testAppendReplacement() {
+        Pattern pat = Pattern.compile("XX");
+        Matcher m = pat.matcher("Today is XX-XX-XX ...");
+        StringBuffer sb = new StringBuffer();
+
+        for (int i = 0; m.find(); i++) {
+            m.appendReplacement(sb, new Integer(i * 10 + i).toString());
+        }
+        m.appendTail(sb);
+        assertEquals("Today is 0-11-22 ...", sb.toString());
+    }
+
+    public void testAppendReplacementRef() {
+        Pattern p = Pattern.compile("xx (rur|\\$)");
+        Matcher m = p.matcher("xx $ equals to xx rur.");
+        StringBuffer sb = new StringBuffer();
+        for (int i = 1; m.find(); i *= 30) {
+            String rep = new Integer(i).toString() + " $1";
+            m.appendReplacement(sb, rep);
+        }
+        m.appendTail(sb);
+        assertEquals("1 $ equals to 30 rur.", sb.toString());
+    }
+
+    public void testReplaceAll() {
+        String input = "aabfooaabfooabfoob";
+        String pattern = "a*b";
+        Pattern pat = Pattern.compile(pattern);
+        Matcher mat = pat.matcher(input);
+
+        assertEquals("-foo-foo-foo-", mat.replaceAll("-"));
+    }
+
+    /*
+     * Class under test for Matcher reset(CharSequence)
+     */
+    public void testResetCharSequence() {
+    }
+
+    public void testAppendSlashes() {
+        Pattern p = Pattern.compile("\\\\");
+        Matcher m = p.matcher("one\\cat\\two\\cats\\in\\the\\yard");
+        StringBuffer sb = new StringBuffer();
+        while (m.find()) {
+            m.appendReplacement(sb, "\\\\");
+        }
+        m.appendTail(sb);
+        assertEquals("one\\cat\\two\\cats\\in\\the\\yard", sb.toString());
+
+    }
+
+    public void testReplaceFirst() {
+        String input = "zzzdogzzzdogzzz";
+        String pattern = "dog";
+        Pattern pat = Pattern.compile(pattern);
+        Matcher mat = pat.matcher(input);
+
+        assertEquals("zzzcatzzzdogzzz", mat.replaceFirst("cat"));
+    }
+
+    public void testPattern() {
+        for (String element : testPatterns) {
+            Pattern test = Pattern.compile(element);
+            assertEquals(test, test.matcher("aaa").pattern());
+        }
+
+        for (String element : testPatterns) {
+            assertEquals(element, Pattern.compile(element).matcher("aaa")
+                    .pattern().toString());
+        }
+    }
+
+    /*
+     * Class under test for Matcher reset()
+     */
+    public void testReset() {
+    }
+
+    /*
+     * Class under test for String group(int)
+     */
+    public void testGroupint() {
+        String positiveTestString = "ababababbaaabb";
+
+        // test IndexOutOfBoundsException
+        // //
+        for (int i = 0; i < groupPatterns.length; i++) {
+            Pattern test = Pattern.compile(groupPatterns[i]);
+            Matcher mat = test.matcher(positiveTestString);
+            mat.matches();
+            try {
+                // groupPattern <index + 1> equals to number of groups
+                // of the specified pattern
+                // //
+                mat.group(i + 2);
+                fail("IndexOutBoundsException expected");
+                mat.group(i + 100);
+                fail("IndexOutBoundsException expected");
+                mat.group(-1);
+                fail("IndexOutBoundsException expected");
+                mat.group(-100);
+                fail("IndexOutBoundsException expected");
+            } catch (IndexOutOfBoundsException iobe) {
+            }
+        }
+
+        String[][] groupResults = { { "a" }, { "a", "a" },
+                { "ababababba", "a", "abb" }, { "ababababba", "a", "a", "b" },
+                { "ababababba", "a", "a", "b", "b" },
+                { "ababababba", "a", "a", "b", "abb", "b" }, };
+
+        for (int i = 0; i < groupPatterns.length; i++) {
+            Pattern test = Pattern.compile(groupPatterns[i]);
+            Matcher mat = test.matcher(positiveTestString);
+            mat.matches();
+            for (int j = 0; j < groupResults[i].length; j++) {
+                assertEquals("i: " + i + " j: " + j, groupResults[i][j], mat
+                        .group(j + 1));
+            }
+
+        }
+
+    }
+
+    public void testGroup() {
+        String positiveTestString = "ababababbaaabb";
+        String negativeTestString = "gjhfgdsjfhgcbv";
+        for (String element : groupPatterns) {
+            Pattern test = Pattern.compile(element);
+            Matcher mat = test.matcher(positiveTestString);
+            mat.matches();
+            // test result
+            assertEquals(positiveTestString, mat.group());
+
+            // test equal to group(0) result
+            assertEquals(mat.group(0), mat.group());
+        }
+
+        for (String element : groupPatterns) {
+            Pattern test = Pattern.compile(element);
+            Matcher mat = test.matcher(negativeTestString);
+            mat.matches();
+            try {
+                mat.group();
+                fail("IllegalStateException expected for <false> matches result");
+            } catch (IllegalStateException ise) {
+            }
+        }
+    }
+
+    public void testGroupPossessive() {
+        Pattern pat = Pattern.compile("((a)|(b))++c");
+        Matcher mat = pat.matcher("aac");
+
+        mat.matches();
+        assertEquals("a", mat.group(1));
+    }
+
+    /*
+     * Class under test for boolean find(int)
+     */
+    public void testFindint() {
+    }
+
+    /*
+     * Class under test for int start(int)
+     */
+    public void testStartint() {
+    }
+
+    /*
+     * Class under test for int end(int)
+     */
+    public void testEndint() {
+    }
+
+    public void testMatchesMisc() {
+        String[][] posSeq = {
+                { "abb", "ababb", "abababbababb", "abababbababbabababbbbbabb" },
+                { "213567", "12324567", "1234567", "213213567",
+                        "21312312312567", "444444567" },
+                { "abcdaab", "aab", "abaab", "cdaab", "acbdadcbaab" },
+                { "213234567", "3458", "0987654", "7689546432", "0398576",
+                        "98432", "5" },
+                {
+                        "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
+                        "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                                + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" },
+                { "ababbaAabababblice", "ababbaAliceababab", "ababbAabliceaaa",
+                        "abbbAbbbliceaaa", "Alice" },
+                { "a123", "bnxnvgds156", "for", "while", "if", "struct" }
+
+        };
+
+        for (int i = 0; i < testPatterns.length; i++) {
+            Pattern pat = Pattern.compile(testPatterns[i]);
+            for (int j = 0; j < posSeq[i].length; j++) {
+                Matcher mat = pat.matcher(posSeq[i][j]);
+                assertTrue("Incorrect match: " + testPatterns[i] + " vs "
+                        + posSeq[i][j], mat.matches());
+            }
+        }
+    }
+
+    public void testMatchesQuantifiers() {
+        String[] testPatternsSingles = { "a{5}", "a{2,4}", "a{3,}" };
+        String[] testPatternsMultiple = { "((a)|(b)){1,2}abb",
+                "((a)|(b)){2,4}", "((a)|(b)){3,}" };
+
+        String[][] stringSingles = { { "aaaaa", "aaa" },
+                { "aa", "a", "aaa", "aaaaaa", "aaaa", "aaaaa" },
+                { "aaa", "a", "aaaa", "aa" }, };
+
+        String[][] stringMultiples = { { "ababb", "aba" },
+                { "ab", "b", "bab", "ababa", "abba", "abababbb" },
+                { "aba", "b", "abaa", "ba" }, };
+
+        for (int i = 0; i < testPatternsSingles.length; i++) {
+            Pattern pat = Pattern.compile(testPatternsSingles[i]);
+            for (int j = 0; j < stringSingles.length / 2; j++) {
+                assertTrue("Match expected, but failed: " + pat.pattern()
+                        + " : " + stringSingles[i][j], pat.matcher(
+                        stringSingles[i][j * 2]).matches());
+                assertFalse("Match failure expected, but match succeed: "
+                        + pat.pattern() + " : " + stringSingles[i][j * 2 + 1],
+                        pat.matcher(stringSingles[i][j * 2 + 1]).matches());
+            }
+        }
+
+        for (int i = 0; i < testPatternsMultiple.length; i++) {
+            Pattern pat = Pattern.compile(testPatternsMultiple[i]);
+            for (int j = 0; j < stringMultiples.length / 2; j++) {
+                assertTrue("Match expected, but failed: " + pat.pattern()
+                        + " : " + stringMultiples[i][j], pat.matcher(
+                        stringMultiples[i][j * 2]).matches());
+                assertFalse(
+                        "Match failure expected, but match succeed: "
+                                + pat.pattern() + " : "
+                                + stringMultiples[i][j * 2 + 1], pat.matcher(
+                                stringMultiples[i][j * 2 + 1]).matches());
+            }
+        }
+    }
+
+    public void testQuantVsGroup() {
+        String patternString = "(d{1,3})((a|c)*)(d{1,3})((a|c)*)(d{1,3})";
+        String testString = "dacaacaacaaddaaacaacaaddd";
+
+        Pattern pat = Pattern.compile(patternString);
+        Matcher mat = pat.matcher(testString);
+
+        mat.matches();
+        assertEquals("dacaacaacaaddaaacaacaaddd", mat.group());
+        assertEquals("d", mat.group(1));
+        assertEquals("acaacaacaa", mat.group(2));
+        assertEquals("dd", mat.group(4));
+        assertEquals("aaacaacaa", mat.group(5));
+        assertEquals("ddd", mat.group(7));
+    }
+
+    public void testLookingAt() {
+    }
+
+    /*
+     * Class under test for boolean find()
+     */
+    public void testFind() {
+        String testPattern = "(abb)";
+        String testString = "cccabbabbabbabbabb";
+        Pattern pat = Pattern.compile(testPattern);
+        Matcher mat = pat.matcher(testString);
+        int start = 3;
+        int end = 6;
+        while (mat.find()) {
+            assertEquals(start, mat.start(1));
+            assertEquals(end, mat.end(1));
+
+            start = end;
+            end += 3;
+        }
+
+        testPattern = "(\\d{1,3})";
+        testString = "aaaa123456789045";
+
+        Pattern pat2 = Pattern.compile(testPattern);
+        Matcher mat2 = pat2.matcher(testString);
+        start = 4;
+        int length = 3;
+        while (mat2.find()) {
+            assertEquals(testString.substring(start, start + length), mat2
+                    .group(1));
+            start += length;
+        }
+    }
+
+    public void testSEOLsymbols() {
+        Pattern pat = Pattern.compile("^a\\(bb\\[$");
+        Matcher mat = pat.matcher("a(bb[");
+
+        assertTrue(mat.matches());
+    }
+
+    /*
+     * Class under test for int start()
+     */
+    public void testStart() {
+    }
+
+    public void testGroupCount() {
+        for (int i = 0; i < groupPatterns.length; i++) {
+            Pattern test = Pattern.compile(groupPatterns[i]);
+            Matcher mat = test.matcher("ababababbaaabb");
+            mat.matches();
+            assertEquals(i + 1, mat.groupCount());
+
+        }
+    }
+
+    public void testRelactantQuantifiers() {
+        Pattern pat = Pattern.compile("(ab*)*b");
+        Matcher mat = pat.matcher("abbbb");
+
+        if (mat.matches()) {
+            assertEquals("abbb", mat.group(1));
+        } else {
+            fail("Match expected: (ab*)*b vs abbbb");
+        }
+    }
+
+    public void testEnhancedFind() {
+        String input = "foob";
+        String pattern = "a*b";
+        Pattern pat = Pattern.compile(pattern);
+        Matcher mat = pat.matcher(input);
+
+        mat.find();
+        assertEquals("b", mat.group());
+    }
+
+    public void _testMatchesURI() {
+        final Pattern pat = Pattern
+                .compile("^(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?");
+        Runnable r1 = new Runnable() {
+            public void run() {
+                Matcher mat = pat
+                        .matcher("file:/c:/workspace/api/build.win32/classes/META-INF/"
+                                + "services/javax.xml.parsers.DocumentBuilderFactory");
+                while (mat.matches()) {
+                    // Do nothing
+                }
+                System.out.println("1: fail");
+            }
+        };
+
+        Runnable r2 = new Runnable() {
+            public void run() {
+                Matcher mat = pat.matcher("file:/c:/workspace/"
+                        + "services/javax.xml.parsers.DocumentBuilderFactory");
+                while (mat.matches()) {
+                    // Do nothing
+                }
+                System.out.println("2: fail");
+            }
+        };
+
+        Thread t1 = new Thread(r1);
+        Thread t2 = new Thread(r2);
+
+        t1.start();
+        t2.start();
+
+        try {
+            t1.join();
+            t2.join();
+        } catch (Exception e) {
+        }
+
+    }
+
+    public void _testUnifiedQuantifiers() {
+        // Pattern pat1 = Pattern.compile("\\s+a");
+        Pattern pat2 = Pattern.compile(" *a");
+
+        Matcher mat = pat2.matcher("      a");
+
+        System.out.println("unified: " + mat.find());
+    }
+
+    public void _testCompositeGroupQuantifiers() {
+        Pattern pat = Pattern.compile("(a|b){0,3}abb");
+        Matcher mat = pat.matcher("ababababababababababaab");
 
-	}
+        System.out.println("composite: " + mat.find());
+    }
+
+    public void testPosCompositeGroup() {
+        String[] posExamples = { "aabbcc", "aacc", "bbaabbcc" };
+        String[] negExamples = { "aabb", "bb", "bbaabb" };
+        Pattern posPat = Pattern.compile("(aa|bb){1,3}+cc");
+        Pattern negPat = Pattern.compile("(aa|bb){1,3}+bb");
+
+        Matcher mat;
+        for (String element : posExamples) {
+            mat = posPat.matcher(element);
+            assertTrue(mat.matches());
+        }
+
+        for (String element : negExamples) {
+            mat = negPat.matcher(element);
+            assertFalse(mat.matches());
+        }
+
+        assertTrue(Pattern.matches("(aa|bb){1,3}+bb", "aabbaabb"));
+
+    }
+
+    public void testPosAltGroup() {
+        String[] posExamples = { "aacc", "bbcc", "cc" };
+        String[] negExamples = { "bb", "aa" };
+        Pattern posPat = Pattern.compile("(aa|bb)?+cc");
+        Pattern negPat = Pattern.compile("(aa|bb)?+bb");
+
+        Matcher mat;
+        for (String element : posExamples) {
+            mat = posPat.matcher(element);
+            assertTrue(posPat.toString() + " vs: " + element, mat.matches());
+        }
+
+        for (String element : negExamples) {
+            mat = negPat.matcher(element);
+            assertFalse(mat.matches());
+        }
+
+        assertTrue(Pattern.matches("(aa|bb)?+bb", "aabb"));
+    }
+
+    public void testRelCompGroup() {
+
+        Matcher mat;
+        Pattern pat;
+        String res = "";
+        for (int i = 0; i < 4; i++) {
+            pat = Pattern.compile("((aa|bb){" + i + ",3}?).*cc");
+            mat = pat.matcher("aaaaaacc");
+            assertTrue(pat.toString() + " vs: " + "aaaaaacc", mat.matches());
+            assertEquals(res, mat.group(1));
+            res += "aa";
+        }
+    }
+
+    public void testRelAltGroup() {
+
+        Matcher mat;
+        Pattern pat;
+
+        pat = Pattern.compile("((aa|bb)??).*cc");
+        mat = pat.matcher("aacc");
+        assertTrue(pat.toString() + " vs: " + "aacc", mat.matches());
+        assertEquals("", mat.group(1));
+
+        pat = Pattern.compile("((aa|bb)??)cc");
+        mat = pat.matcher("aacc");
+        assertTrue(pat.toString() + " vs: " + "aacc", mat.matches());
+        assertEquals("aa", mat.group(1));
+    }
+
+    public void testIgnoreCase() {
+        Pattern pat = Pattern.compile("(aa|bb)*", Pattern.CASE_INSENSITIVE);
+        Matcher mat = pat.matcher("aAbb");
+
+        assertTrue(mat.matches());
+
+        pat = Pattern.compile("(a|b|c|d|e)*", Pattern.CASE_INSENSITIVE);
+        mat = pat.matcher("aAebbAEaEdebbedEccEdebbedEaedaebEbdCCdbBDcdcdADa");
+        assertTrue(mat.matches());
+
+        pat = Pattern.compile("[a-e]*", Pattern.CASE_INSENSITIVE);
+        mat = pat.matcher("aAebbAEaEdebbedEccEdebbedEaedaebEbdCCdbBDcdcdADa");
+        assertTrue(mat.matches());
+
+    }
+
+    public void testQuoteReplacement() {
+        assertEquals("\\\\aaCC\\$1", Matcher.quoteReplacement("\\aaCC$1"));
+    }
+
+    public void testOverFlow() {
+        Pattern tp = Pattern.compile("(a*)*");
+        Matcher tm = tp.matcher("aaa");
+        assertTrue(tm.matches());
+        assertEquals("", tm.group(1));
+
+        assertTrue(Pattern.matches("(1+)\\1+", "11"));
+        assertTrue(Pattern.matches("(1+)(2*)\\2+", "11"));
+
+        Pattern pat = Pattern.compile("(1+)\\1*");
+        Matcher mat = pat.matcher("11");
+
+        assertTrue(mat.matches());
+        assertEquals("11", mat.group(1));
+
+        pat = Pattern.compile("((1+)|(2+))(\\2+)");
+        mat = pat.matcher("11");
+
+        assertTrue(mat.matches());
+        assertEquals("1", mat.group(2));
+        assertEquals("1", mat.group(1));
+        assertEquals("1", mat.group(4));
+        assertNull(mat.group(3));
+
+    }
+
+    public void testUnicode() {
+
+        assertTrue(Pattern.matches("\\x61a", "aa"));
+        assertTrue(Pattern.matches("\\u0061a", "aa"));
+        assertTrue(Pattern.matches("\\0141a", "aa"));
+        assertTrue(Pattern.matches("\\0777", "?7"));
+
+    }
+
+    public void testUnicodeCategory() {
+        assertTrue(Pattern.matches("\\p{Ll}", "k")); // Unicode lower case
+        assertTrue(Pattern.matches("\\P{Ll}", "K")); // Unicode non-lower
+        // case
+        assertTrue(Pattern.matches("\\p{Lu}", "K")); // Unicode upper case
+        assertTrue(Pattern.matches("\\P{Lu}", "k")); // Unicode non-upper
+        // case
+        // combinations
+        assertTrue(Pattern.matches("[\\p{L}&&[^\\p{Lu}]]", "k"));
+        assertTrue(Pattern.matches("[\\p{L}&&[^\\p{Ll}]]", "K"));
+        assertFalse(Pattern.matches("[\\p{L}&&[^\\p{Lu}]]", "K"));
+        assertFalse(Pattern.matches("[\\p{L}&&[^\\p{Ll}]]", "k"));
+
+        // category/character combinations
+        assertFalse(Pattern.matches("[\\p{L}&&[^a-z]]", "k"));
+        assertTrue(Pattern.matches("[\\p{L}&&[^a-z]]", "K"));
+
+        assertTrue(Pattern.matches("[\\p{Lu}a-z]", "k"));
+        assertTrue(Pattern.matches("[a-z\\p{Lu}]", "k"));
+
+        assertFalse(Pattern.matches("[\\p{Lu}a-d]", "k"));
+        assertTrue(Pattern.matches("[a-d\\p{Lu}]", "K"));
+
+        // assertTrue(Pattern.matches("[\\p{L}&&[^\\p{Lu}&&[^K]]]", "K"));
+        assertFalse(Pattern.matches("[\\p{L}&&[^\\p{Lu}&&[^G]]]", "K"));
+
+    }
+
+    public void testSplitEmpty() {
+
+        Pattern pat = Pattern.compile("");
+        String[] s = pat.split("", -1);
+
+        assertEquals(1, s.length);
+        assertEquals("", s[0]);
+    }
+
+    public void testFindDollar() {
+        Matcher mat = Pattern.compile("a$").matcher("a\n");
+        assertTrue(mat.find());
+        assertEquals("a", mat.group());
+    }
+
+    /*
+     * Verify if the Matcher can match the input when region is changed
+     */
+    public void testMatchesRegionChanged() {
+        // Regression for HARMONY-610
+        String input = " word ";
+        Pattern pattern = Pattern.compile("\\w+");
+        Matcher matcher = pattern.matcher(input);
+        matcher.region(1, 5);
+        assertTrue(matcher.matches());
+    }
+
+    public void testAllCodePoints() {
+        // Regression for HARMONY-3145
+        int[] codePoint = new int[1];
+        Pattern p = Pattern.compile("(\\p{all})+");
+        boolean res = true;
+        int cnt = 0;
+        String s;
+        for (int i = 0; i < 0x110000; i++) {
+            codePoint[0] = i;
+            s = new String(codePoint, 0, 1);
+            if (!s.matches(p.toString())) {
+                cnt++;
+                res = false;
+            }
+        }
+        assertTrue(res);
+        assertEquals(0, cnt);
+
+        p = Pattern.compile("(\\P{all})+");
+        res = true;
+        cnt = 0;
+
+        for (int i = 0; i < 0x110000; i++) {
+            codePoint[0] = i;
+            s = new String(codePoint, 0, 1);
+            if (!s.matches(p.toString())) {
+                cnt++;
+                res = false;
+            }
+        }
+
+        assertFalse(res);
+        assertEquals(0x110000, cnt);
+    }
+
+    /*
+     * Verify if the Matcher behaves correct when region is changed
+     */
+    public void testFindRegionChanged() {
+        // Regression for HARMONY-625
+        Pattern pattern = Pattern.compile("(?s).*");
+        Matcher matcher = pattern.matcher("abcde");
+        matcher.find();
+        assertEquals("abcde", matcher.group());
+
+        matcher = pattern.matcher("abcde");
+        matcher.region(0, 2);
+        matcher.find();
+        assertEquals("ab", matcher.group());
+
+    }
 
     /*
      * Verify if the Matcher behaves correct with pattern "c" when region is
@@ -680,10 +679,10 @@
 
         assertFalse(matcher.find());
     }
-    
-	/*
-	 * Regression test for HARMONY-674
-	 */
+
+    /*
+     * Regression test for HARMONY-674
+     */
     public void testPatternMatcher() throws Exception {
         Pattern pattern = Pattern.compile("(?:\\d+)(?:pt)");
         assertTrue(pattern.matcher("14pt").matches());
@@ -704,7 +703,8 @@
      * Regression test for HARMONY-3360
      */
     public void testGeneralPunctuationCategory() {
-        String[] s = {",", "!", "\"", "#", "%", "&", "'", "(", ")", "-", ".", "/"};
+        String[] s = { ",", "!", "\"", "#", "%", "&", "'", "(", ")", "-", ".",
+                "/" };
         String regexp = "\\p{P}";
 
         for (int i = 0; i < s.length; i++) {
@@ -763,6 +763,6 @@
     }
 
     public static void main(String[] args) {
-		junit.textui.TestRunner.run(MatcherTest.class);
-	}
+        junit.textui.TestRunner.run(MatcherTest.class);
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/ModeTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/ModeTest.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/ModeTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/ModeTest.java Tue Oct 30 09:48:16 2007
@@ -16,101 +16,96 @@
 
 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;
+
 /**
  * Tests Pattern compilation modes and modes triggered in pattern strings
- * 
  */
+@SuppressWarnings("nls")
 public class ModeTest extends TestCase {
-	public void testCase() throws PatternSyntaxException {
+    public void testCase() throws PatternSyntaxException {
         Pattern p;
         Matcher m;
 
         p = Pattern.compile("([a-z]+)[0-9]+");
-		m = p.matcher("cAT123#dog345");
+        m = p.matcher("cAT123#dog345");
+        assertTrue(m.find());
+        assertEquals("dog", m.group(1));
+        assertFalse(m.find());
+
+        p = Pattern.compile("([a-z]+)[0-9]+", Pattern.CASE_INSENSITIVE);
+        m = p.matcher("cAt123#doG345");
+        assertTrue(m.find());
+        assertEquals("cAt", m.group(1));
         assertTrue(m.find());
-		assertEquals("dog", m.group(1));
-		assertFalse(m.find());
+        assertEquals("doG", m.group(1));
+        assertFalse(m.find());
 
-        
-		p = Pattern.compile("([a-z]+)[0-9]+", Pattern.CASE_INSENSITIVE);
-		m = p.matcher("cAt123#doG345");
-        assertTrue(m.find());
-		assertEquals("cAt", m.group(1));
-		assertTrue(m.find());
-		assertEquals("doG", m.group(1));
-		assertFalse(m.find());
-
-        
-		p = Pattern.compile("(?i)([a-z]+)[0-9]+");
-		m = p.matcher("cAt123#doG345");
-        assertTrue(m.find());
-		assertEquals("cAt", m.group(1));
-		assertTrue(m.find());
-		assertEquals("doG", m.group(1));
-		assertFalse(m.find());
-	}
-
-	public void testMultiline() throws PatternSyntaxException {
-		Pattern p;
-		Matcher m;
-
-		p = Pattern.compile("^foo");
-		m = p.matcher("foobar");
-        assertTrue(m.find());
-		assertTrue(m.start() == 0 && m.end() == 3);
-		assertFalse(m.find());
-        
-		m = p.matcher("barfoo");
-		assertFalse(m.find());
-
-        
-		p = Pattern.compile("foo$");
-		m = p.matcher("foobar");
-		assertFalse(m.find());
-
-		m = p.matcher("barfoo");
-		assertTrue(m.find());
-		assertTrue(m.start() == 3 && m.end() == 6);
-		assertFalse(m.find());
-
-
-		p = Pattern.compile("^foo([0-9]*)", Pattern.MULTILINE);
-		m = p.matcher("foo1bar\nfoo2foo3\nbarfoo4");
-		assertTrue(m.find());
-		assertEquals("1", m.group(1));
-		assertTrue(m.find());
-		assertEquals("2", m.group(1));
-		assertFalse(m.find());
-
-
-		p = Pattern.compile("foo([0-9]*)$", Pattern.MULTILINE);
-		m = p.matcher("foo1bar\nfoo2foo3\nbarfoo4");
-		assertTrue(m.find());
-		assertEquals("3", m.group(1));
-		assertTrue(m.find());
-		assertEquals("4", m.group(1));
-		assertFalse(m.find());
+        p = Pattern.compile("(?i)([a-z]+)[0-9]+");
+        m = p.matcher("cAt123#doG345");
+        assertTrue(m.find());
+        assertEquals("cAt", m.group(1));
+        assertTrue(m.find());
+        assertEquals("doG", m.group(1));
+        assertFalse(m.find());
+    }
+
+    public void testMultiline() throws PatternSyntaxException {
+        Pattern p;
+        Matcher m;
+
+        p = Pattern.compile("^foo");
+        m = p.matcher("foobar");
+        assertTrue(m.find());
+        assertTrue(m.start() == 0 && m.end() == 3);
+        assertFalse(m.find());
 
+        m = p.matcher("barfoo");
+        assertFalse(m.find());
+
+        p = Pattern.compile("foo$");
+        m = p.matcher("foobar");
+        assertFalse(m.find());
+
+        m = p.matcher("barfoo");
+        assertTrue(m.find());
+        assertTrue(m.start() == 3 && m.end() == 6);
+        assertFalse(m.find());
+
+        p = Pattern.compile("^foo([0-9]*)", Pattern.MULTILINE);
+        m = p.matcher("foo1bar\nfoo2foo3\nbarfoo4");
+        assertTrue(m.find());
+        assertEquals("1", m.group(1));
+        assertTrue(m.find());
+        assertEquals("2", m.group(1));
+        assertFalse(m.find());
+
+        p = Pattern.compile("foo([0-9]*)$", Pattern.MULTILINE);
+        m = p.matcher("foo1bar\nfoo2foo3\nbarfoo4");
+        assertTrue(m.find());
+        assertEquals("3", m.group(1));
+        assertTrue(m.find());
+        assertEquals("4", m.group(1));
+        assertFalse(m.find());
 
         p = Pattern.compile("(?m)^foo([0-9]*)");
-		m = p.matcher("foo1bar\nfoo2foo3\nbarfoo4");
-		assertTrue(m.find());
-		assertEquals("1", m.group(1));
-		assertTrue(m.find());
-		assertEquals("2", m.group(1));
-		assertFalse(m.find());
-
-		p = Pattern.compile("(?m)foo([0-9]*)$");
-		m = p.matcher("foo1bar\nfoo2foo3\nbarfoo4");
-		assertTrue(m.find());
-		assertEquals("3", m.group(1));
-		assertTrue(m.find());
-		assertEquals("4", m.group(1));
-		assertFalse(m.find());
-	}
+        m = p.matcher("foo1bar\nfoo2foo3\nbarfoo4");
+        assertTrue(m.find());
+        assertEquals("1", m.group(1));
+        assertTrue(m.find());
+        assertEquals("2", m.group(1));
+        assertFalse(m.find());
+
+        p = Pattern.compile("(?m)foo([0-9]*)$");
+        m = p.matcher("foo1bar\nfoo2foo3\nbarfoo4");
+        assertTrue(m.find());
+        assertEquals("3", m.group(1));
+        assertTrue(m.find());
+        assertEquals("4", m.group(1));
+        assertFalse(m.find());
+    }
 }



Mime
View raw message