Search in sources :

Example 1 with OneField

use of com.squareup.wire.protos.edgecases.OneField in project wire by square.

the class ParseTest method typeMismatchHonorsWireDeclaredType.

@Ignore("TODO(jwilson)")
@Test
public void typeMismatchHonorsWireDeclaredType() throws Exception {
    // tag 1 / 3-byte length-delimited string: 0x109506
    // (0x109506 is a well-formed proto message that sets tag 2 to 456).
    ByteString data = ByteString.decodeHex("0a03109506");
    OneField oneField = OneField.ADAPTER.decode(data.toByteArray());
    assertThat(oneField).isEqualTo(new OneField.Builder().opt_int32(3).build());
}
Also used : ByteString(okio.ByteString) OneField(com.squareup.wire.protos.edgecases.OneField) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with OneField

use of com.squareup.wire.protos.edgecases.OneField in project wire by square.

the class ParseTest method unknownTagIgnored.

@Test
public void unknownTagIgnored() throws Exception {
    // tag 1 / type 0: 456
    // tag 2 / type 0: 789
    ByteString data = ByteString.decodeHex("08c803109506");
    OneField oneField = OneField.ADAPTER.decode(data.toByteArray());
    OneField expected = new OneField.Builder().opt_int32(456).build();
    assertThat(oneField).isNotEqualTo(expected);
    assertThat(oneField.withoutUnknownFields()).isEqualTo(expected);
}
Also used : ByteString(okio.ByteString) OneField(com.squareup.wire.protos.edgecases.OneField) Test(org.junit.Test)

Example 3 with OneField

use of com.squareup.wire.protos.edgecases.OneField in project wire by square.

the class ParseTest method lastValueWinsForRepeatedValueOfNonrepeatedField.

@Test
public void lastValueWinsForRepeatedValueOfNonrepeatedField() throws Exception {
    // tag 1 / type 0: 456
    // tag 1 / type 0: 789
    ByteString data = ByteString.decodeHex("08c803089506");
    OneField oneField = OneField.ADAPTER.decode(data.toByteArray());
    assertThat(new OneField.Builder().opt_int32(789).build()).isEqualTo(oneField);
}
Also used : ByteString(okio.ByteString) OneField(com.squareup.wire.protos.edgecases.OneField) Test(org.junit.Test)

Aggregations

OneField (com.squareup.wire.protos.edgecases.OneField)3 ByteString (okio.ByteString)3 Test (org.junit.Test)3 Ignore (org.junit.Ignore)1