use of protos.TypicalData in project j2objc by google.
the class CompatibilityTest method testExtendableMessageOrBuilder.
public void testExtendableMessageOrBuilder() throws Exception {
TypicalData.Builder builder = TypicalData.newBuilder().setMyInt(42);
TypicalData data = builder.build();
Object o = builder;
ExtendableMessageOrBuilder emob = (ExtendableMessageOrBuilder) o;
o = data;
emob = (ExtendableMessageOrBuilder) o;
}
use of protos.TypicalData in project j2objc by google.
the class CompatibilityTest method testParseFromInvalidProtocolBufferException.
public void testParseFromInvalidProtocolBufferException() throws Exception {
try {
@SuppressWarnings("unused") TypicalData output = TypicalData.parseFrom(new byte[] { 0x08 });
fail("Expected InvalidProtocolBufferException to be thrown.");
} catch (InvalidProtocolBufferException e) {
// Expected
}
}
use of protos.TypicalData in project j2objc by google.
the class CompatibilityTest method testWriteDelimitedToOutputStream.
public void testWriteDelimitedToOutputStream() throws Exception {
TypicalData data = TypicalData.newBuilder().setMyInt(7).setMyBool(true).setMyString("foo").build();
ByteArrayOutputStream out = new ByteArrayOutputStream();
data.writeDelimitedTo(out);
byte[] bytes = out.toByteArray();
byte[] expected = new byte[] { 0x09, 0x08, 0x07, 0x60, 0x01, 0x7A, 0x03, 0x66, 0x6F, 0x6F };
checkBytes(expected, bytes);
}
use of protos.TypicalData in project j2objc by google.
the class CompatibilityTest method testSetAndGetRepeatedFloat.
public void testSetAndGetRepeatedFloat() throws Exception {
TypicalData data = TypicalData.newBuilder().addRepeatedFloat(0.5f).build();
assertEquals(1, data.getRepeatedFloatCount());
assertEquals(0.5f, data.getRepeatedFloat(0), 0.0001);
}
use of protos.TypicalData in project j2objc by google.
the class CompatibilityTest method testMessageLiteToBuilderAndMergeFrom.
public void testMessageLiteToBuilderAndMergeFrom() throws Exception {
TypicalData input = TypicalData.newBuilder().setMyInt(123).build();
MessageLite msg = TypicalData.getDefaultInstance();
// mergeFrom(byte[], ExtensionRegistryLite)
MessageLite.Builder builder = msg.toBuilder();
builder.mergeFrom(input.toByteString().toByteArray(), ExtensionRegistry.getEmptyRegistry());
assertEquals(123, ((TypicalData) builder.build()).getMyInt());
// mergeFrom(byte[])
builder = msg.toBuilder();
builder.mergeFrom(input.toByteString().toByteArray());
assertEquals(123, ((TypicalData) builder.build()).getMyInt());
// mergeFrom(ByteString, ExtensionRegistryLite)
builder = msg.toBuilder();
builder.mergeFrom(input.toByteString(), ExtensionRegistry.getEmptyRegistry());
assertEquals(123, ((TypicalData) builder.build()).getMyInt());
// mergeFrom(ByteString)
builder = msg.toBuilder();
builder.mergeFrom(input.toByteString());
assertEquals(123, ((TypicalData) builder.build()).getMyInt());
}
Aggregations