Search in sources :

Example 6 with AllTypes

use of com.squareup.wire.protos.alltypes.AllTypes in project wire by square.

the class GsonTest method deserializationOfAllTypes.

@Test
public void deserializationOfAllTypes() {
    AllTypes allTypes = createBuilder().build();
    AllTypes parsed = gson.fromJson(JSON, AllTypes.class);
    assertThat(parsed).isEqualTo(allTypes);
    assertThat(parsed.toString()).isEqualTo(allTypes.toString());
    assertThat(gson.toJson(parsed)).isEqualTo(gson.toJson(allTypes));
}
Also used : AllTypes(com.squareup.wire.protos.alltypes.AllTypes) Test(org.junit.Test)

Example 7 with AllTypes

use of com.squareup.wire.protos.alltypes.AllTypes in project wire by square.

the class GsonTest method serializationOfAllTypes.

@Test
public void serializationOfAllTypes() {
    AllTypes allTypes = createBuilder().build();
    String json = gson.toJson(allTypes);
    assertThat(json).isEqualTo(JSON);
}
Also used : AllTypes(com.squareup.wire.protos.alltypes.AllTypes) ByteString(okio.ByteString) Test(org.junit.Test)

Example 8 with AllTypes

use of com.squareup.wire.protos.alltypes.AllTypes in project wire by square.

the class TestAllTypes method testReadFromSlowSource.

@Test
public void testReadFromSlowSource() throws IOException {
    byte[] data = adapter.encode(allTypes);
    Source input = new SlowSource(new Buffer().write(data));
    AllTypes parsed = adapter.decode(Okio.buffer(input));
    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));
}
Also used : Buffer(okio.Buffer) AllTypes(com.squareup.wire.protos.alltypes.AllTypes) Source(okio.Source) ForwardingSource(okio.ForwardingSource) Test(org.junit.Test)

Example 9 with AllTypes

use of com.squareup.wire.protos.alltypes.AllTypes in project wire by square.

the class TestAllTypes method testReadLongMessages.

@Test
public void testReadLongMessages() throws IOException {
    AllTypes allTypes = createAllTypes(50);
    byte[] data = adapter.encode(allTypes);
    AllTypes parsed = adapter.decode(data);
    assertThat(parsed).isEqualTo(allTypes);
    assertThat(allTypes.ext_opt_bool).isEqualTo(Boolean.TRUE);
    assertThat(allTypes.ext_rep_bool).isEqualTo(list(true, 50));
    assertThat(allTypes.ext_pack_bool).isEqualTo(list(true, 50));
}
Also used : AllTypes(com.squareup.wire.protos.alltypes.AllTypes) Test(org.junit.Test)

Example 10 with AllTypes

use of com.squareup.wire.protos.alltypes.AllTypes in project wire by square.

the class TestAllTypes method testToString.

@Test
public void testToString() throws IOException {
    byte[] data = adapter.encode(allTypes);
    AllTypes parsed = adapter.decode(data);
    assertThat(parsed.toString()).isEqualTo(TestAllTypesData.expectedToString);
}
Also used : AllTypes(com.squareup.wire.protos.alltypes.AllTypes) Test(org.junit.Test)

Aggregations

AllTypes (com.squareup.wire.protos.alltypes.AllTypes)14 Test (org.junit.Test)14 Buffer (okio.Buffer)3 ByteString (okio.ByteString)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 ForwardingSource (okio.ForwardingSource)1 Source (okio.Source)1