harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r394041 [1/2] - in /incubator/harmony/enhanced/classlib/trunk/modules/regex: make/common/ src/test/java/tests/api/java/util/regex/
Date Fri, 14 Apr 2006 07:42:18 GMT
Author: mloenko
Date: Fri Apr 14 00:42:15 2006
New Revision: 394041

URL: http://svn.apache.org/viewcvs?rev=394041&view=rev
Log:
inclusion of HARMONY-88 regex tests to test run

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/MatcherTest.java
      - copied, changed from r394009, incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/MatcherTests.java
    incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/ModeTest.java
      - copied, changed from r394009, incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/ModeTests.java
    incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/PatternErrorTest.java
      - copied, changed from r394009, incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/PatternErrorTests.java
    incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/PatternSyntaxExceptionTest.java
      - copied, changed from r394009, incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/PatternSyntaxExceptionTests.java
    incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/PatternTest.java
      - copied, changed from r394009, incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/PatternTests.java
    incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/ReplaceTest.java
      - copied, changed from r394009, incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/ReplaceTests.java
    incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/SplitTest.java
      - copied, changed from r394009, incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/SplitTests.java
Removed:
    incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/MatcherTests.java
    incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/ModeTests.java
    incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/PatternErrorTests.java
    incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/PatternSyntaxExceptionTests.java
    incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/PatternTests.java
    incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/ReplaceTests.java
    incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/SplitTests.java
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/regex/make/common/build.xml
    incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/AllTests.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/regex/make/common/build.xml
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex/make/common/build.xml?rev=394041&r1=394040&r2=394041&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex/make/common/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex/make/common/build.xml Fri Apr
14 00:42:15 2006
@@ -95,6 +95,10 @@
 				<fileset dir="${hy.regex.src.test.java}">
 					<include name="**/*Test.java"/>
 
+
+					<!-- Harmony exclude list -->
+					<exclude name="tests/api/java/util/regex/PatternSyntaxExceptionTest.java"/>
+
 				</fileset>
 			</batchtest>
 		</junit>

Modified: incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/AllTests.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/AllTests.java?rev=394041&r1=394040&r2=394041&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/AllTests.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/AllTests.java
Fri Apr 14 00:42:15 2006
@@ -27,13 +27,13 @@
 	public static Test suite() {
 		TestSuite suite = new TestSuite("API test suite for java.util.regex");
 		// $JUnit-BEGIN$
-		suite.addTestSuite(PatternTests.class);
-		suite.addTestSuite(ModeTests.class);
-		suite.addTestSuite(PatternSyntaxExceptionTests.class);
-		suite.addTestSuite(PatternErrorTests.class);
-		suite.addTestSuite(SplitTests.class);
-		suite.addTestSuite(ReplaceTests.class);
-		suite.addTestSuite(MatcherTests.class);
+		suite.addTestSuite(PatternTest.class);
+		suite.addTestSuite(ModeTest.class);
+		suite.addTestSuite(PatternSyntaxExceptionTest.class);
+		suite.addTestSuite(PatternErrorTest.class);
+		suite.addTestSuite(SplitTest.class);
+		suite.addTestSuite(ReplaceTest.class);
+		suite.addTestSuite(MatcherTest.class);
 		// $JUnit-END$
 		return suite;
 	}

Copied: incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/MatcherTest.java
(from r394009, incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/MatcherTests.java)
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/MatcherTest.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/MatcherTest.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/MatcherTests.java&r1=394009&r2=394041&rev=394041&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/MatcherTests.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/MatcherTest.java
Fri Apr 14 00:42:15 2006
@@ -22,7 +22,7 @@
  * Tests Matcher methods
  * 
  */
-public class MatcherTests extends TestCase {
+public class MatcherTest extends TestCase {
 	public void test_toString() {
 		Pattern p = Pattern.compile("foo");
 		Matcher m = p.matcher("bar");
@@ -30,218 +30,178 @@
 				.toString()));
 	}
 
