Java 类com.google.protobuf.UnittestLite 实例源码

项目:sstore-soft    文件:LiteTest.java   
public void testLiteExtensions() throws Exception {
  // TODO(kenton):  Unlike other features of the lite library, extensions are
  //   implemented completely differently from the regular library.  We
  //   should probably test them more thoroughly.

  TestAllExtensionsLite message =
    TestAllExtensionsLite.newBuilder()
      .setExtension(UnittestLite.optionalInt32ExtensionLite, 123)
      .addExtension(UnittestLite.repeatedStringExtensionLite, "hello")
      .setExtension(UnittestLite.optionalNestedEnumExtensionLite,
          TestAllTypesLite.NestedEnum.BAZ)
      .setExtension(UnittestLite.optionalNestedMessageExtensionLite,
          TestAllTypesLite.NestedMessage.newBuilder().setBb(7).build())
      .build();

  // Test copying a message, since coping extensions actually does use a
  // different code path between lite and regular libraries, and as of this
  // writing, parsing hasn't been implemented yet.
  TestAllExtensionsLite message2 = message.toBuilder().build();

  assertEquals(123, (int) message2.getExtension(
      UnittestLite.optionalInt32ExtensionLite));
  assertEquals(1, message2.getExtensionCount(
      UnittestLite.repeatedStringExtensionLite));
  assertEquals(1, message2.getExtension(
      UnittestLite.repeatedStringExtensionLite).size());
  assertEquals("hello", message2.getExtension(
      UnittestLite.repeatedStringExtensionLite, 0));
  assertEquals(TestAllTypesLite.NestedEnum.BAZ, message2.getExtension(
      UnittestLite.optionalNestedEnumExtensionLite));
  assertEquals(7, message2.getExtension(
      UnittestLite.optionalNestedMessageExtensionLite).getBb());
}
项目:sstore-soft    文件:GeneratedMessageTest.java   
public void testClearLiteExtension() throws Exception {
  // clearExtension() is not actually used in TestUtil, so try it manually.
  assertFalse(
    TestAllExtensionsLite.newBuilder()
      .setExtension(UnittestLite.optionalInt32ExtensionLite, 1)
      .clearExtension(UnittestLite.optionalInt32ExtensionLite)
      .hasExtension(UnittestLite.optionalInt32ExtensionLite));
  assertEquals(0,
    TestAllExtensionsLite.newBuilder()
      .addExtension(UnittestLite.repeatedInt32ExtensionLite, 1)
      .clearExtension(UnittestLite.repeatedInt32ExtensionLite)
      .getExtensionCount(UnittestLite.repeatedInt32ExtensionLite));
}
项目:sstore-soft    文件:GeneratedMessageTest.java   
public void testLiteExtensionMergeFrom() throws Exception {
  TestAllExtensionsLite original =
    TestAllExtensionsLite.newBuilder()
      .setExtension(UnittestLite.optionalInt32ExtensionLite, 1).build();
  TestAllExtensionsLite merged =
      TestAllExtensionsLite.newBuilder().mergeFrom(original).build();
  assertTrue(merged.hasExtension(UnittestLite.optionalInt32ExtensionLite));
  assertEquals(
      1, (int) merged.getExtension(UnittestLite.optionalInt32ExtensionLite));
}
项目:s-store    文件:LiteTest.java   
public void testLiteExtensions() throws Exception {
  // TODO(kenton):  Unlike other features of the lite library, extensions are
  //   implemented completely differently from the regular library.  We
  //   should probably test them more thoroughly.

  TestAllExtensionsLite message =
    TestAllExtensionsLite.newBuilder()
      .setExtension(UnittestLite.optionalInt32ExtensionLite, 123)
      .addExtension(UnittestLite.repeatedStringExtensionLite, "hello")
      .setExtension(UnittestLite.optionalNestedEnumExtensionLite,
          TestAllTypesLite.NestedEnum.BAZ)
      .setExtension(UnittestLite.optionalNestedMessageExtensionLite,
          TestAllTypesLite.NestedMessage.newBuilder().setBb(7).build())
      .build();

  // Test copying a message, since coping extensions actually does use a
  // different code path between lite and regular libraries, and as of this
  // writing, parsing hasn't been implemented yet.
  TestAllExtensionsLite message2 = message.toBuilder().build();

  assertEquals(123, (int) message2.getExtension(
      UnittestLite.optionalInt32ExtensionLite));
  assertEquals(1, message2.getExtensionCount(
      UnittestLite.repeatedStringExtensionLite));
  assertEquals(1, message2.getExtension(
      UnittestLite.repeatedStringExtensionLite).size());
  assertEquals("hello", message2.getExtension(
      UnittestLite.repeatedStringExtensionLite, 0));
  assertEquals(TestAllTypesLite.NestedEnum.BAZ, message2.getExtension(
      UnittestLite.optionalNestedEnumExtensionLite));
  assertEquals(7, message2.getExtension(
      UnittestLite.optionalNestedMessageExtensionLite).getBb());
}
项目:s-store    文件:GeneratedMessageTest.java   
public void testClearLiteExtension() throws Exception {
  // clearExtension() is not actually used in TestUtil, so try it manually.
  assertFalse(
    TestAllExtensionsLite.newBuilder()
      .setExtension(UnittestLite.optionalInt32ExtensionLite, 1)
      .clearExtension(UnittestLite.optionalInt32ExtensionLite)
      .hasExtension(UnittestLite.optionalInt32ExtensionLite));
  assertEquals(0,
    TestAllExtensionsLite.newBuilder()
      .addExtension(UnittestLite.repeatedInt32ExtensionLite, 1)
      .clearExtension(UnittestLite.repeatedInt32ExtensionLite)
      .getExtensionCount(UnittestLite.repeatedInt32ExtensionLite));
}
项目:s-store    文件:GeneratedMessageTest.java   
public void testLiteExtensionMergeFrom() throws Exception {
  TestAllExtensionsLite original =
    TestAllExtensionsLite.newBuilder()
      .setExtension(UnittestLite.optionalInt32ExtensionLite, 1).build();
  TestAllExtensionsLite merged =
      TestAllExtensionsLite.newBuilder().mergeFrom(original).build();
  assertTrue(merged.hasExtension(UnittestLite.optionalInt32ExtensionLite));
  assertEquals(
      1, (int) merged.getExtension(UnittestLite.optionalInt32ExtensionLite));
}
项目:vsminecraft    文件:LiteTest.java   
public void testLiteExtensions() throws Exception {
  // TODO(kenton):  Unlike other features of the lite library, extensions are
  //   implemented completely differently from the regular library.  We
  //   should probably test them more thoroughly.

  TestAllExtensionsLite message =
    TestAllExtensionsLite.newBuilder()
      .setExtension(UnittestLite.optionalInt32ExtensionLite, 123)
      .addExtension(UnittestLite.repeatedStringExtensionLite, "hello")
      .setExtension(UnittestLite.optionalNestedEnumExtensionLite,
          TestAllTypesLite.NestedEnum.BAZ)
      .setExtension(UnittestLite.optionalNestedMessageExtensionLite,
          TestAllTypesLite.NestedMessage.newBuilder().setBb(7).build())
      .build();

  // Test copying a message, since coping extensions actually does use a
  // different code path between lite and regular libraries, and as of this
  // writing, parsing hasn't been implemented yet.
  TestAllExtensionsLite message2 = message.toBuilder().build();

  assertEquals(123, (int) message2.getExtension(
      UnittestLite.optionalInt32ExtensionLite));
  assertEquals(1, message2.getExtensionCount(
      UnittestLite.repeatedStringExtensionLite));
  assertEquals(1, message2.getExtension(
      UnittestLite.repeatedStringExtensionLite).size());
  assertEquals("hello", message2.getExtension(
      UnittestLite.repeatedStringExtensionLite, 0));
  assertEquals(TestAllTypesLite.NestedEnum.BAZ, message2.getExtension(
      UnittestLite.optionalNestedEnumExtensionLite));
  assertEquals(7, message2.getExtension(
      UnittestLite.optionalNestedMessageExtensionLite).getBb());
}
项目:sstore-soft    文件:TestUtil.java   
public static void registerAllExtensionsLite(ExtensionRegistryLite registry) {
  UnittestLite.registerAllExtensions(registry);
}
项目:s-store    文件:TestUtil.java   
public static void registerAllExtensionsLite(ExtensionRegistryLite registry) {
  UnittestLite.registerAllExtensions(registry);
}
项目:vsminecraft    文件:TestUtil.java   
public static void registerAllExtensionsLite(ExtensionRegistryLite registry) {
  UnittestLite.registerAllExtensions(registry);
}
项目:protobuf-el    文件:TestUtil.java   
public static void registerAllExtensionsLite(ExtensionRegistryLite registry) {
  UnittestLite.registerAllExtensions(registry);
}