Fix bugs for internal integration.

pull/2234/head
Bo Yang 8 years ago
parent cc8ca5b6a5
commit e3f0689d05
  1. 82
      conformance/conformance_test.cc
  2. 1
      conformance/conformance_test.h
  3. 6
      conformance/failure_list_cpp.txt
  4. 1
      src/Makefile.am

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

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

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

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

Loading…
Cancel
Save