-	public void testErrorConditions() {
-		Pattern p;
-		Matcher m;
-		boolean errFound;
-		try {
-			// Test match cursors in absence of a match
-			p = Pattern.compile("foo");
-			m = p.matcher("bar");
-			assertFalse(m.matches());
-
-			errFound = false;
-			try {
-				m.start();
-			} catch (IllegalStateException e) {
-				errFound = true;
-			}
-			assertTrue(errFound);
-
-			errFound = false;
-			try {
-				m.end();
-			} catch (IllegalStateException e) {
-				errFound = true;
-			}
-			assertTrue(errFound);
-
-			errFound = false;
-			try {
-				m.group();
-			} catch (IllegalStateException e) {
-				errFound = true;
-			}
-			assertTrue(errFound);
-
-			errFound = false;
-			try {
-				m.start(1);
-			} catch (IllegalStateException e) {
-				errFound = true;
-			}
-			assertTrue(errFound);
-
-			errFound = false;
-			try {
-				m.end(1);
-			} catch (IllegalStateException e) {
-				errFound = true;
-			}
-			assertTrue(errFound);
-
-			errFound = false;
-			try {
-				m.group(1);
-			} catch (IllegalStateException e) {
-				errFound = true;
-			}
-			assertTrue(errFound);
-
-			// Test match cursors in absence of a match
-			p = Pattern.compile("(foo[0-9])(bar[a-z])");
-			m = p.matcher("foo1barzfoo2baryfoozbar5");
-
-			assertTrue(m.find());
-			assertTrue(m.start() == 0);
-			assertTrue(m.end() == 8);
-			assertTrue(m.start(1) == 0);
-			assertTrue(m.end(1) == 4);
-			assertTrue(m.start(2) == 4);
-			assertTrue(m.end(2) == 8);
-			errFound = false;
-			try {
-				m.start(3);
-			} catch (IndexOutOfBoundsException e) {
-				errFound = true;
-			}
-			assertTrue(errFound);
-			errFound = false;
-			try {
-				m.end(3);
-			} catch (IndexOutOfBoundsException e) {
-				errFound = true;
-			}
-			assertTrue(errFound);
-			errFound = false;
-			try {
-				m.group(3);
-			} catch (IndexOutOfBoundsException e) {
-				errFound = true;
-			}
-			assertTrue(errFound);
-			errFound = false;
-			try {
-				m.start(-1);
-			} catch (IndexOutOfBoundsException e) {
-				errFound = true;
-			}
-			assertTrue(errFound);
-			errFound = false;
-			try {
-				m.end(-1);
-			} catch (IndexOutOfBoundsException e) {
-				errFound = true;
-			}
-			assertTrue(errFound);
-			errFound = false;
-			try {
-				m.group(-1);
-			} catch (IndexOutOfBoundsException e) {
-				errFound = true;
-			}
-			assertTrue(errFound);
-
-			assertTrue(m.find());
-			assertTrue(m.start() == 8);
-			assertTrue(m.end() == 16);
-			assertTrue(m.start(1) == 8);
-			assertTrue(m.end(1) == 12);
-			assertTrue(m.start(2) == 12);
-			assertTrue(m.end(2) == 16);
-			errFound = false;
-			try {
-				m.start(3);
-			} catch (IndexOutOfBoundsException e) {
-				errFound = true;
-			}
-			assertTrue(errFound);
-			errFound = false;
-			try {
-				m.end(3);
-			} catch (IndexOutOfBoundsException e) {
-				errFound = true;
-			}
-			assertTrue(errFound);
-			errFound = false;
-			try {
-				m.group(3);
-			} catch (IndexOutOfBoundsException e) {
-				errFound = true;
-			}
-			assertTrue(errFound);
-			errFound = false;
-			try {
-				m.start(-1);
-			} catch (IndexOutOfBoundsException e) {
-				errFound = true;
-			}
-			assertTrue(errFound);
-			errFound = false;
-			try {
-				m.end(-1);
-			} catch (IndexOutOfBoundsException e) {
-				errFound = true;
-			}
-			assertTrue(errFound);
-			errFound = false;
-			try {
-				m.group(-1);
-			} catch (IndexOutOfBoundsException e) {
-				errFound = true;
-			}
-			assertTrue(errFound);
-
-			assertFalse(m.find());
-			errFound = false;
-			try {
-				m.start(3);
-			} catch (IllegalStateException e) {
-				errFound = true;
-			}
-			assertTrue(errFound);
-
-			errFound = false;
-			try {
-				m.end(3);
-			} catch (IllegalStateException e) {
-				errFound = true;
-			}
-			assertTrue(errFound);
-
-			errFound = false;
-			try {
-				m.group(3);
-			} catch (IllegalStateException e) {
-				errFound = true;
-			}
-			assertTrue(errFound);
-
-			errFound = false;
-			try {
-				m.start(-1);
-			} catch (IllegalStateException e) {
-				errFound = true;
-			}
-			assertTrue(errFound);
-
-			errFound = false;
-			try {
-				m.end(-1);
-			} catch (IllegalStateException e) {
-				errFound = true;
-			}
-			assertTrue(errFound);
-
-			errFound = false;
-			try {
-				m.group(-1);
-			} catch (IllegalStateException e) {
-				errFound = true;
-			}
-			assertTrue(errFound);
-		} catch (PatternSyntaxException e) {
-			fail();
+	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) {
+		}
+    }
+
+    public void testErrorConditions2() throws PatternSyntaxException {
+		// 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());
+		assertTrue(m.start() == 0);
+		assertTrue(m.end() == 8);
+		assertTrue(m.start(1) == 0);
+		assertTrue(m.end(1) == 4);
+		assertTrue(m.start(2) == 4);
+		assertTrue(m.end(2) == 8);
+
+		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());
+		assertTrue(m.start() == 8);
+		assertTrue(m.end() == 16);
+		assertTrue(m.start(1) == 8);
+		assertTrue(m.end(1) == 12);
+		assertTrue(m.start(2) == 12);
+		assertTrue(m.end(2) == 16);
+
+		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) {
 		}
 	}
 }

