Эх сурвалжийг харах

Fix bugs for internal integration.

Bo Yang 9 жил өмнө
parent
commit
e3f0689d05

+ 41 - 41
conformance/conformance_test.cc

@@ -286,14 +286,14 @@ void ConformanceTestSuite::RunValidInputTest(
 
 
   switch (response.result_case()) {
   switch (response.result_case()) {
     case ConformanceResponse::RESULT_NOT_SET:
     case ConformanceResponse::RESULT_NOT_SET:
-      ReportFailure(test_name, request, response,
+      ReportFailure(test_name, level, request, response,
                     "Response didn't have any field in the Response.");
                     "Response didn't have any field in the Response.");
       return;
       return;
 
 
     case ConformanceResponse::kParseError:
     case ConformanceResponse::kParseError:
     case ConformanceResponse::kRuntimeError:
     case ConformanceResponse::kRuntimeError:
     case ConformanceResponse::kSerializeError:
     case ConformanceResponse::kSerializeError:
-      ReportFailure(test_name, request, response,
+      ReportFailure(test_name, level, request, response,
                     "Failed to parse input or produce output.");
                     "Failed to parse input or produce output.");
       return;
       return;
 
 
@@ -423,12 +423,12 @@ void ConformanceTestSuite::RunValidJsonTestWithProtobufInput(
 }
 }
 
 
 void ConformanceTestSuite::RunValidProtobufTest(
 void ConformanceTestSuite::RunValidProtobufTest(
-    const string& test_name, const TestAllTypes& input,
+    const string& test_name, ConformanceLevel level, const TestAllTypes& input,
     const string& equivalent_text_format) {
     const string& equivalent_text_format) {
-  RunValidInputTest("ProtobufInput." + test_name + ".ProtobufOutput",
+  RunValidInputTest("ProtobufInput." + test_name + ".ProtobufOutput", level,
                     input.SerializeAsString(), conformance::PROTOBUF,
                     input.SerializeAsString(), conformance::PROTOBUF,
                     equivalent_text_format, conformance::PROTOBUF);
                     equivalent_text_format, conformance::PROTOBUF);
-  RunValidInputTest("ProtobufInput." + test_name + ".JsonOutput",
+  RunValidInputTest("ProtobufInput." + test_name + ".JsonOutput", level,
                     input.SerializeAsString(), conformance::PROTOBUF,
                     input.SerializeAsString(), conformance::PROTOBUF,
                     equivalent_text_format, conformance::JSON);
                     equivalent_text_format, conformance::JSON);
 }
 }
@@ -723,7 +723,7 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
         FIELD_name12: 12
         FIELD_name12: 12
       )");
       )");
   RunValidJsonTest(
   RunValidJsonTest(
-      "FieldNameWithDoubleUnderscores",
+      "FieldNameWithDoubleUnderscores", RECOMMENDED,
       R"({
       R"({
         "fieldName13": 13,
         "fieldName13": 13,
         "fieldName14": 14,
         "fieldName14": 14,
@@ -790,7 +790,7 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
       "fieldname1: 1");
       "fieldname1: 1");
   // String ends with escape character.
   // String ends with escape character.
   ExpectParseFailureForJson(
   ExpectParseFailureForJson(
-      "StringEndsWithEscapeChar",
+      "StringEndsWithEscapeChar", RECOMMENDED,
       "{\"optionalString\": \"abc\\");
       "{\"optionalString\": \"abc\\");
   // Field names must be quoted (or it's not valid JSON).
   // Field names must be quoted (or it's not valid JSON).
   ExpectParseFailureForJson(
   ExpectParseFailureForJson(
@@ -801,13 +801,13 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
       "TrailingCommaInAnObject", RECOMMENDED,
       "TrailingCommaInAnObject", RECOMMENDED,
       R"({"fieldname1":1,})");
       R"({"fieldname1":1,})");
   ExpectParseFailureForJson(
   ExpectParseFailureForJson(
-      "TrailingCommaInAnObjectWithSpace",
+      "TrailingCommaInAnObjectWithSpace", RECOMMENDED,
       R"({"fieldname1":1 ,})");
       R"({"fieldname1":1 ,})");
   ExpectParseFailureForJson(
   ExpectParseFailureForJson(
-      "TrailingCommaInAnObjectWithSpaceCommaSpace",
+      "TrailingCommaInAnObjectWithSpaceCommaSpace", RECOMMENDED,
       R"({"fieldname1":1 , })");
       R"({"fieldname1":1 , })");
   ExpectParseFailureForJson(
   ExpectParseFailureForJson(
-      "TrailingCommaInAnObjectWithNewlines",
+      "TrailingCommaInAnObjectWithNewlines", RECOMMENDED,
       R"({
       R"({
         "fieldname1":1,
         "fieldname1":1,
       })");
       })");
