exercise all unicode for byte array stream write/readUTF to validate

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@908618 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2010-02-10 18:15:16 +00:00
parent 2b019ea627
commit 0701d7d0e6
1 changed files with 27 additions and 1 deletions

View File

@ -26,14 +26,40 @@ public class DataByteArrayInputStreamTest extends TestCase {
public void testNonAscii() throws Exception {
doMarshallUnMarshallValidation("meißen");
String accumulator = new String();
int test = 0; // int to get Supplementary chars
while(Character.isDefined(test)) {
doMarshallUnMarshallValidation(String.valueOf((char)test));
String toTest = String.valueOf((char)test);
accumulator += toTest;
doMarshallUnMarshallValidation(toTest);
test++;
}
int massiveThreeByteCharValue = 0x0FFF;
String toTest = String.valueOf((char)massiveThreeByteCharValue);
accumulator += toTest;
doMarshallUnMarshallValidation(String.valueOf((char)massiveThreeByteCharValue));
// Altogether
doMarshallUnMarshallValidation(accumulator);
// the three byte values
char t = '\u0800';
final char max = '\uffff';
accumulator = String.valueOf(t);
while (t < max) {
String val = String.valueOf(t);
accumulator += val;
doMarshallUnMarshallValidation(val);
t++;
}
// Altogether so long as it is not too big
while (accumulator.length() > 20000) {
accumulator = accumulator.substring(20000);
}
doMarshallUnMarshallValidation(accumulator);
}
void doMarshallUnMarshallValidation(String value) throws Exception {