diff --git a/conformance/BUILD b/conformance/BUILD index e3c22bb0fb1f4..b6bbbc4cdeec9 100644 --- a/conformance/BUILD +++ b/conformance/BUILD @@ -143,7 +143,6 @@ cc_library( "//editions:test_messages_proto2_editions_cc_proto", "//editions:test_messages_proto3_editions_cc_proto", "//src/google/protobuf", - "//src/google/protobuf:endian", "//src/google/protobuf:protobuf_lite", "//src/google/protobuf/json", "//src/google/protobuf/util:type_resolver", diff --git a/conformance/binary_json_conformance_suite.cc b/conformance/binary_json_conformance_suite.cc index 62c9294893a09..46a1517d5f0a7 100644 --- a/conformance/binary_json_conformance_suite.cc +++ b/conformance/binary_json_conformance_suite.cc @@ -3471,6 +3471,68 @@ void BinaryAndJsonConformanceSuiteImpl::RunJsonTestsForStruct() { } } )"); + + std::string deep_json = R"({"optionalStruct": {)"; + std::string deep_proto = "optional_struct: {\n"; + int depth = 25; + for (int i = 0; i < depth; ++i) { + deep_json += R"("n": {)"; + deep_proto += R"( fields: { + key: "n" + value: { + struct_value: { +)"; + } + deep_json += R"("value": 1)"; + deep_proto += R"( fields: { + key: "value" + value: { + number_value: 1 + } + } +)"; + + for (int i = 0; i < depth; ++i) { + deep_json += '}'; + deep_proto += R"( } + } + } +)"; + } + deep_json += "}}"; + deep_proto += "}\n"; + + RunValidJsonTest("StructDeepNesting25", REQUIRED, deep_json, deep_proto); + + { + std::string deep_json = R"({"optionalStruct": {)"; + int depth = 90; + for (int i = 0; i < depth; ++i) { + deep_json += R"("n": {)"; + } + deep_json += R"("value": 1)"; + for (int i = 0; i < depth; ++i) { + deep_json += '}'; + } + deep_json += "}}"; + + ExpectParseFailureForJson("StructDeepNesting90", REQUIRED, deep_json); + } + + { + std::string deep_json = R"({"optionalStruct": {)"; + int depth = 200; + for (int i = 0; i < depth; ++i) { + deep_json += R"("n": {)"; + } + deep_json += R"("value": 1)"; + for (int i = 0; i < depth; ++i) { + deep_json += '}'; + } + deep_json += "}}"; + + ExpectParseFailureForJson("StructDeepNesting200", REQUIRED, deep_json); + } } template @@ -3561,6 +3623,54 @@ void BinaryAndJsonConformanceSuiteImpl::RunJsonTestsForValue() { "optional_value: { number_value: nan}"); ExpectSerializeFailureForJson("ValueRejectInfNumberValue", RECOMMENDED, "optional_value: { number_value: inf}"); + + { + std::string deep_json = R"({"optionalValue": )"; + std::string deep_proto = "optional_value: {\n"; + int depth = 25; + for (int i = 0; i < depth; ++i) { + deep_json += '['; + deep_proto += " list_value: {\n values: {\n"; + } + deep_json += '1'; + deep_proto += " number_value: 1\n"; + for (int i = 0; i < depth; ++i) { + deep_json += ']'; + deep_proto += " }\n }\n"; + } + deep_json += '}'; + deep_proto += "}\n"; + + RunValidJsonTest("ValueDeepNesting", REQUIRED, deep_json, deep_proto); + } + { + std::string deep_json = R"({"optionalValue": )"; + int depth = 90; + for (int i = 0; i < depth; ++i) { + deep_json += '['; + } + deep_json += '1'; + for (int i = 0; i < depth; ++i) { + deep_json += ']'; + } + deep_json += '}'; + + ExpectParseFailureForJson("ValueDeepNesting90", REQUIRED, deep_json); + } + { + std::string deep_json = R"({"optionalValue": )"; + int depth = 200; + for (int i = 0; i < depth; ++i) { + deep_json += '['; + } + deep_json += '1'; + for (int i = 0; i < depth; ++i) { + deep_json += ']'; + } + deep_json += '}'; + + ExpectParseFailureForJson("ValueDeepNesting200", REQUIRED, deep_json); + } } template diff --git a/conformance/failure_list_cpp.txt b/conformance/failure_list_cpp.txt index f2d114909c9f4..7089833ba2b78 100644 --- a/conformance/failure_list_cpp.txt +++ b/conformance/failure_list_cpp.txt @@ -34,6 +34,7 @@ Recommended.*.FieldMaskTooManyUnderscore.JsonOutput Recommended.*.JsonInput.FieldMaskInvalidCharacter # Should have failed to parse, but didn't. Required.*.JsonInput.SingleValueForRepeatedFieldInt32 # Should have failed to parse, but didn't. Required.*.JsonInput.SingleValueForRepeatedFieldMessage # Should have failed to parse, but didn't. +Required.*.JsonInput.StructDeepNesting90 # Should have failed to parse, but didn't. Required.*.ProtobufInput.BadTag_FieldNumberSlightlyTooHigh # Should have failed to parse, but didn't. # TODO: Uncomment once conformance tests can express failures that are not expected to be fixed. # Recommended.Editions_Proto2.ProtobufInput.RejectInvalidUtf8.String.MapKey # Should have failed to parse, but didn't. diff --git a/conformance/failure_list_java.txt b/conformance/failure_list_java.txt index 94c9871484a68..cc076a1f7105d 100644 --- a/conformance/failure_list_java.txt +++ b/conformance/failure_list_java.txt @@ -42,6 +42,8 @@ Required.*.JsonInput.Int32FieldPlusSign Required.*.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotBool # Should have failed to parse, but didn't. Required.*.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt # Should have failed to parse, but didn't. Required.*.JsonInput.StringFieldNotAString # Should have failed to parse, but didn't. +Required.*.JsonInput.StructDeepNesting90 # Should have failed to parse, but didn't. +Required.*.JsonInput.ValueDeepNesting90 # Should have failed to parse, but didn't. Required.*.ProtobufInput.UnknownOrdering.ProtobufOutput # Unknown field mismatch Required.*.ProtobufInput.BadTag_FieldNumberTooHigh # Should have failed to parse, but didn't. Required.*.ProtobufInput.BadTag_FieldNumberSlightlyTooHigh # Should have failed to parse, but didn't. diff --git a/conformance/failure_list_python.txt b/conformance/failure_list_python.txt index bd8e7703ba508..0f35dbed0bf0a 100644 --- a/conformance/failure_list_python.txt +++ b/conformance/failure_list_python.txt @@ -1,5 +1,6 @@ -Recommended.*.JsonInput.FieldNameDuplicateDifferentCasing1 # Should have failed to parse, but didn't. -Recommended.*.JsonInput.FieldNameDuplicateDifferentCasing2 # Should have failed to parse, but didn't. +Recommended.*.JsonInput.FieldNameDuplicateDifferentCasing1 # Should have failed to parse, but didn't. +Recommended.*.JsonInput.FieldNameDuplicateDifferentCasing2 # Should have failed to parse, but didn't. +Required.*.JsonInput.StructDeepNesting25.ProtobufOutput # Failed to parse input or produce output. Required.*.ProtobufInput.BadTag_FieldNumberTooHigh # Should have failed to parse, but didn't. Required.*.ProtobufInput.BadTag_FieldNumberSlightlyTooHigh # Should have failed to parse, but didn't. Required.*.ProtobufInput.BadTag_OverlongVarint # Should have failed to parse, but didn't.