sbailliez 02/01/30 14:05:39
Modified: src/testcases/org/apache/tools/ant/util/regexp
Jdk14RegexpMatcherTest.java RegexpMatcherTest.java
JakartaRegexpRegexpTest.java
Log:
- Added some more tests. All tests that fail have
not been commented but rather modify to trigger
once they are fixed.
If Unix people could tests and make sure that they
pass on Unix that would be nice.
Revision Changes Path
1.2 +35 -0
jakarta-ant/src/testcases/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcherTest.java
Index: Jdk14RegexpMatcherTest.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcherTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Jdk14RegexpMatcherTest.java 11 Jul 2001 08:03:10 -0000 1.1
+++ Jdk14RegexpMatcherTest.java 30 Jan 2002 22:05:38 -0000 1.2
@@ -54,6 +54,10 @@
package org.apache.tools.ant.util.regexp;
+import java.io.IOException;
+
+import junit.framework.AssertionFailedError;
+
/**
* Tests for the JDK 1.4 implementation of the RegexpMatcher interface.
*
@@ -69,4 +73,35 @@
super(name);
}
+ public void testParagraphCharacter() throws IOException {
+ try {
+ super.testParagraphCharacter();
+ fail("Should trigger once fixed. [EMAIL PROTECTED] JDK 1.4RC1}");
+ } catch (AssertionFailedError e){
+ }
+ }
+
+ public void testLineSeparatorCharacter() throws IOException {
+ try {
+ super.testLineSeparatorCharacter();
+ fail("Should trigger once fixed. [EMAIL PROTECTED] JDK 1.4RC1}");
+ } catch (AssertionFailedError e){
+ }
+ }
+
+ public void testStandaloneCR() throws IOException {
+ try {
+ super.testStandaloneCR();
+ fail("Should trigger once fixed. [EMAIL PROTECTED] JDK 1.4RC1}");
+ } catch (AssertionFailedError e){
+ }
+ }
+
+ public void testWindowsLineSeparator() throws IOException {
+ try {
+ super.testWindowsLineSeparator();
+ fail("Should trigger once fixed. [EMAIL PROTECTED] JDK 1.4RC1}");
+ } catch (AssertionFailedError e){
+ }
+ }
}
1.8 +45 -8
jakarta-ant/src/testcases/org/apache/tools/ant/util/regexp/RegexpMatcherTest.java
Index: RegexpMatcherTest.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/util/regexp/RegexpMatcherTest.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- RegexpMatcherTest.java 10 Jan 2002 10:13:13 -0000 1.7
+++ RegexpMatcherTest.java 30 Jan 2002 22:05:38 -0000 1.8
@@ -68,6 +68,8 @@
*/
public abstract class RegexpMatcherTest extends TestCase {
+ public final static String UNIX_LINE = "\n";
+
private RegexpMatcher reg;
public abstract RegexpMatcher getImplementation();
@@ -138,15 +140,50 @@
reg.matches("AAaa",
RegexpMatcher.MATCH_CASE_INSENSITIVE));
}
+
+// make sure there are no issues concerning line separator interpretation
+// a line separator for regex (perl) is always a unix line (ie \n)
+
+ public void testParagraphCharacter() throws IOException {
+ reg.setPattern("end of text$");
+ assertTrue("paragraph character", !reg.matches("end of text\u2029"));
+ }
+
+ public void testLineSeparatorCharacter() throws IOException {
+ reg.setPattern("end of text$");
+ assertTrue("line-separator character", !reg.matches("end of
text\u2028"));
+ }
+
+ public void testNextLineCharacter() throws IOException {
+ reg.setPattern("end of text$");
+ assertTrue("next-line character", !reg.matches("end of text\u0085"));
+ }
+
+ public void testStandaloneCR() throws IOException {
+ reg.setPattern("end of text$");
+ assertTrue("standalone CR", !reg.matches("end of text\r"));
+ }
+
+ public void testWindowsLineSeparator() throws IOException {
+ reg.setPattern("end of text$");
+ assertTrue("Windows line separator", !reg.matches("end of
text\r\n"));
+ reg.setPattern("end of text\r$");
+ assertTrue("Windows line separator", reg.matches("end of text\r\n"));
+ }
+
+ public void testUnixLineSeparator() throws IOException {
+ reg.setPattern("end of text$");
+ assertTrue("Unix line separator", reg.matches("end of text\n"));
+ }
+
+
public void testMultiVersusSingleLine() throws IOException {
- StringWriter swr = new StringWriter();
- PrintWriter p = new PrintWriter(swr);
- p.println("Line1");
- p.println("starttest Line2");
- p.println("Line3 endtest");
- p.println("Line4");
- p.close();
- String text = swr.toString();
+ StringBuffer buf = new StringBuffer();
+ buf.append("Line1").append(UNIX_LINE);
+ buf.append("starttest Line2").append(UNIX_LINE);
+ buf.append("Line3 endtest").append(UNIX_LINE);
+ buf.append("Line4").append(UNIX_LINE);
+ String text = buf.toString();
doStartTest1(text);
doStartTest2(text);
1.3 +30 -0
jakarta-ant/src/testcases/org/apache/tools/ant/util/regexp/JakartaRegexpRegexpTest.java
Index: JakartaRegexpRegexpTest.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/util/regexp/JakartaRegexpRegexpTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JakartaRegexpRegexpTest.java 10 Jan 2002 10:13:13 -0000 1.2
+++ JakartaRegexpRegexpTest.java 30 Jan 2002 22:05:38 -0000 1.3
@@ -54,6 +54,12 @@
package org.apache.tools.ant.util.regexp;
+import java.io.IOException;
+
+import junit.framework.AssertionFailedError;
+
+import org.apache.tools.ant.taskdefs.condition.Os;
+
/**
* Tests for the jakarta-regexp implementation of the Regexp interface.
*
@@ -67,6 +73,30 @@
public JakartaRegexpRegexpTest(String name) {
super(name);
+ }
+
+ public void testWindowsLineSeparator() throws IOException {
+ if ( Os.isFamily("windows") ) {
+ try {
+ super.testWindowsLineSeparator();
+ fail("Windows issue. Should trigger when this bug is fixed.
[EMAIL PROTECTED] 1.2}");
+ } catch (AssertionFailedError e){
+ }
+ } else {
+ super.testWindowsLineSeparator();
+ }
+ }
+
+ public void testUnixLineSeparator() throws IOException {
+ if ( Os.isFamily("windows") ){
+ try {
+ super.testUnixLineSeparator();
+ fail("Windows issue. Should trigger once this bug is fixed.
[EMAIL PROTECTED] 1.2}");
+ } catch (AssertionFailedError e){
+ }
+ } else {
+ super.testUnixLineSeparator();
+ }
}
/**
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>