Author: chris.laprun(a)jboss.com
Date: 2008-04-22 02:00:13 -0400 (Tue, 22 Apr 2008)
New Revision: 10690
Modified:
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/CharBufferTestCase.java
Log:
- Added more test cases for border conditions and error checking.
Modified:
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/CharBufferTestCase.java
===================================================================
---
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/CharBufferTestCase.java 2008-04-22
05:39:57 UTC (rev 10689)
+++
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/text/CharBufferTestCase.java 2008-04-22
06:00:13 UTC (rev 10690)
@@ -68,10 +68,56 @@
CharBuffer buffer = new CharBuffer();
buffer.append("abcdef".toCharArray(), 1, 5);
assertEquals("bcdef", buffer.asString());
+
buffer.append("pqrstu".toCharArray(), 3, 3);
assertEquals("stu", buffer.asString());
+
+ buffer.append("abc".toCharArray(), 0, 0);
+ assertEquals("", buffer.asString());
+
+ buffer.append("abc".toCharArray(), 3, 0);
+ assertEquals("", buffer.asString());
+
+ buffer.append("abc".toCharArray(), 2, 1);
+ assertEquals("c", buffer.asString());
}
+ public void testAppendCharArrayRobustness()
+ {
+ CharBuffer buffer = new CharBuffer(0);
+
+ try
+ {
+ buffer.append("abc".toCharArray(), 3, 1);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ // expected
+ }
+
+ try
+ {
+ buffer.append("abc".toCharArray(), -1, 1);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ // expected
+ }
+
+ try
+ {
+ buffer.append("abc".toCharArray(), 0, 4);
+ fail();
+ }
+ catch (IllegalArgumentException expected)
+ {
+ // expected
+ }
+
+ }
+
public void testReset()
{
CharBuffer buffer = new CharBuffer(0);
Show replies by date