@@ -820,28 +820,28 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
       })");
       })");
   // JSON spec says whitespace doesn't matter, so try a few spacings to be sure.
   // JSON spec says whitespace doesn't matter, so try a few spacings to be sure.
   RunValidJsonTest(
   RunValidJsonTest(
-      "OneLineNoSpaces",
+      "OneLineNoSpaces", RECOMMENDED,
       "{\"optionalInt32\":1,\"optionalInt64\":2}",
       "{\"optionalInt32\":1,\"optionalInt64\":2}",
       R"(
       R"(
         optional_int32: 1
         optional_int32: 1
         optional_int64: 2
         optional_int64: 2
       )");
       )");
   RunValidJsonTest(
   RunValidJsonTest(
-      "OneLineWithSpaces",
+      "OneLineWithSpaces", RECOMMENDED,
       "{ \"optionalInt32\" : 1 , \"optionalInt64\" : 2 }",
       "{ \"optionalInt32\" : 1 , \"optionalInt64\" : 2 }",
       R"(
       R"(
         optional_int32: 1
         optional_int32: 1
         optional_int64: 2
         optional_int64: 2
       )");
       )");
   RunValidJsonTest(
   RunValidJsonTest(
-      "MultilineNoSpaces",
+      "MultilineNoSpaces", RECOMMENDED,
       "{\n\"optionalInt32\"\n:\n1\n,\n\"optionalInt64\"\n:\n2\n}",
       "{\n\"optionalInt32\"\n:\n1\n,\n\"optionalInt64\"\n:\n2\n}",
       R"(
       R"(
         optional_int32: 1
         optional_int32: 1
         optional_int64: 2
         optional_int64: 2
       )");
       )");
   RunValidJsonTest(
   RunValidJsonTest(
-      "MultilineWithSpaces",
+      "MultilineWithSpaces", RECOMMENDED,
       "{\n  \"optionalInt32\"  :  1\n  ,\n  \"optionalInt64\"  :  2\n}\n",
       "{\n  \"optionalInt32\"  :  1\n  ,\n  \"optionalInt64\"  :  2\n}\n",
       R"(
       R"(
         optional_int32: 1
         optional_int32: 1
@@ -849,10 +849,10 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
       )");
       )");
   // Missing comma between key/value pairs.
   // Missing comma between key/value pairs.
   ExpectParseFailureForJson(
   ExpectParseFailureForJson(
-      "MissingCommaOneLine",
+      "MissingCommaOneLine", RECOMMENDED,
       "{ \"optionalInt32\": 1 \"optionalInt64\": 2 }");
       "{ \"optionalInt32\": 1 \"optionalInt64\": 2 }");
   ExpectParseFailureForJson(
   ExpectParseFailureForJson(
-      "MissingCommaMultiline",
+      "MissingCommaMultiline", RECOMMENDED,
       "{\n  \"optionalInt32\": 1\n  \"optionalInt64\": 2\n}");
       "{\n  \"optionalInt32\": 1\n  \"optionalInt64\": 2\n}");
   // Duplicated field names are not allowed.
   // Duplicated field names are not allowed.
   ExpectParseFailureForJson(
   ExpectParseFailureForJson(
@@ -919,7 +919,7 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
             value.isMember("FIELDName12");
             value.isMember("FIELDName12");
       });
       });
   RunValidJsonTestWithValidator(
   RunValidJsonTestWithValidator(
-      "FieldNameWithDoubleUnderscores",
+      "FieldNameWithDoubleUnderscores", RECOMMENDED,
       R"({
       R"({
         "fieldName13": 13,
         "fieldName13": 13,
         "fieldName14": 14,
         "fieldName14": 14,
@@ -1375,58 +1375,58 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
     TestAllTypes message;
     TestAllTypes message;
     message.set_oneof_uint32(0);
     message.set_oneof_uint32(0);
     RunValidProtobufTest(
     RunValidProtobufTest(
-        "OneofZeroUint32", message, "oneof_uint32: 0");
+        "OneofZeroUint32", RECOMMENDED, message, "oneof_uint32: 0");
     message.mutable_oneof_nested_message()->set_a(0);
     message.mutable_oneof_nested_message()->set_a(0);
     RunValidProtobufTest(
     RunValidProtobufTest(
-        "OneofZeroMessage", message, "oneof_nested_message: {}");
+        "OneofZeroMessage", RECOMMENDED, message, "oneof_nested_message: {}");
     message.set_oneof_string("");
     message.set_oneof_string("");
     RunValidProtobufTest(
     RunValidProtobufTest(
-        "OneofZeroString", message, "oneof_string: \"\"");
+        "OneofZeroString", RECOMMENDED, message, "oneof_string: \"\"");
     message.set_oneof_bytes("");
     message.set_oneof_bytes("");
     RunValidProtobufTest(
     RunValidProtobufTest(
-        "OneofZeroBytes", message, "oneof_bytes: \"\"");
+        "OneofZeroBytes", RECOMMENDED, message, "oneof_bytes: \"\"");
     message.set_oneof_bool(false);
     message.set_oneof_bool(false);
     RunValidProtobufTest(
     RunValidProtobufTest(
-        "OneofZeroBool", message, "oneof_bool: false");
+        "OneofZeroBool", RECOMMENDED, message, "oneof_bool: false");
     message.set_oneof_uint64(0);
     message.set_oneof_uint64(0);
     RunValidProtobufTest(
     RunValidProtobufTest(
-        "OneofZeroUint64", message, "oneof_uint64: 0");
+        "OneofZeroUint64", RECOMMENDED, message, "oneof_uint64: 0");
     message.set_oneof_float(0.0f);
     message.set_oneof_float(0.0f);
     RunValidProtobufTest(
     RunValidProtobufTest(
-        "OneofZeroFloat", message, "oneof_float: 0");
+        "OneofZeroFloat", RECOMMENDED, message, "oneof_float: 0");
     message.set_oneof_double(0.0);
     message.set_oneof_double(0.0);
     RunValidProtobufTest(
     RunValidProtobufTest(
-        "OneofZeroDouble", message, "oneof_double: 0");
+        "OneofZeroDouble", RECOMMENDED, message, "oneof_double: 0");
     message.set_oneof_enum(TestAllTypes::FOO);
     message.set_oneof_enum(TestAllTypes::FOO);
     RunValidProtobufTest(
     RunValidProtobufTest(
-        "OneofZeroEnum", message, "oneof_enum: FOO");
+        "OneofZeroEnum", RECOMMENDED, message, "oneof_enum: FOO");
   }
   }
   RunValidJsonTest(
   RunValidJsonTest(
-      "OneofZeroUint32",
+      "OneofZeroUint32", RECOMMENDED,
       R"({"oneofUint32": 0})", "oneof_uint32: 0");
       R"({"oneofUint32": 0})", "oneof_uint32: 0");
   RunValidJsonTest(
   RunValidJsonTest(
-      "OneofZeroMessage",
+      "OneofZeroMessage", RECOMMENDED,
       R"({"oneofNestedMessage": {}})", "oneof_nested_message: {}");
       R"({"oneofNestedMessage": {}})", "oneof_nested_message: {}");
   RunValidJsonTest(
   RunValidJsonTest(
-      "OneofZeroString",
+      "OneofZeroString", RECOMMENDED,
       R"({"oneofString": ""})", "oneof_string: \"\"");
       R"({"oneofString": ""})", "oneof_string: \"\"");
   RunValidJsonTest(
   RunValidJsonTest(
-      "OneofZeroBytes",
+      "OneofZeroBytes", RECOMMENDED,
       R"({"oneofBytes": ""})", "oneof_bytes: \"\"");
       R"({"oneofBytes": ""})", "oneof_bytes: \"\"");
   RunValidJsonTest(
   RunValidJsonTest(
-      "OneofZeroBool",
+      "OneofZeroBool", RECOMMENDED,
       R"({"oneofBool": false})", "oneof_bool: false");
       R"({"oneofBool": false})", "oneof_bool: false");
   RunValidJsonTest(
   RunValidJsonTest(
-      "OneofZeroUint64",
+      "OneofZeroUint64", RECOMMENDED,
       R"({"oneofUint64": 0})", "oneof_uint64: 0");
       R"({"oneofUint64": 0})", "oneof_uint64: 0");
   RunValidJsonTest(
   RunValidJsonTest(
-      "OneofZeroFloat",
+      "OneofZeroFloat", RECOMMENDED,
       R"({"oneofFloat": 0.0})", "oneof_float: 0");
       R"({"oneofFloat": 0.0})", "oneof_float: 0");
   RunValidJsonTest(
   RunValidJsonTest(
-      "OneofZeroDouble",
+      "OneofZeroDouble", RECOMMENDED,
       R"({"oneofDouble": 0.0})", "oneof_double: 0");
       R"({"oneofDouble": 0.0})", "oneof_double: 0");
   RunValidJsonTest(
   RunValidJsonTest(
-      "OneofZeroEnum",
+      "OneofZeroEnum", RECOMMENDED,
       R"({"oneofEnum":"FOO"})", "oneof_enum: FOO");
       R"({"oneofEnum":"FOO"})", "oneof_enum: FOO");
 
 
   // Repeated fields.
   // Repeated fields.
