use of com.squareup.wire.protos.alltypes.AllTypes in project wire by square.
the class TestAllTypes method testReadStream.
@Test
public void testReadStream() throws IOException {
byte[] data = adapter.encode(allTypes);
InputStream stream = new ByteArrayInputStream(data);
AllTypes parsed = adapter.decode(stream);
assertThat(parsed).isEqualTo(allTypes);
assertThat(allTypes.ext_opt_bool).isEqualTo(Boolean.TRUE);
assertThat(allTypes.ext_rep_bool).isEqualTo(list(true));
assertThat(allTypes.ext_pack_bool).isEqualTo(list(true));
}
use of com.squareup.wire.protos.alltypes.AllTypes in project wire by square.
the class TestAllTypes method testHashCodes.
@Test
public void testHashCodes() {
AllTypes.Builder builder = getBuilder();
AllTypes message = builder.build();
int messageHashCode = message.hashCode();
assertThat(messageHashCode).isEqualTo(allTypes.hashCode());
}
use of com.squareup.wire.protos.alltypes.AllTypes in project wire by square.
the class TestAllTypes method testReadNoExtension.
@Test
public void testReadNoExtension() throws IOException {
byte[] data = adapter.encode(allTypes);
AllTypes parsed = AllTypes.ADAPTER.decode(data);
assertThat(allTypes).isEqualTo(parsed);
}
use of com.squareup.wire.protos.alltypes.AllTypes in project wire by square.
the class GsonTest method omitsUnknownFields.
@Test
public void omitsUnknownFields() {
AllTypes.Builder builder = createBuilder();
builder.addUnknownField(9000, FieldEncoding.FIXED32, 9000);
builder.addUnknownField(9001, FieldEncoding.FIXED64, 9001L);
builder.addUnknownField(9002, FieldEncoding.LENGTH_DELIMITED, ByteString.of((byte) '9', (byte) '0', (byte) '0', (byte) '2'));
builder.addUnknownField(9003, FieldEncoding.VARINT, 9003L);
AllTypes allTypes = builder.build();
String json = gson.toJson(allTypes);
assertThat(json).isEqualTo(JSON);
}
Aggregations