runStringTest(1024 * 1026);
runStringTest(1024 * 1024 * 2);
}
public void runStringTest (int length) throws IOException {
Output write = new Output(1024, -1);
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < length; i++)
buffer.append((char)i);
String value = buffer.toString();
write.writeString(value);
write.writeString(value);
Input read = new Input(write.toBytes());
assertEquals(value, read.readString());
assertEquals(value, read.readStringBuilder().toString());
write.clear();
write.writeString(buffer);
write.writeString(buffer);
read = new Input(write.toBytes());
assertEquals(value, read.readStringBuilder().toString());
assertEquals(value, read.readString());
if (length <= 127) {
write.clear();
write.writeAscii(value);
write.writeAscii(value);
read = new Input(write.toBytes());
assertEquals(value, read.readStringBuilder().toString());
assertEquals(value, read.readString());
}
}