use of protos.StringMsg in project j2objc by google.
the class StringsTest method testSerialization.
public void testSerialization() throws Exception {
StringMsg msg = getFilledMessage();
assertEquals(171, msg.getSerializedSize());
byte[] bytes1 = msg.toByteArray();
checkBytes(ALL_STRINGS_BYTES, bytes1);
ByteArrayOutputStream out = new ByteArrayOutputStream();
msg.writeTo(out);
byte[] bytes2 = out.toByteArray();
checkBytes(ALL_STRINGS_BYTES, bytes2);
}
use of protos.StringMsg in project j2objc by google.
the class StringsTest method testMergeFromOtherMessage.
public void testMergeFromOtherMessage() throws Exception {
StringMsg filledMsg = getFilledMessage();
StringMsg.Builder builder = StringMsg.newBuilder();
builder.mergeFrom(filledMsg);
StringMsg msg = builder.build();
checkFields(builder);
checkFields(msg);
}
use of protos.StringMsg in project j2objc by google.
the class StringsTest method testParseFromByteArray.
public void testParseFromByteArray() throws Exception {
ExtensionRegistry registry = ExtensionRegistry.newInstance();
StringFields.registerAllExtensions(registry);
StringMsg msg = StringMsg.parseFrom(ALL_STRINGS_BYTES, registry);
checkFields(msg);
}
use of protos.StringMsg in project j2objc by google.
the class StringsTest method testMergeFromInputStream.
public void testMergeFromInputStream() throws Exception {
ExtensionRegistry registry = ExtensionRegistry.newInstance();
StringFields.registerAllExtensions(registry);
ByteArrayInputStream in = new ByteArrayInputStream(ALL_STRINGS_BYTES);
StringMsg.Builder builder = StringMsg.newBuilder().mergeFrom(in, registry);
StringMsg msg = builder.build();
checkFields(builder);
checkFields(msg);
}
use of protos.StringMsg in project j2objc by google.
the class StringsTest method testDefaultValue.
public void testDefaultValue() throws Exception {
StringMsg msg = StringMsg.newBuilder().build();
assertEquals("", msg.getEmptyF());
assertEquals("abc", msg.getDefaultStringF());
assertEquals("", new String(msg.getBytesF().toByteArray()));
assertEquals("def", new String(msg.getDefaultBytesF().toByteArray()));
assertEquals("", msg.getExtension(StringFields.emptyFe));
assertEquals("ghi", msg.getExtension(StringFields.defaultStringFe));
assertEquals("", new String(msg.getExtension(StringFields.bytesFe).toByteArray()));
assertEquals("jkl", new String(msg.getExtension(StringFields.defaultBytesFe).toByteArray()));
}
Aggregations