use of protos.StringMsg in project j2objc by google.
the class StringsTest method testReallyLongNonAsciiString.
public void testReallyLongNonAsciiString() throws Exception {
char[] chars = new char[10000];
Arrays.fill(chars, '﷽');
String str = new String(chars);
StringMsg msg = StringMsg.newBuilder().setNonAsciiF(str).build();
ByteArrayOutputStream out = new ByteArrayOutputStream();
msg.writeTo(out);
byte[] bytes = out.toByteArray();
assertEquals(30004, bytes.length);
for (int i = 4; i < 30004; ) {
assertEquals((byte) 0xef, bytes[i++]);
assertEquals((byte) 0xb7, bytes[i++]);
assertEquals((byte) 0xbd, bytes[i++]);
}
ByteArrayInputStream in = new ByteArrayInputStream(bytes);
StringMsg msg2 = StringMsg.parseFrom(in);
assertEquals(str, msg2.getNonAsciiF());
}
use of protos.StringMsg in project j2objc by google.
the class StringsTest method testReallyLongString.
public void testReallyLongString() throws Exception {
char[] chars = new char[10000];
Arrays.fill(chars, 'a');
String str = new String(chars);
StringMsg msg = StringMsg.newBuilder().setAsciiF(str).build();
ByteArrayOutputStream out = new ByteArrayOutputStream();
msg.writeTo(out);
byte[] bytes = out.toByteArray();
assertEquals(10003, bytes.length);
for (int i = 3; i < 10003; i++) {
assertEquals('a', bytes[i]);
}
ByteArrayInputStream in = new ByteArrayInputStream(bytes);
StringMsg msg2 = StringMsg.parseFrom(in);
assertEquals(str, msg2.getAsciiF());
}
Aggregations