@@ -1485,13 +1485,13 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
       "RepeatedFieldTrailingComma", RECOMMENDED,
       "RepeatedFieldTrailingComma", RECOMMENDED,
       R"({"repeatedInt32": [1, 2, 3, 4,]})");
       R"({"repeatedInt32": [1, 2, 3, 4,]})");
   ExpectParseFailureForJson(
   ExpectParseFailureForJson(
-      "RepeatedFieldTrailingCommaWithSpace",
+      "RepeatedFieldTrailingCommaWithSpace", RECOMMENDED,
       "{\"repeatedInt32\": [1, 2, 3, 4 ,]}");
       "{\"repeatedInt32\": [1, 2, 3, 4 ,]}");
   ExpectParseFailureForJson(
   ExpectParseFailureForJson(
-      "RepeatedFieldTrailingCommaWithSpaceCommaSpace",
+      "RepeatedFieldTrailingCommaWithSpaceCommaSpace", RECOMMENDED,
       "{\"repeatedInt32\": [1, 2, 3, 4 , ]}");
       "{\"repeatedInt32\": [1, 2, 3, 4 , ]}");
   ExpectParseFailureForJson(
   ExpectParseFailureForJson(
-      "RepeatedFieldTrailingCommaWithNewlines",
+      "RepeatedFieldTrailingCommaWithNewlines", RECOMMENDED,
       "{\"repeatedInt32\": [\n  1,\n  2,\n  3,\n  4,\n]}");
       "{\"repeatedInt32\": [\n  1,\n  2,\n  3,\n  4,\n]}");
 
 
   // Map fields.
   // Map fields.
