You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jmeter-dev@jakarta.apache.org by se...@apache.org on 2005/02/20 20:43:50 UTC
cvs commit: jakarta-jmeter/src/jorphan/org/apache/jorphan/util JOrphanUtils.java
sebb 2005/02/20 11:43:50
Modified: src/jorphan/org/apache/jorphan/util Tag: rel-2_0
JOrphanUtils.java
Log:
Added some split() tests
Revision Changes Path
No revision
No revision
1.10.2.1 +23 -3 jakarta-jmeter/src/jorphan/org/apache/jorphan/util/JOrphanUtils.java
Index: JOrphanUtils.java
===================================================================
RCS file: /home/cvs/jakarta-jmeter/src/jorphan/org/apache/jorphan/util/JOrphanUtils.java,v
retrieving revision 1.10
retrieving revision 1.10.2.1
diff -u -r1.10 -r1.10.2.1
--- JOrphanUtils.java 11 Feb 2004 23:57:23 -0000 1.10
+++ JOrphanUtils.java 20 Feb 2005 19:43:50 -0000 1.10.2.1
@@ -43,9 +43,11 @@
}
/**
- * This is equivalent to the String.split method in JDK 1.4. It is
+ * This is _almost_ equivalent to the String.split method in JDK 1.4. It is
* here to enable us to support earlier JDKs.
*
+ * Note that unlike JDK1.4 spilt(), it ignores leading split Characters.
+ *
* <P>This piece of code used to be part of JMeterUtils, but was moved
* here because some JOrphan classes use it too.
*
@@ -288,5 +290,23 @@
{
assertEquals("img src=xyz ",replaceFirst("img src=xyz alt=\"\" ","alt=\"\" ",""));
}
+ public void testSplit1()
+ {
+ String in="a,bc,,"; // Test ignore trailing split characters
+ String out[]=split(in,",");
+ assertEquals(2,out.length);
+ assertEquals("a",out[0]);
+ assertEquals("bc",out[1]);
+ }
+ public void testSplit2()
+ {
+ String in=",,a,bc"; // Test leading split characters
+ String out[]=split(in,",");
+ assertEquals("Should detect the leading split chars; ",2,out.length-2);
+ assertEquals("",out[0]);
+ assertEquals("",out[1]);
+ assertEquals("a",out[2]);
+ assertEquals("bc",out[3]);
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-dev-help@jakarta.apache.org