Copied: incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/ModeTest.java
(from r394009, incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/ModeTests.java)
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/ModeTest.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/ModeTest.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/ModeTests.java&r1=394009&r2=394041&rev=394041&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/ModeTests.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/ModeTest.java
Fri Apr 14 00:42:15 2006
@@ -24,80 +24,51 @@
  * Tests Pattern compilation modes and modes triggered in pattern strings
  * 
  */
-public class ModeTests extends TestCase {
-	public void testCase() {
-		Pattern p;
-		Matcher m;
-
-		try {
-			p = Pattern.compile("([a-z]+)[0-9]+");
-		} catch (PatternSyntaxException e) {
-			assertFalse(true);
-			return;
-		}
+public class ModeTest extends TestCase {
+	public void testCase() throws PatternSyntaxException {
+        Pattern p;
+        Matcher m;
 
+        p = Pattern.compile("([a-z]+)[0-9]+");
 		m = p.matcher("cAT123#dog345");
-		assertTrue(m.find());
+        assertTrue(m.find());
 		assertTrue(m.group(1).equals("dog"));
 		assertFalse(m.find());
 
-		try {
-			p = Pattern.compile("([a-z]+)[0-9]+", Pattern.CASE_INSENSITIVE);
-		} catch (PatternSyntaxException e) {
-			assertFalse(true);
-			return;
-		}
-
+        
+		p = Pattern.compile("([a-z]+)[0-9]+", Pattern.CASE_INSENSITIVE);
 		m = p.matcher("cAt123#doG345");
-		assertTrue(m.find());
+        assertTrue(m.find());
 		assertTrue(m.group(1).equals("cAt"));
 		assertTrue(m.find());
 		assertTrue(m.group(1).equals("doG"));
 		assertFalse(m.find());
 
-		try {
-			p = Pattern.compile("(?i)([a-z]+)[0-9]+");
-		} catch (PatternSyntaxException e) {
-			assertFalse(true);
-			return;
-		}
-
+        
+		p = Pattern.compile("(?i)([a-z]+)[0-9]+");
 		m = p.matcher("cAt123#doG345");
-		assertTrue(m.find());
-		System.out.println(m.group());
-		System.out.println(m.group(1));
+        assertTrue(m.find());
 		assertTrue(m.group(1).equals("cAt"));
 		assertTrue(m.find());
 		assertTrue(m.group(1).equals("doG"));
 		assertFalse(m.find());
 	}
 
-	public void testMultiline() {
+	public void testMultiline() throws PatternSyntaxException {
 		Pattern p;
 		Matcher m;
 
-		try {
-			p = Pattern.compile("^foo");
-		} catch (PatternSyntaxException e) {
-			assertFalse(true);
-			return;
-		}
-
+		p = Pattern.compile("^foo");
 		m = p.matcher("foobar");
-		assertTrue(m.find());
+        assertTrue(m.find());
 		assertTrue(m.start() == 0 && m.end() == 3);
 		assertFalse(m.find());
-
+        
 		m = p.matcher("barfoo");
 		assertFalse(m.find());
 
-		try {
-			p = Pattern.compile("foo$");
-		} catch (PatternSyntaxException e) {
-			assertFalse(true);
-			return;
-		}
-
+        
+		p = Pattern.compile("foo$");
 		m = p.matcher("foobar");
 		assertFalse(m.find());
 
@@ -106,13 +77,8 @@
 		assertTrue(m.start() == 3 && m.end() == 6);
 		assertFalse(m.find());
 
-		try {
-			p = Pattern.compile("^foo([0-9]*)", Pattern.MULTILINE);
-		} catch (PatternSyntaxException e) {
-			assertFalse(true);
-			return;
-		}
 
+		p = Pattern.compile("^foo([0-9]*)", Pattern.MULTILINE);
 		m = p.matcher("foo1bar\nfoo2foo3\nbarfoo4");
 		assertTrue(m.find());
 		assertTrue(m.group(1).equals("1"));
@@ -120,13 +86,8 @@
 		assertTrue(m.group(1).equals("2"));
 		assertFalse(m.find());
 
-		try {
-			p = Pattern.compile("foo([0-9]*)$", Pattern.MULTILINE);
-		} catch (PatternSyntaxException e) {
-			assertFalse(true);
-			return;
-		}
 
+		p = Pattern.compile("foo([0-9]*)$", Pattern.MULTILINE);
 		m = p.matcher("foo1bar\nfoo2foo3\nbarfoo4");
 		assertTrue(m.find());
 		assertTrue(m.group(1).equals("3"));
@@ -134,13 +95,8 @@
 		assertTrue(m.group(1).equals("4"));
 		assertFalse(m.find());
 
-		try {
-			p = Pattern.compile("(?m)^foo([0-9]*)");
-		} catch (PatternSyntaxException e) {
-			assertFalse(true);
-			return;
-		}
 
+        p = Pattern.compile("(?m)^foo([0-9]*)");
 		m = p.matcher("foo1bar\nfoo2foo3\nbarfoo4");
 		assertTrue(m.find());
 		assertTrue(m.group(1).equals("1"));
@@ -148,13 +104,7 @@
 		assertTrue(m.group(1).equals("2"));
 		assertFalse(m.find());
 
-		try {
-			p = Pattern.compile("(?m)foo([0-9]*)$");
-		} catch (PatternSyntaxException e) {
-			assertFalse(true);
-			return;
-		}
-
+		p = Pattern.compile("(?m)foo([0-9]*)$");
 		m = p.matcher("foo1bar\nfoo2foo3\nbarfoo4");
 		assertTrue(m.find());
 		assertTrue(m.group(1).equals("3"));

Copied: incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/PatternErrorTest.java
(from r394009, incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/PatternErrorTests.java)
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/PatternErrorTest.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/PatternErrorTest.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/PatternErrorTests.java&r1=394009&r2=394041&rev=394041&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/PatternErrorTests.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/PatternErrorTest.java
Fri Apr 14 00:42:15 2006
@@ -22,37 +22,24 @@
  * Test boundary and error conditions in java.util.regex.Pattern
  * 
  */
-public class PatternErrorTests extends TestCase {
-	public void testCompileErrors() {
-		boolean validException = false;
-
+public class PatternErrorTest extends TestCase {
+	public void testCompileErrors() throws Exception {
 		// null regex string - should get NullPointerException
 		try {
 			Pattern.compile(null);
+            fail("NullPointerException expected");
 		} catch (NullPointerException e) {
-			// This is the expected exception
-			validException = true;
-		} catch (Exception e) {
-			fail();
 		}
-		assertTrue(validException);
+
 
 		// empty regex string - no exception should be thrown
-		try {
-			Pattern.compile("");
-		} catch (Exception e) {
-			fail();
-		}
+		Pattern.compile("");
 
-		// note: invalid regex syntax checked in PatternSyntaxExceptionTests
+		// note: invalid regex syntax checked in PatternSyntaxExceptionTest
 
 		// flags = 0 should raise no exception
 		int flags = 0;
-		try {
-			Pattern.compile("foo", flags);
-		} catch (Exception e) {
-			fail();
-		}
+		Pattern.compile("foo", flags);
 
 		// check that all valid flags accepted without exception
 		flags |= Pattern.UNIX_LINES;
@@ -62,11 +49,7 @@
 		flags |= Pattern.COMMENTS;
 		flags |= Pattern.DOTALL;
 		flags |= Pattern.UNICODE_CASE;
-		try {
-			Pattern.compile("foo", flags);
-		} catch (Exception e) {
-			fail();
-		}
+		Pattern.compile("foo", flags);
 
 		// add invalid flags - should get IllegalArgumentException
 		/*
@@ -84,13 +67,10 @@
 		 *   fail();
 		 * }
 		 */
-		/* Workaround test is: */
+
+        /* Workaround test is: */
 		flags |= 0xFFFFFFFF;
-		try {
-			Pattern.compile("foo", flags);
-		} catch (Exception e) {
-			// No exception expected to match incorrect the reference behaviour
-			fail();
-		}
+        // No exception expected to match incorrect the reference behaviour
+		Pattern.compile("foo", flags);
 	}
 }

Copied: incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/PatternSyntaxExceptionTest.java
(from r394009, incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/PatternSyntaxExceptionTests.java)
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/PatternSyntaxExceptionTest.java?p2=incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/PatternSyntaxExceptionTest.java&p1=incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/PatternSyntaxExceptionTests.java&r1=394009&r2=394041&rev=394041&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/PatternSyntaxExceptionTests.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/tests/api/java/util/regex/PatternSyntaxExceptionTest.java
Fri Apr 14 00:42:15 2006
@@ -24,34 +24,34 @@
  * TODO Type description
  * 
  */
-public class PatternSyntaxExceptionTests extends TestCase {
+public class PatternSyntaxExceptionTest extends TestCase {
 	public void testCase() {
-		String regex;
-		regex = "(";
+		String regex = "(";
 		try {
 			Pattern.compile(regex);
+            fail("PatternSyntaxException expected");
 		} catch (PatternSyntaxException e) {
-			assertTrue(e.getDescription().equals("')' is expected."));
+			assertEquals(e.getDescription(), "')' is expected.");
 			// The reference JDK index:
 			// assertTrue(e.getIndex() == 1);
 			assertTrue(e.getIndex() == 0);
-			assertTrue(e.getMessage().equals(
-					"')' is expected. near index 0\r\n(\r\n^"));
-			assertTrue(e.getPattern().equals(regex));
+			assertEquals(e.getMessage(), "')' is expected. near index 0\r\n(\r\n^");
+			assertEquals(e.getPattern(), regex);
 		}
-
-		regex = "[4-";
+    }
+    
+    public void testCase2() {
+		String regex = "[4-";
 		try {
 			Pattern.compile(regex);
+            fail("PatternSyntaxException expected");
 		} catch (PatternSyntaxException e) {
-			assertTrue(e.getDescription().equals(
-					"Unexpected end of the pattern in a character class."));
+			assertEquals(e.getDescription(), 
+					"Unexpected end of the pattern in a character class.");
 			assertTrue(e.getIndex() == 3);
-			assertTrue(e
-					.getMessage()
-					.equals(
-							"Unexpected end of the pattern in a character class. near index 3\r\n[4-\r\n   ^"));
-			assertTrue(e.getPattern().equals(regex));
+			assertEquals(e.getMessage(),
+							"Unexpected end of the pattern in a character class. near index 3\r\n[4-\r\n   ^");
+            assertEquals(e.getPattern(), regex);
 		}
 	}
 }



Mime
View raw message