@@ -1614,13 +1614,13 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
   // http://www.rfc-editor.org/rfc/rfc7159.txt says strings have to use double
   // http://www.rfc-editor.org/rfc/rfc7159.txt says strings have to use double
   // quotes.
   // quotes.
   ExpectParseFailureForJson(
   ExpectParseFailureForJson(
-      "StringFieldSingleQuoteKey",
+      "StringFieldSingleQuoteKey", RECOMMENDED,
       R"({'optionalString': "Hello world!"})");
       R"({'optionalString': "Hello world!"})");
   ExpectParseFailureForJson(
   ExpectParseFailureForJson(
-      "StringFieldSingleQuoteValue",
+      "StringFieldSingleQuoteValue", RECOMMENDED,
       R"({"optionalString": 'Hello world!'})");
       R"({"optionalString": 'Hello world!'})");
   ExpectParseFailureForJson(
   ExpectParseFailureForJson(
-      "StringFieldSingleQuoteBoth",
+      "StringFieldSingleQuoteBoth", RECOMMENDED,
       R"({'optionalString': 'Hello world!'})");
       R"({'optionalString': 'Hello world!'})");
 
 
   // Wrapper types.
   // Wrapper types.

+ 1 - 0
conformance/conformance_test.h

@@ -170,6 +170,7 @@ class ConformanceTestSuite {
                                          const conformance::TestAllTypes& input,
                                          const conformance::TestAllTypes& input,
                                          const string& equivalent_text_format);
                                          const string& equivalent_text_format);
   void RunValidProtobufTest(const string& test_name,
   void RunValidProtobufTest(const string& test_name,
+                            ConformanceLevel level,
                             const conformance::TestAllTypes& input,
                             const conformance::TestAllTypes& input,
                             const string& equivalent_text_format);
                             const string& equivalent_text_format);
 
 

