コード例 #1
0
 public void testParseBadEnumDefinitionWithMissingColon() throws Exception {
   writeTestProto("enum Response {", "  YES = 0;", "  NO = 1", "};");
   ProtoEnumDefinition enumDef = getOnlyTopLevelEnumeration();
   assertNotNull(enumDef);
   assertNoError(enumDef.getConstants().get(0));
   assertError(enumDef.getConstants().get(1), "expected ';' or ','");
 }
コード例 #2
0
  public void testParseEnumsWithInvalidFieldOption() throws Exception {
    writeTestProto("enum Response {", "    YES = 0 [(foo)=];", "    NO = 1;", "}");

    ProtoEnumDefinition enumDef = getOnlyTopLevelEnumeration();
    ProtoEnumBody body = enumDef.getEnumBody();
    assertError((AbstractProtoElement) body.getChildren()[0], "expected custom option value");
  }
コード例 #3
0
 public void testParseEnumWithoutComma() throws Exception {
   writeTestProto("package foo;", "enum Foo {", "  Bar1 = 1", "  Bar2 = 2,", "}");
   assertPackageName(protoFile, "foo");
   ProtoEnumDefinition foo = getOnlyTopLevelEnumeration();
   List<ProtoEnumConstant> constVals = foo.getConstants();
   assertError(constVals.get(0), "expected ';' or ','");
 }
コード例 #4
0
 private void assertEnumEquals(String name, List<String> constants, ProtoEnumDefinition enumDef) {
   assertEquals(name, enumDef.getName());
   assertNotNull(enumDef.getEnumBody());
   assertAnyOrder(
       Iterables.transform(
           enumDef.getConstants(),
           new Function<ProtoEnumConstant, String>() {
             @Override
             public String apply(@Nullable ProtoEnumConstant protoEnumConstant) {
               return protoEnumConstant.getName();
             }
           }),
       constants);
 }
コード例 #5
0
 public void testParseBadEnumDefinitionWithMissingRBrace() throws Exception {
   writeTestProto("enum Response {", "  YES = 0;", "  NO = 1;");
   ProtoEnumDefinition enumDef = getOnlyTopLevelEnumeration();
   assertNotNull(enumDef);
   assertError(enumDef.getEnumBody(), "expected '}'");
 }