Search in sources :

Example 16 with TypicalData

use of protos.TypicalData in project j2objc by google.

the class CompatibilityTest method testSetAndGetRepeatedbBool.

public void testSetAndGetRepeatedbBool() throws Exception {
    TypicalData data = TypicalData.newBuilder().addRepeatedBool(true).build();
    assertEquals(1, data.getRepeatedBoolCount());
    assertTrue(data.getRepeatedBool(0));
}
Also used : TypicalData(protos.TypicalData)

Example 17 with TypicalData

use of protos.TypicalData in project j2objc by google.

the class CompatibilityTest method testSetAndGetRepeatedUint32.

public void testSetAndGetRepeatedUint32() throws Exception {
    TypicalData data = TypicalData.newBuilder().addRepeatedUint32(123).build();
    assertEquals(1, data.getRepeatedUint32Count());
    assertEquals(123, data.getRepeatedUint32(0));
}
Also used : TypicalData(protos.TypicalData)

Example 18 with TypicalData

use of protos.TypicalData in project j2objc by google.

the class CompatibilityTest method testMessageLiteInterface.

public void testMessageLiteInterface() throws Exception {
    ExtensionRegistryLite registry = ExtensionRegistryLite.newInstance();
    TypicalData data = TypicalData.newBuilder().build();
    MessageLite messageLite = data;
    MessageLite.Builder builderLite = messageLite.newBuilderForType();
    messageLite.writeTo(new ByteArrayOutputStream());
    messageLite.writeDelimitedTo(new ByteArrayOutputStream());
    builderLite.mergeFrom(new ByteArrayInputStream(new byte[0]));
    builderLite.mergeFrom(new ByteArrayInputStream(new byte[0]), registry);
    builderLite.mergeDelimitedFrom(new ByteArrayInputStream(new byte[0]));
    builderLite.mergeDelimitedFrom(new ByteArrayInputStream(new byte[0]), registry);
    assertEquals(0, messageLite.getSerializedSize());
}
Also used : TypicalData(protos.TypicalData) ByteArrayInputStream(java.io.ByteArrayInputStream) ExtensionRegistryLite(com.google.protobuf.ExtensionRegistryLite) ByteArrayOutputStream(java.io.ByteArrayOutputStream) MessageLite(com.google.protobuf.MessageLite)

Example 19 with TypicalData

use of protos.TypicalData in project j2objc by google.

the class CompatibilityTest method testParseDelimitedFromInvalidProtocolBufferException.

public void testParseDelimitedFromInvalidProtocolBufferException() throws Exception {
    try {
        ByteArrayInputStream in = new ByteArrayInputStream(new byte[] { 0x03, 0x01, 0x02 });
        @SuppressWarnings("unused") TypicalData output = TypicalData.parseDelimitedFrom(in);
        fail("Expected InvalidProtocolBufferException to be thrown.");
    } catch (InvalidProtocolBufferException e) {
    // Expected
    }
}
Also used : TypicalData(protos.TypicalData) ByteArrayInputStream(java.io.ByteArrayInputStream) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException)

Example 20 with TypicalData

use of protos.TypicalData in project j2objc by google.

the class CompatibilityTest method testMergeFromInvalidProtocolBufferException.

public void testMergeFromInvalidProtocolBufferException() throws Exception {
    try {
        ByteArrayInputStream in = new ByteArrayInputStream(new byte[] { 0x00 });
        @SuppressWarnings("unused") TypicalData output = TypicalData.newBuilder().mergeFrom(in, ExtensionRegistry.getEmptyRegistry()).build();
        fail("Expected InvalidProtocolBufferException to be thrown.");
    } catch (InvalidProtocolBufferException e) {
    // Expected
    }
}
Also used : TypicalData(protos.TypicalData) ByteArrayInputStream(java.io.ByteArrayInputStream) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException)

Aggregations

TypicalData (protos.TypicalData)39 ByteArrayInputStream (java.io.ByteArrayInputStream)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 TypicalDataMessage (protos.TypicalDataMessage)5 ByteString (com.google.protobuf.ByteString)3 FieldDescriptor (com.google.protobuf.Descriptors.FieldDescriptor)3 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)3 ArrayList (java.util.ArrayList)3 MessageLite (com.google.protobuf.MessageLite)2 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 Descriptor (com.google.protobuf.Descriptors.Descriptor)1 EnumDescriptor (com.google.protobuf.Descriptors.EnumDescriptor)1 EnumValueDescriptor (com.google.protobuf.Descriptors.EnumValueDescriptor)1 ExtensionRegistry (com.google.protobuf.ExtensionRegistry)1 ExtensionRegistryLite (com.google.protobuf.ExtensionRegistryLite)1 GeneratedMessage (com.google.protobuf.GeneratedMessage)1 ExtendableMessageOrBuilder (com.google.protobuf.GeneratedMessage.ExtendableMessageOrBuilder)1 Message (com.google.protobuf.Message)1 ProtocolMessageEnum (com.google.protobuf.ProtocolMessageEnum)1