use of protos.PrimitiveFields in project j2objc by google.
the class PrimitivesTest method checkIntValue.
private void checkIntValue(int value, int[] expectedBytesAsInts) throws Exception {
byte[] expectedBytes = asBytes(expectedBytesAsInts);
PrimitiveFields msg = PrimitiveFields.newBuilder().setInt32F(value).setUint32F(value).setSint32F(value).setFixed32F(value).setSfixed32F(value).setExtension(Primitives.int32Fe, value).setExtension(Primitives.uint32Fe, value).setExtension(Primitives.sint32Fe, value).setExtension(Primitives.fixed32Fe, value).setExtension(Primitives.sfixed32Fe, value).build();
checkBytes(expectedBytes, msg.toByteArray());
PrimitiveFields parsedMsg = PrimitiveFields.parseFrom(expectedBytes);
assertEquals(value, parsedMsg.getInt32F());
assertEquals(value, parsedMsg.getUint32F());
assertEquals(value, parsedMsg.getSint32F());
assertEquals(value, parsedMsg.getFixed32F());
assertEquals(value, parsedMsg.getSfixed32F());
}
use of protos.PrimitiveFields in project j2objc by google.
the class PrimitivesTest method testMergeFromOtherMessage.
public void testMergeFromOtherMessage() throws Exception {
PrimitiveFields filledMsg = getFilledMessage();
PrimitiveFields.Builder builder = PrimitiveFields.newBuilder();
builder.mergeFrom(filledMsg);
PrimitiveFields msg = builder.build();
checkFields(builder);
checkFields(msg);
}
use of protos.PrimitiveFields in project j2objc by google.
the class PrimitivesTest method testSerialization.
public void testSerialization() throws Exception {
PrimitiveFields msg = getFilledMessage();
assertEquals(695, msg.getSerializedSize());
byte[] bytes1 = msg.toByteArray();
checkBytes(ALL_PRIMITIVES_BYTES, bytes1);
ByteArrayOutputStream out = new ByteArrayOutputStream();
msg.writeTo(out);
byte[] bytes2 = out.toByteArray();
checkBytes(ALL_PRIMITIVES_BYTES, bytes2);
}
use of protos.PrimitiveFields in project j2objc by google.
the class PrimitivesTest method checkLongValue.
private void checkLongValue(long value, int[] expectedBytesAsInts) throws Exception {
byte[] expectedBytes = asBytes(expectedBytesAsInts);
PrimitiveFields msg = PrimitiveFields.newBuilder().setInt64F(value).setUint64F(value).setSint64F(value).setFixed64F(value).setSfixed64F(value).setExtension(Primitives.int64Fe, value).setExtension(Primitives.uint64Fe, value).setExtension(Primitives.sint64Fe, value).setExtension(Primitives.fixed64Fe, value).setExtension(Primitives.sfixed64Fe, value).build();
checkBytes(expectedBytes, msg.toByteArray());
PrimitiveFields parsedMsg = PrimitiveFields.parseFrom(expectedBytes);
assertEquals(value, parsedMsg.getInt64F());
assertEquals(value, parsedMsg.getUint64F());
assertEquals(value, parsedMsg.getSint64F());
assertEquals(value, parsedMsg.getFixed64F());
assertEquals(value, parsedMsg.getSfixed64F());
}
use of protos.PrimitiveFields in project j2objc by google.
the class PrimitivesTest method testMergeFromInputStream.
public void testMergeFromInputStream() throws Exception {
ExtensionRegistry registry = ExtensionRegistry.newInstance();
Primitives.registerAllExtensions(registry);
ByteArrayInputStream in = new ByteArrayInputStream(ALL_PRIMITIVES_BYTES);
PrimitiveFields.Builder builder = PrimitiveFields.newBuilder().mergeFrom(in, registry);
PrimitiveFields msg = builder.build();
checkFields(builder);
checkFields(msg);
}
Aggregations