Search in sources :

Example 6 with MapMsg

use of protos.MapMsg in project j2objc by google.

the class MapsTest method testEquals.

public void testEquals() throws Exception {
    MapMsg msg1 = getFilledMessage();
    MapMsg msg2 = getFilledMessage();
    MapMsg msg3 = getFilledMessage().toBuilder().putIntString(7, "seven").build();
    assertEquals(msg1, msg2);
    assertFalse(msg1.equals(msg3));
    assertFalse(msg3.equals(msg2));
    assertEquals(msg1.hashCode(), msg2.hashCode());
}
Also used : MapMsg(protos.MapMsg)

Example 7 with MapMsg

use of protos.MapMsg in project j2objc by google.

the class MapsTest method testGetOrDefault.

public void testGetOrDefault() throws Exception {
    MapMsg msg = getFilledMessage();
    assertEquals("five", msg.getIntStringOrDefault(5, "default"));
    assertEquals("six", msg.getIntStringOrDefault(6, "default"));
    assertEquals("default", msg.getIntStringOrDefault(7, "default"));
}
Also used : MapMsg(protos.MapMsg)

Example 8 with MapMsg

use of protos.MapMsg in project j2objc by google.

the class MapsTest method testIsInitialized.

public void testIsInitialized() throws Exception {
    MapMsg.Builder builder = MapMsg.newBuilder();
    // Check no exception.
    MapMsg unused = builder.build();
    builder.putStringMessage("foo", MapValue.newBuilder().buildPartial());
    try {
        builder.build();
        fail("Expected UninitializedMessageException");
    } catch (RuntimeException e) {
    // Expected.
    }
}
Also used : MapMsg(protos.MapMsg)

Example 9 with MapMsg

use of protos.MapMsg in project j2objc by google.

the class MapsTest method testContains.

public void testContains() throws Exception {
    MapMsg msg = getFilledMessage();
    assertTrue(msg.containsStringMessage("abc"));
    assertFalse(msg.containsStringMessage("ABC"));
    assertTrue(msg.containsIntMessage(5280));
    assertFalse(msg.containsIntMessage(5281));
}
Also used : MapMsg(protos.MapMsg)

Aggregations

MapMsg (protos.MapMsg)9 ExtensionRegistry (com.google.protobuf.ExtensionRegistry)2 AutoreleasePool (com.google.j2objc.annotations.AutoreleasePool)1 Descriptor (com.google.protobuf.Descriptors.Descriptor)1 FieldDescriptor (com.google.protobuf.Descriptors.FieldDescriptor)1 MapEntry (com.google.protobuf.MapEntry)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1