+ 6 - 0
conformance/failure_list_cpp.txt

@@ -17,6 +17,9 @@ Recommended.JsonInput.FieldNameDuplicate
 Recommended.JsonInput.FieldNameDuplicateDifferentCasing1
 Recommended.JsonInput.FieldNameDuplicateDifferentCasing1
 Recommended.JsonInput.FieldNameDuplicateDifferentCasing2
 Recommended.JsonInput.FieldNameDuplicateDifferentCasing2
 Recommended.JsonInput.FieldNameNotQuoted
 Recommended.JsonInput.FieldNameNotQuoted
+Recommended.JsonInput.FieldNameWithDoubleUnderscores.JsonOutput
+Recommended.JsonInput.FieldNameWithDoubleUnderscores.ProtobufOutput
+Recommended.JsonInput.FieldNameWithDoubleUnderscores.Validator
 Recommended.JsonInput.MapFieldValueIsNull
 Recommended.JsonInput.MapFieldValueIsNull
 Recommended.JsonInput.RepeatedFieldMessageElementIsNull
 Recommended.JsonInput.RepeatedFieldMessageElementIsNull
 Recommended.JsonInput.RepeatedFieldPrimitiveElementIsNull
 Recommended.JsonInput.RepeatedFieldPrimitiveElementIsNull
@@ -33,6 +36,9 @@ Recommended.JsonInput.TrailingCommaInAnObjectWithNewlines
 Recommended.JsonInput.TrailingCommaInAnObjectWithSpace
 Recommended.JsonInput.TrailingCommaInAnObjectWithSpace
 Recommended.JsonInput.TrailingCommaInAnObjectWithSpaceCommaSpace
 Recommended.JsonInput.TrailingCommaInAnObjectWithSpaceCommaSpace
 Required.JsonInput.DoubleFieldTooSmall
 Required.JsonInput.DoubleFieldTooSmall
+Required.JsonInput.FieldNameInLowerCamelCase.Validator
+Required.JsonInput.FieldNameInSnakeCase.JsonOutput
+Required.JsonInput.FieldNameInSnakeCase.ProtobufOutput
 Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.MESSAGE
 Required.ProtobufInput.PrematureEofBeforeKnownRepeatedValue.MESSAGE
 Required.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
 Required.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
 Required.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
 Required.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE

+ 1 - 0
src/Makefile.am

@@ -115,6 +115,7 @@ nobase_include_HEADERS =                                        \
   google/protobuf/generated_enum_util.h                         \
   google/protobuf/generated_enum_util.h                         \
   google/protobuf/generated_message_reflection.h                \
   google/protobuf/generated_message_reflection.h                \
   google/protobuf/generated_message_util.h                      \
   google/protobuf/generated_message_util.h                      \
+  google/protobuf/has_bits.h                                    \
   google/protobuf/map_entry.h                                   \
   google/protobuf/map_entry.h                                   \
   google/protobuf/map_entry_lite.h                              \
   google/protobuf/map_entry_lite.h                              \
   google/protobuf/map_field.h                                   \
   google/protobuf/map_field.h                                   \