Added a conformance test for embedded nulls in JSON strings.

Going forward we will be forbidding `null` in `json_name`, but we will continue to support embedded `null` in JSON value.  This conformance test will help clarify that this is a supported use case.

PiperOrigin-RevId: 527918031
This commit is contained in:
Joshua Haberman 2023-04-28 10:11:27 -07:00 committed by Copybara-Service
parent f6c7fdf88c
commit 37dfe806f8

View file

@ -2378,7 +2378,7 @@ void BinaryAndJsonConformanceSuite::RunJsonTestsForNonRepeatedTypes() {
// String fields.
RunValidJsonTest("StringField", REQUIRED,
R"({"optionalString": "Hello world!"})",
"optional_string: \"Hello world!\"");
R"(optional_string: "Hello world!")");
RunValidJsonTest("StringFieldUnicode", REQUIRED,
// Google in Chinese.
R"({"optionalString": ""})",
@ -2397,6 +2397,9 @@ void BinaryAndJsonConformanceSuite::RunJsonTestsForNonRepeatedTypes() {
// The character is an emoji: grinning face with smiling eyes. 😁
R"({"optionalString": "\uD83D\uDE01"})",
R"(optional_string: "\xF0\x9F\x98\x81")");
RunValidJsonTest("StringFieldEmbeddedNull", REQUIRED,
R"({"optionalString": "Hello\u0000world!"})",
R"(optional_string: "Hello\000world!")");
// Unicode escapes must start with "\u" (lowercase u).
ExpectParseFailureForJson("StringFieldUppercaseEscapeLetter", RECOMMENDED,