Skip to content

Commit

Permalink
Added a conformance test for embedded nulls in JSON strings.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
haberman authored and copybara-github committed Apr 28, 2023
1 parent f6c7fdf commit 37dfe80
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion conformance/binary_json_conformance_suite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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": "谷歌"})",
Expand All @@ -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,
Expand Down

0 comments on commit 37dfe80

Please sign in to comment.