diff options
Diffstat (limited to 'conformance')
-rw-r--r-- | conformance/Makefile.am | 92 | ||||
-rw-r--r-- | conformance/conformance.proto | 12 | ||||
-rwxr-xr-x | conformance/conformance_ruby.rb | 2 | ||||
-rw-r--r-- | conformance/conformance_test.cc | 230 | ||||
-rw-r--r-- | conformance/conformance_test.h | 3 | ||||
-rw-r--r-- | conformance/failure_list_cpp.txt | 12 | ||||
-rw-r--r-- | conformance/failure_list_csharp.txt | 7 | ||||
-rw-r--r-- | conformance/failure_list_java.txt | 8 | ||||
-rw-r--r-- | conformance/failure_list_objc.txt | 6 | ||||
-rw-r--r-- | conformance/failure_list_python.txt | 5 | ||||
-rw-r--r-- | conformance/failure_list_python_cpp.txt | 5 | ||||
-rw-r--r-- | conformance/failure_list_ruby.txt | 14 |
12 files changed, 321 insertions, 75 deletions
diff --git a/conformance/Makefile.am b/conformance/Makefile.am index 5538cc75..28ac3c8a 100644 --- a/conformance/Makefile.am +++ b/conformance/Makefile.am @@ -20,7 +20,7 @@ other_language_protoc_outputs = \ conformance_pb2.py \ Conformance.pbobjc.h \ Conformance.pbobjc.m \ - conformance.rb \ + conformance_pb.rb \ com/google/protobuf/Any.java \ com/google/protobuf/AnyOrBuilder.java \ com/google/protobuf/AnyProto.java \ @@ -84,47 +84,47 @@ other_language_protoc_outputs = \ google/protobuf/wrappers.pb.cc \ google/protobuf/wrappers.pb.h \ google/protobuf/wrappers.rb \ - google/protobuf/wrappers_pb2.py \ - lite/com/google/protobuf/Any.java \ - lite/com/google/protobuf/AnyOrBuilder.java \ - lite/com/google/protobuf/AnyProto.java \ - lite/com/google/protobuf/BoolValue.java \ - lite/com/google/protobuf/BoolValueOrBuilder.java \ - lite/com/google/protobuf/BytesValue.java \ - lite/com/google/protobuf/BytesValueOrBuilder.java \ - lite/com/google/protobuf/conformance/Conformance.java \ - lite/com/google/protobuf/DoubleValue.java \ - lite/com/google/protobuf/DoubleValueOrBuilder.java \ - lite/com/google/protobuf/Duration.java \ - lite/com/google/protobuf/DurationOrBuilder.java \ - lite/com/google/protobuf/DurationProto.java \ - lite/com/google/protobuf/FieldMask.java \ - lite/com/google/protobuf/FieldMaskOrBuilder.java \ - lite/com/google/protobuf/FieldMaskProto.java \ - lite/com/google/protobuf/FloatValue.java \ - lite/com/google/protobuf/FloatValueOrBuilder.java \ - lite/com/google/protobuf/Int32Value.java \ - lite/com/google/protobuf/Int32ValueOrBuilder.java \ - lite/com/google/protobuf/Int64Value.java \ - lite/com/google/protobuf/Int64ValueOrBuilder.java \ - lite/com/google/protobuf/ListValue.java \ - lite/com/google/protobuf/ListValueOrBuilder.java \ - lite/com/google/protobuf/NullValue.java \ - lite/com/google/protobuf/StringValue.java \ - lite/com/google/protobuf/StringValueOrBuilder.java \ - lite/com/google/protobuf/Struct.java \ - lite/com/google/protobuf/StructOrBuilder.java \ - lite/com/google/protobuf/StructProto.java \ - lite/com/google/protobuf/Timestamp.java \ - lite/com/google/protobuf/TimestampOrBuilder.java \ - lite/com/google/protobuf/TimestampProto.java \ - lite/com/google/protobuf/UInt32Value.java \ - lite/com/google/protobuf/UInt32ValueOrBuilder.java \ - lite/com/google/protobuf/UInt64Value.java \ - lite/com/google/protobuf/UInt64ValueOrBuilder.java \ - lite/com/google/protobuf/Value.java \ - lite/com/google/protobuf/ValueOrBuilder.java \ - lite/com/google/protobuf/WrappersProto.java + google/protobuf/wrappers_pb2.py + # lite/com/google/protobuf/Any.java \ + # lite/com/google/protobuf/AnyOrBuilder.java \ + # lite/com/google/protobuf/AnyProto.java \ + # lite/com/google/protobuf/BoolValue.java \ + # lite/com/google/protobuf/BoolValueOrBuilder.java \ + # lite/com/google/protobuf/BytesValue.java \ + # lite/com/google/protobuf/BytesValueOrBuilder.java \ + # lite/com/google/protobuf/conformance/Conformance.java \ + # lite/com/google/protobuf/DoubleValue.java \ + # lite/com/google/protobuf/DoubleValueOrBuilder.java \ + # lite/com/google/protobuf/Duration.java \ + # lite/com/google/protobuf/DurationOrBuilder.java \ + # lite/com/google/protobuf/DurationProto.java \ + # lite/com/google/protobuf/FieldMask.java \ + # lite/com/google/protobuf/FieldMaskOrBuilder.java \ + # lite/com/google/protobuf/FieldMaskProto.java \ + # lite/com/google/protobuf/FloatValue.java \ + # lite/com/google/protobuf/FloatValueOrBuilder.java \ + # lite/com/google/protobuf/Int32Value.java \ + # lite/com/google/protobuf/Int32ValueOrBuilder.java \ + # lite/com/google/protobuf/Int64Value.java \ + # lite/com/google/protobuf/Int64ValueOrBuilder.java \ + # lite/com/google/protobuf/ListValue.java \ + # lite/com/google/protobuf/ListValueOrBuilder.java \ + # lite/com/google/protobuf/NullValue.java \ + # lite/com/google/protobuf/StringValue.java \ + # lite/com/google/protobuf/StringValueOrBuilder.java \ + # lite/com/google/protobuf/Struct.java \ + # lite/com/google/protobuf/StructOrBuilder.java \ + # lite/com/google/protobuf/StructProto.java \ + # lite/com/google/protobuf/Timestamp.java \ + # lite/com/google/protobuf/TimestampOrBuilder.java \ + # lite/com/google/protobuf/TimestampProto.java \ + # lite/com/google/protobuf/UInt32Value.java \ + # lite/com/google/protobuf/UInt32ValueOrBuilder.java \ + # lite/com/google/protobuf/UInt64Value.java \ + # lite/com/google/protobuf/UInt64ValueOrBuilder.java \ + # lite/com/google/protobuf/Value.java \ + # lite/com/google/protobuf/ValueOrBuilder.java \ + # lite/com/google/protobuf/WrappersProto.java bin_PROGRAMS = conformance-test-runner conformance-cpp @@ -192,7 +192,7 @@ if USE_EXTERNAL_PROTOC protoc_middleman: $(conformance_protoc_inputs) $(well_known_type_protoc_inputs) $(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --objc_out=. --python_out=. $(conformance_protoc_inputs) $(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --python_out=. $(well_known_type_protoc_inputs) - $(PROTOC) -I$(srcdir) -I$(top_srcdir) --java_out=lite:lite $(conformance_protoc_inputs) $(well_known_type_protoc_inputs) + ## $(PROTOC) -I$(srcdir) -I$(top_srcdir) --java_out=lite:lite $(conformance_protoc_inputs) $(well_known_type_protoc_inputs) touch protoc_middleman else @@ -203,8 +203,8 @@ else protoc_middleman: $(top_srcdir)/src/protoc$(EXEEXT) $(conformance_protoc_inputs) $(well_known_type_protoc_inputs) oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --objc_out=$$oldpwd --python_out=$$oldpwd $(conformance_protoc_inputs) ) oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --python_out=$$oldpwd $(well_known_type_protoc_inputs) ) - @mkdir -p lite - oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --java_out=lite:$$oldpwd/lite $(conformance_protoc_inputs) $(well_known_type_protoc_inputs) ) + ## @mkdir -p lite + ## oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --java_out=lite:$$oldpwd/lite $(conformance_protoc_inputs) $(well_known_type_protoc_inputs) ) touch protoc_middleman endif @@ -246,7 +246,7 @@ conformance-java-lite: javac_middleman_lite conformance-csharp: $(other_language_protoc_outputs) @echo "Writing shortcut script conformance-csharp..." @echo '#! /bin/sh' > conformance-csharp - @echo 'mono ../csharp/src/Google.Protobuf.Conformance/bin/Release/Google.Protobuf.Conformance.exe "$$@"' >> conformance-csharp + @echo 'dotnet ../csharp/src/Google.Protobuf.Conformance/bin/Release/netcoreapp1.0/Google.Protobuf.Conformance.dll "$$@"' >> conformance-csharp @chmod +x conformance-csharp # Targets for actually running tests. diff --git a/conformance/conformance.proto b/conformance/conformance.proto index fc96074a..95a8fd13 100644 --- a/conformance/conformance.proto +++ b/conformance/conformance.proto @@ -210,6 +210,11 @@ message TestAllTypes { NestedMessage oneof_nested_message = 112; string oneof_string = 113; bytes oneof_bytes = 114; + bool oneof_bool = 115; + uint64 oneof_uint64 = 116; + float oneof_float = 117; + double oneof_double = 118; + NestedEnum oneof_enum = 119; } // Well-known types @@ -248,6 +253,7 @@ message TestAllTypes { repeated google.protobuf.Value repeated_value = 316; // Test field-name-to-JSON-name convention. + // (protobuf says names can be any valid C/C++ identifier.) int32 fieldname1 = 401; int32 field_name2 = 402; int32 _field_name3 = 403; @@ -260,6 +266,12 @@ message TestAllTypes { int32 Field_Name10 = 410; int32 FIELD_NAME11 = 411; int32 FIELD_name12 = 412; + int32 __field_name13 = 413; + int32 __Field_name14 = 414; + int32 field__name15 = 415; + int32 field__Name16 = 416; + int32 field_name17__ = 417; + int32 Field_name18__ = 418; } message ForeignMessage { diff --git a/conformance/conformance_ruby.rb b/conformance/conformance_ruby.rb index c716facd..aa572144 100755 --- a/conformance/conformance_ruby.rb +++ b/conformance/conformance_ruby.rb @@ -30,7 +30,7 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -require 'conformance' +require 'conformance_pb' $test_count = 0 $verbose = false diff --git a/conformance/conformance_test.cc b/conformance/conformance_test.cc index 59a61e51..fb963f68 100644 --- a/conformance/conformance_test.cc +++ b/conformance/conformance_test.cc @@ -272,11 +272,16 @@ void ConformanceTestSuite::RunValidInputTest( TestAllTypes test_message; switch (response.result_case()) { + case ConformanceResponse::RESULT_NOT_SET: + ReportFailure(test_name, 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, - "Failed to parse JSON input or produce JSON output."); + "Failed to parse input or produce output."); return; case ConformanceResponse::kSkipped: @@ -400,6 +405,17 @@ void ConformanceTestSuite::RunValidJsonTestWithProtobufInput( equivalent_text_format, conformance::JSON); } +void ConformanceTestSuite::RunValidProtobufTest( + const string& test_name, const TestAllTypes& input, + const string& equivalent_text_format) { + RunValidInputTest("ProtobufInput." + test_name + ".ProtobufOutput", + input.SerializeAsString(), conformance::PROTOBUF, + equivalent_text_format, conformance::PROTOBUF); + RunValidInputTest("ProtobufInput." + test_name + ".JsonOutput", + input.SerializeAsString(), conformance::PROTOBUF, + equivalent_text_format, conformance::JSON); +} + // According to proto3 JSON specification, JSON serializers follow more strict // rules than parsers (e.g., a serializer must serialize int32 values as JSON // numbers while the parser is allowed to accept them as JSON strings). This @@ -638,18 +654,22 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner, RunValidJsonTest("HelloWorld", "{\"optionalString\":\"Hello, World!\"}", "optional_string: 'Hello, World!'"); + // NOTE: The spec for JSON support is still being sorted out, these may not + // all be correct. // Test field name conventions. RunValidJsonTest( "FieldNameInSnakeCase", R"({ "fieldname1": 1, "fieldName2": 2, - "FieldName3": 3 + "fieldName3": 3, + "fieldName4": 4 })", R"( fieldname1: 1 field_name2: 2 _field_name3: 3 + field__name4_: 4 )"); RunValidJsonTest( "FieldNameWithNumbers", @@ -679,6 +699,24 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner, FIELD_NAME11: 11 FIELD_name12: 12 )"); + RunValidJsonTest( + "FieldNameWithDoubleUnderscores", + R"({ + "fieldName13": 13, + "fieldName14": 14, + "fieldName15": 15, + "fieldName16": 16, + "fieldName17": 17, + "fieldName18": 18 + })", + R"( + __field_name13: 13 + __Field_name14: 14 + field__name15: 15 + field__Name16: 16 + field_name17__: 17 + Field_name18__: 18 + )"); // Using the original proto field name in JSON is also allowed. RunValidJsonTest( "OriginalProtoFieldName", @@ -686,6 +724,7 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner, "fieldname1": 1, "field_name2": 2, "_field_name3": 3, + "field__name4_": 4, "field0name5": 5, "field_0_name6": 6, "fieldName7": 7, @@ -693,12 +732,19 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner, "field_Name9": 9, "Field_Name10": 10, "FIELD_NAME11": 11, - "FIELD_name12": 12 + "FIELD_name12": 12, + "__field_name13": 13, + "__Field_name14": 14, + "field__name15": 15, + "field__Name16": 16, + "field_name17__": 17, + "Field_name18__": 18 })", R"( fieldname1: 1 field_name2: 2 _field_name3: 3 + field__name4_: 4 field0name5: 5 field_0_name6: 6 fieldName7: 7 @@ -707,12 +753,22 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner, Field_Name10: 10 FIELD_NAME11: 11 FIELD_name12: 12 + __field_name13: 13 + __Field_name14: 14 + field__name15: 15 + field__Name16: 16 + field_name17__: 17 + Field_name18__: 18 )"); // Field names can be escaped. RunValidJsonTest( "FieldNameEscaped", R"({"fieldn\u0061me1": 1})", "fieldname1: 1"); + // String ends with escape character. + ExpectParseFailureForJson( + "StringEndsWithEscapeChar", + "{\"optionalString\": \"abc\\"); // Field names must be quoted (or it's not valid JSON). ExpectParseFailureForJson( "FieldNameNotQuoted", @@ -721,6 +777,17 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner, ExpectParseFailureForJson( "TrailingCommaInAnObject", R"({"fieldname1":1,})"); + ExpectParseFailureForJson( + "TrailingCommaInAnObjectWithSpace", + R"({"fieldname1":1 ,})"); + ExpectParseFailureForJson( + "TrailingCommaInAnObjectWithSpaceCommaSpace", + R"({"fieldname1":1 , })"); + ExpectParseFailureForJson( + "TrailingCommaInAnObjectWithNewlines", + R"({ + "fieldname1":1, + })"); // JSON doesn't support comments. ExpectParseFailureForJson( "JsonWithComments", @@ -728,6 +795,42 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner, // This is a comment. "fieldname1": 1 })"); + // JSON spec says whitespace doesn't matter, so try a few spacings to be sure. + RunValidJsonTest( + "OneLineNoSpaces", + "{\"optionalInt32\":1,\"optionalInt64\":2}", + R"( + optional_int32: 1 + optional_int64: 2 + )"); + RunValidJsonTest( + "OneLineWithSpaces", + "{ \"optionalInt32\" : 1 , \"optionalInt64\" : 2 }", + R"( + optional_int32: 1 + optional_int64: 2 + )"); + RunValidJsonTest( + "MultilineNoSpaces", + "{\n\"optionalInt32\"\n:\n1\n,\n\"optionalInt64\"\n:\n2\n}", + R"( + optional_int32: 1 + optional_int64: 2 + )"); + RunValidJsonTest( + "MultilineWithSpaces", + "{\n \"optionalInt32\" : 1\n ,\n \"optionalInt64\" : 2\n}\n", + R"( + optional_int32: 1 + optional_int64: 2 + )"); + // Missing comma between key/value pairs. + ExpectParseFailureForJson( + "MissingCommaOneLine", + "{ \"optionalInt32\": 1 \"optionalInt64\": 2 }"); + ExpectParseFailureForJson( + "MissingCommaMultiline", + "{\n \"optionalInt32\": 1\n \"optionalInt64\": 2\n}"); // Duplicated field names are not allowed. ExpectParseFailureForJson( "FieldNameDuplicate", @@ -747,18 +850,22 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner, "optionalNestedMessage": {a: 1}, "optional_nested_message": {} })"); + // NOTE: The spec for JSON support is still being sorted out, these may not + // all be correct. // Serializers should use lowerCamelCase by default. RunValidJsonTestWithValidator( "FieldNameInLowerCamelCase", R"({ "fieldname1": 1, "fieldName2": 2, - "FieldName3": 3 + "fieldName3": 3, + "fieldName4": 4 })", [](const Json::Value& value) { return value.isMember("fieldname1") && value.isMember("fieldName2") && - value.isMember("FieldName3"); + value.isMember("fieldName3") && + value.isMember("fieldName4"); }); RunValidJsonTestWithValidator( "FieldNameWithNumbers", @@ -788,6 +895,24 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner, value.isMember("fIELDNAME11") && value.isMember("fIELDName12"); }); + RunValidJsonTestWithValidator( + "FieldNameWithDoubleUnderscores", + R"({ + "fieldName13": 13, + "fieldName14": 14, + "fieldName15": 15, + "fieldName16": 16, + "fieldName17": 17, + "fieldName18": 18 + })", + [](const Json::Value& value) { + return value.isMember("fieldName13") && + value.isMember("fieldName14") && + value.isMember("fieldName15") && + value.isMember("fieldName16") && + value.isMember("fieldName17") && + value.isMember("fieldName18"); + }); // Integer fields. RunValidJsonTest( @@ -814,18 +939,26 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner, "Uint64FieldMaxValue", R"({"optionalUint64": "18446744073709551615"})", "optional_uint64: 18446744073709551615"); + // While not the largest Int64, this is the largest + // Int64 which can be exactly represented within an + // IEEE-754 64-bit float, which is the expected level + // of interoperability guarantee. Larger values may + // work in some implementations, but should not be + // relied upon. RunValidJsonTest( "Int64FieldMaxValueNotQuoted", - R"({"optionalInt64": 9223372036854775807})", - "optional_int64: 9223372036854775807"); + R"({"optionalInt64": 9223372036854774784})", + "optional_int64: 9223372036854774784"); RunValidJsonTest( "Int64FieldMinValueNotQuoted", R"({"optionalInt64": -9223372036854775808})", "optional_int64: -9223372036854775808"); + // Largest interoperable Uint64; see comment above + // for Int64FieldMaxValueNotQuoted. RunValidJsonTest( "Uint64FieldMaxValueNotQuoted", - R"({"optionalUint64": 18446744073709551615})", - "optional_uint64: 18446744073709551615"); + R"({"optionalUint64": 18446744073709549568})", + "optional_uint64: 18446744073709549568"); // Values can be represented as JSON strings. RunValidJsonTest( "Int32FieldStringValue", @@ -1217,6 +1350,64 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner, ExpectParseFailureForJson( "OneofFieldDuplicate", R"({"oneofUint32": 1, "oneofString": "test"})"); + // Ensure zero values for oneof make it out/backs. + { + TestAllTypes message; + message.set_oneof_uint32(0); + RunValidProtobufTest( + "OneofZeroUint32", message, "oneof_uint32: 0"); + message.mutable_oneof_nested_message()->set_a(0); + RunValidProtobufTest( + "OneofZeroMessage", message, "oneof_nested_message: {}"); + message.set_oneof_string(""); + RunValidProtobufTest( + "OneofZeroString", message, "oneof_string: \"\""); + message.set_oneof_bytes(""); + RunValidProtobufTest( + "OneofZeroBytes", message, "oneof_bytes: \"\""); + message.set_oneof_bool(false); + RunValidProtobufTest( + "OneofZeroBool", message, "oneof_bool: false"); + message.set_oneof_uint64(0); + RunValidProtobufTest( + "OneofZeroUint64", message, "oneof_uint64: 0"); + message.set_oneof_float(0.0f); + RunValidProtobufTest( + "OneofZeroFloat", message, "oneof_float: 0"); + message.set_oneof_double(0.0); + RunValidProtobufTest( + "OneofZeroDouble", message, "oneof_double: 0"); + message.set_oneof_enum(TestAllTypes::FOO); + RunValidProtobufTest( + "OneofZeroEnum", message, "oneof_enum: FOO"); + } + RunValidJsonTest( + "OneofZeroUint32", + R"({"oneofUint32": 0})", "oneof_uint32: 0"); + RunValidJsonTest( + "OneofZeroMessage", + R"({"oneofNestedMessage": {}})", "oneof_nested_message: {}"); + RunValidJsonTest( + "OneofZeroString", + R"({"oneofString": ""})", "oneof_string: \"\""); + RunValidJsonTest( + "OneofZeroBytes", + R"({"oneofBytes": ""})", "oneof_bytes: \"\""); + RunValidJsonTest( + "OneofZeroBool", + R"({"oneofBool": false})", "oneof_bool: false"); + RunValidJsonTest( + "OneofZeroUint64", + R"({"oneofUint64": 0})", "oneof_uint64: 0"); + RunValidJsonTest( + "OneofZeroFloat", + R"({"oneofFloat": 0.0})", "oneof_float: 0"); + RunValidJsonTest( + "OneofZeroDouble", + R"({"oneofDouble": 0.0})", "oneof_double: 0"); + RunValidJsonTest( + "OneofZeroEnum", + R"({"oneofEnum":"FOO"})", "oneof_enum: FOO"); // Repeated fields. RunValidJsonTest( @@ -1273,6 +1464,15 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner, ExpectParseFailureForJson( "RepeatedFieldTrailingComma", R"({"repeatedInt32": [1, 2, 3, 4,]})"); + ExpectParseFailureForJson( + "RepeatedFieldTrailingCommaWithSpace", + "{\"repeatedInt32\": [1, 2, 3, 4 ,]}"); + ExpectParseFailureForJson( + "RepeatedFieldTrailingCommaWithSpaceCommaSpace", + "{\"repeatedInt32\": [1, 2, 3, 4 , ]}"); + ExpectParseFailureForJson( + "RepeatedFieldTrailingCommaWithNewlines", + "{\"repeatedInt32\": [\n 1,\n 2,\n 3,\n 4,\n]}"); // Map fields. RunValidJsonTest( @@ -1391,6 +1591,18 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner, "MapFieldValueIsNull", R"({"mapInt32Int32": {"0": null}})"); + // http://www.rfc-editor.org/rfc/rfc7159.txt says strings have to use double + // quotes. + ExpectParseFailureForJson( + "StringFieldSingleQuoteKey", + R"({'optionalString': "Hello world!"})"); + ExpectParseFailureForJson( + "StringFieldSingleQuoteValue", + R"({"optionalString": 'Hello world!'})"); + ExpectParseFailureForJson( + "StringFieldSingleQuoteBoth", + R"({'optionalString': 'Hello world!'})"); + // Wrapper types. RunValidJsonTest( "OptionalBoolWrapper", diff --git a/conformance/conformance_test.h b/conformance/conformance_test.h index c9c5213c..56689318 100644 --- a/conformance/conformance_test.h +++ b/conformance/conformance_test.h @@ -133,6 +133,9 @@ class ConformanceTestSuite { void RunValidJsonTestWithProtobufInput(const string& test_name, const conformance::TestAllTypes& input, const string& equivalent_text_format); + void RunValidProtobufTest(const string& test_name, + const conformance::TestAllTypes& input, + const string& equivalent_text_format); typedef std::function<bool(const Json::Value&)> Validator; void RunValidJsonTestWithValidator(const string& test_name, diff --git a/conformance/failure_list_cpp.txt b/conformance/failure_list_cpp.txt index 839e5210..5e17176e 100644 --- a/conformance/failure_list_cpp.txt +++ b/conformance/failure_list_cpp.txt @@ -22,16 +22,22 @@ JsonInput.FieldMaskInvalidCharacter JsonInput.FieldNameDuplicate JsonInput.FieldNameDuplicateDifferentCasing1 JsonInput.FieldNameDuplicateDifferentCasing2 -JsonInput.FieldNameInLowerCamelCase.Validator -JsonInput.FieldNameInSnakeCase.JsonOutput -JsonInput.FieldNameInSnakeCase.ProtobufOutput JsonInput.FieldNameNotQuoted JsonInput.MapFieldValueIsNull JsonInput.RepeatedFieldMessageElementIsNull JsonInput.RepeatedFieldPrimitiveElementIsNull JsonInput.RepeatedFieldTrailingComma +JsonInput.RepeatedFieldTrailingCommaWithNewlines +JsonInput.RepeatedFieldTrailingCommaWithSpace +JsonInput.RepeatedFieldTrailingCommaWithSpaceCommaSpace +JsonInput.StringFieldSingleQuoteBoth +JsonInput.StringFieldSingleQuoteKey +JsonInput.StringFieldSingleQuoteValue JsonInput.StringFieldUppercaseEscapeLetter JsonInput.TrailingCommaInAnObject +JsonInput.TrailingCommaInAnObjectWithNewlines +JsonInput.TrailingCommaInAnObjectWithSpace +JsonInput.TrailingCommaInAnObjectWithSpaceCommaSpace JsonInput.WrapperTypesWithNullValue.JsonOutput JsonInput.WrapperTypesWithNullValue.ProtobufOutput ProtobufInput.PrematureEofBeforeKnownRepeatedValue.MESSAGE diff --git a/conformance/failure_list_csharp.txt b/conformance/failure_list_csharp.txt index e7de4b96..d8bfe1bb 100644 --- a/conformance/failure_list_csharp.txt +++ b/conformance/failure_list_csharp.txt @@ -1,11 +1,4 @@ -JsonInput.FieldNameInLowerCamelCase.Validator -JsonInput.FieldNameInSnakeCase.JsonOutput -JsonInput.FieldNameInSnakeCase.ProtobufOutput JsonInput.FieldNameWithMixedCases.JsonOutput JsonInput.FieldNameWithMixedCases.ProtobufOutput JsonInput.FieldNameWithMixedCases.Validator -JsonInput.Int64FieldMaxValueNotQuoted.JsonOutput -JsonInput.Int64FieldMaxValueNotQuoted.ProtobufOutput JsonInput.OriginalProtoFieldName.JsonOutput -JsonInput.Uint64FieldMaxValueNotQuoted.JsonOutput -JsonInput.Uint64FieldMaxValueNotQuoted.ProtobufOutput diff --git a/conformance/failure_list_java.txt b/conformance/failure_list_java.txt index 850712bd..b2122c8b 100644 --- a/conformance/failure_list_java.txt +++ b/conformance/failure_list_java.txt @@ -20,8 +20,13 @@ JsonInput.DoubleFieldNegativeInfinityNotQuoted JsonInput.EnumFieldNotQuoted JsonInput.FieldMaskInvalidCharacter JsonInput.FieldNameDuplicate +JsonInput.FieldNameInLowerCamelCase.Validator JsonInput.FieldNameInSnakeCase.JsonOutput +JsonInput.FieldNameInSnakeCase.ProtobufOutput JsonInput.FieldNameNotQuoted +JsonInput.FieldNameWithDoubleUnderscores.JsonOutput +JsonInput.FieldNameWithDoubleUnderscores.ProtobufOutput +JsonInput.FieldNameWithDoubleUnderscores.Validator JsonInput.FloatFieldInfinityNotQuoted JsonInput.FloatFieldNanNotQuoted JsonInput.FloatFieldNegativeInfinityNotQuoted @@ -35,6 +40,9 @@ JsonInput.OriginalProtoFieldName.JsonOutput JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotBool JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt JsonInput.StringFieldNotAString +JsonInput.StringFieldSingleQuoteBoth +JsonInput.StringFieldSingleQuoteKey +JsonInput.StringFieldSingleQuoteValue JsonInput.StringFieldSurrogateInWrongOrder JsonInput.StringFieldUnpairedHighSurrogate JsonInput.StringFieldUnpairedLowSurrogate diff --git a/conformance/failure_list_objc.txt b/conformance/failure_list_objc.txt index 5dac3501..dd538c10 100644 --- a/conformance/failure_list_objc.txt +++ b/conformance/failure_list_objc.txt @@ -1,4 +1,4 @@ -# No tests currently failing. +# All tests currently passing. # -# json input or output tests are skipped (in conformance_objc.m) as mobile -# platforms don't support json wire format to avoid code bloat. +# JSON input or output tests are skipped (in conformance_objc.m) as mobile +# platforms don't support JSON wire format to avoid code bloat. diff --git a/conformance/failure_list_python.txt b/conformance/failure_list_python.txt index 550a043f..d38b7828 100644 --- a/conformance/failure_list_python.txt +++ b/conformance/failure_list_python.txt @@ -19,9 +19,6 @@ JsonInput.EnumFieldNumericValueZero.ProtobufOutput JsonInput.EnumFieldUnknownValue.Validator JsonInput.FieldMask.ProtobufOutput JsonInput.FieldMaskInvalidCharacter -JsonInput.FieldNameInLowerCamelCase.Validator -JsonInput.FieldNameInSnakeCase.JsonOutput -JsonInput.FieldNameInSnakeCase.ProtobufOutput JsonInput.FloatFieldInfinityNotQuoted JsonInput.FloatFieldNanNotQuoted JsonInput.FloatFieldNegativeInfinityNotQuoted @@ -35,6 +32,8 @@ JsonInput.Int32FieldMaxFloatValue.JsonOutput JsonInput.Int32FieldMaxFloatValue.ProtobufOutput JsonInput.Int32FieldMinFloatValue.JsonOutput JsonInput.Int32FieldMinFloatValue.ProtobufOutput +JsonInput.OneofZeroMessage.JsonOutput +JsonInput.OneofZeroMessage.ProtobufOutput JsonInput.OriginalProtoFieldName.JsonOutput JsonInput.OriginalProtoFieldName.ProtobufOutput JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool diff --git a/conformance/failure_list_python_cpp.txt b/conformance/failure_list_python_cpp.txt index 1eb916ab..84d9fccd 100644 --- a/conformance/failure_list_python_cpp.txt +++ b/conformance/failure_list_python_cpp.txt @@ -28,9 +28,6 @@ JsonInput.EnumFieldNumericValueZero.ProtobufOutput JsonInput.EnumFieldUnknownValue.Validator JsonInput.FieldMask.ProtobufOutput JsonInput.FieldMaskInvalidCharacter -JsonInput.FieldNameInLowerCamelCase.Validator -JsonInput.FieldNameInSnakeCase.JsonOutput -JsonInput.FieldNameInSnakeCase.ProtobufOutput JsonInput.FloatFieldInfinityNotQuoted JsonInput.FloatFieldNanNotQuoted JsonInput.FloatFieldNegativeInfinityNotQuoted @@ -44,6 +41,8 @@ JsonInput.Int32FieldMaxFloatValue.JsonOutput JsonInput.Int32FieldMaxFloatValue.ProtobufOutput JsonInput.Int32FieldMinFloatValue.JsonOutput JsonInput.Int32FieldMinFloatValue.ProtobufOutput +JsonInput.OneofZeroMessage.JsonOutput +JsonInput.OneofZeroMessage.ProtobufOutput JsonInput.OriginalProtoFieldName.JsonOutput JsonInput.OriginalProtoFieldName.ProtobufOutput JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool diff --git a/conformance/failure_list_ruby.txt b/conformance/failure_list_ruby.txt index 7c12da06..2a533aa5 100644 --- a/conformance/failure_list_ruby.txt +++ b/conformance/failure_list_ruby.txt @@ -58,7 +58,12 @@ JsonInput.EnumFieldNumericValueZero.ProtobufOutput JsonInput.EnumFieldUnknownValue.Validator JsonInput.FieldMask.JsonOutput JsonInput.FieldMask.ProtobufOutput +JsonInput.FieldNameInLowerCamelCase.Validator JsonInput.FieldNameInSnakeCase.JsonOutput +JsonInput.FieldNameInSnakeCase.ProtobufOutput +JsonInput.FieldNameWithDoubleUnderscores.JsonOutput +JsonInput.FieldNameWithDoubleUnderscores.ProtobufOutput +JsonInput.FieldNameWithDoubleUnderscores.Validator JsonInput.FieldNameWithMixedCases.JsonOutput JsonInput.FieldNameWithMixedCases.ProtobufOutput JsonInput.FieldNameWithMixedCases.Validator @@ -103,6 +108,14 @@ JsonInput.MessageMapField.JsonOutput JsonInput.MessageMapField.ProtobufOutput JsonInput.MessageRepeatedField.JsonOutput JsonInput.MessageRepeatedField.ProtobufOutput +JsonInput.OneofZeroDouble.JsonOutput +JsonInput.OneofZeroDouble.ProtobufOutput +JsonInput.OneofZeroFloat.JsonOutput +JsonInput.OneofZeroFloat.ProtobufOutput +JsonInput.OneofZeroUint32.JsonOutput +JsonInput.OneofZeroUint32.ProtobufOutput +JsonInput.OneofZeroUint64.JsonOutput +JsonInput.OneofZeroUint64.ProtobufOutput JsonInput.OptionalBoolWrapper.JsonOutput JsonInput.OptionalBoolWrapper.ProtobufOutput JsonInput.OptionalBytesWrapper.JsonOutput @@ -145,6 +158,7 @@ JsonInput.RepeatedUint32Wrapper.JsonOutput JsonInput.RepeatedUint32Wrapper.ProtobufOutput JsonInput.RepeatedUint64Wrapper.JsonOutput JsonInput.RepeatedUint64Wrapper.ProtobufOutput +JsonInput.StringEndsWithEscapeChar JsonInput.StringFieldNotAString JsonInput.StringFieldSurrogateInWrongOrder JsonInput.StringFieldSurrogatePair.JsonOutput |