Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
7437774a
Commit
7437774a
authored
Aug 19, 2016
by
Thomas Van Lenten
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More JSON tests
- String behaviors - Testing only valid JSON is allowed
parent
ff2a6600
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
0 deletions
+85
-0
conformance_test.cc
conformance/conformance_test.cc
+72
-0
failure_list_cpp.txt
conformance/failure_list_cpp.txt
+9
-0
failure_list_java.txt
conformance/failure_list_java.txt
+3
-0
failure_list_ruby.txt
conformance/failure_list_ruby.txt
+1
-0
No files found.
conformance/conformance_test.cc
View file @
7437774a
...
@@ -763,6 +763,10 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
...
@@ -763,6 +763,10 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
"FieldNameEscaped"
,
"FieldNameEscaped"
,
R"({"fieldn\u0061me1": 1})"
,
R"({"fieldn\u0061me1": 1})"
,
"fieldname1: 1"
);
"fieldname1: 1"
);
// String ends with escape character.
ExpectParseFailureForJson
(
"StringEndsWithEscapeChar"
,
"{
\"
optionalString
\"
:
\"
abc
\\
"
);
// Field names must be quoted (or it's not valid JSON).
// Field names must be quoted (or it's not valid JSON).
ExpectParseFailureForJson
(
ExpectParseFailureForJson
(
"FieldNameNotQuoted"
,
"FieldNameNotQuoted"
,
...
@@ -771,6 +775,17 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
...
@@ -771,6 +775,17 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
ExpectParseFailureForJson
(
ExpectParseFailureForJson
(
"TrailingCommaInAnObject"
,
"TrailingCommaInAnObject"
,
R"({"fieldname1":1,})"
);
R"({"fieldname1":1,})"
);
ExpectParseFailureForJson
(
"TrailingCommaInAnObjectWithSpace"
,
R"({"fieldname1":1 ,})"
);
ExpectParseFailureForJson
(
"TrailingCommaInAnObjectWithSpaceCommaSpace"
,
R"({"fieldname1":1 , })"
);
ExpectParseFailureForJson
(
"TrailingCommaInAnObjectWithNewlines"
,
R"({
"fieldname1":1,
})"
);
// JSON doesn't support comments.
// JSON doesn't support comments.
ExpectParseFailureForJson
(
ExpectParseFailureForJson
(
"JsonWithComments"
,
"JsonWithComments"
,
...
@@ -778,6 +793,42 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
...
@@ -778,6 +793,42 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
// This is a comment.
// This is a comment.
"fieldname1": 1
"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
:
\n
1
\n
,
\n\"
optionalInt64
\"\n
:
\n
2
\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.
// Duplicated field names are not allowed.
ExpectParseFailureForJson
(
ExpectParseFailureForJson
(
"FieldNameDuplicate"
,
"FieldNameDuplicate"
,
...
@@ -1389,6 +1440,15 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
...
@@ -1389,6 +1440,15 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
ExpectParseFailureForJson
(
ExpectParseFailureForJson
(
"RepeatedFieldTrailingComma"
,
"RepeatedFieldTrailingComma"
,
R"({"repeatedInt32": [1, 2, 3, 4,]})"
);
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.
// Map fields.
RunValidJsonTest
(
RunValidJsonTest
(
...
@@ -1507,6 +1567,18 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
...
@@ -1507,6 +1567,18 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
"MapFieldValueIsNull"
,
"MapFieldValueIsNull"
,
R"({"mapInt32Int32": {"0": null}})"
);
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.
// Wrapper types.
RunValidJsonTest
(
RunValidJsonTest
(
"OptionalBoolWrapper"
,
"OptionalBoolWrapper"
,
...
...
conformance/failure_list_cpp.txt
View file @
7437774a
...
@@ -30,8 +30,17 @@ JsonInput.MapFieldValueIsNull
...
@@ -30,8 +30,17 @@ JsonInput.MapFieldValueIsNull
JsonInput.RepeatedFieldMessageElementIsNull
JsonInput.RepeatedFieldMessageElementIsNull
JsonInput.RepeatedFieldPrimitiveElementIsNull
JsonInput.RepeatedFieldPrimitiveElementIsNull
JsonInput.RepeatedFieldTrailingComma
JsonInput.RepeatedFieldTrailingComma
JsonInput.RepeatedFieldTrailingCommaWithNewlines
JsonInput.RepeatedFieldTrailingCommaWithSpace
JsonInput.RepeatedFieldTrailingCommaWithSpaceCommaSpace
JsonInput.StringFieldSingleQuoteBoth
JsonInput.StringFieldSingleQuoteKey
JsonInput.StringFieldSingleQuoteValue
JsonInput.StringFieldUppercaseEscapeLetter
JsonInput.StringFieldUppercaseEscapeLetter
JsonInput.TrailingCommaInAnObject
JsonInput.TrailingCommaInAnObject
JsonInput.TrailingCommaInAnObjectWithNewlines
JsonInput.TrailingCommaInAnObjectWithSpace
JsonInput.TrailingCommaInAnObjectWithSpaceCommaSpace
JsonInput.WrapperTypesWithNullValue.JsonOutput
JsonInput.WrapperTypesWithNullValue.JsonOutput
JsonInput.WrapperTypesWithNullValue.ProtobufOutput
JsonInput.WrapperTypesWithNullValue.ProtobufOutput
ProtobufInput.PrematureEofBeforeKnownRepeatedValue.MESSAGE
ProtobufInput.PrematureEofBeforeKnownRepeatedValue.MESSAGE
...
...
conformance/failure_list_java.txt
View file @
7437774a
...
@@ -38,6 +38,9 @@ JsonInput.OriginalProtoFieldName.JsonOutput
...
@@ -38,6 +38,9 @@ JsonInput.OriginalProtoFieldName.JsonOutput
JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotBool
JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotBool
JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt
JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt
JsonInput.StringFieldNotAString
JsonInput.StringFieldNotAString
JsonInput.StringFieldSingleQuoteBoth
JsonInput.StringFieldSingleQuoteKey
JsonInput.StringFieldSingleQuoteValue
JsonInput.StringFieldSurrogateInWrongOrder
JsonInput.StringFieldSurrogateInWrongOrder
JsonInput.StringFieldUnpairedHighSurrogate
JsonInput.StringFieldUnpairedHighSurrogate
JsonInput.StringFieldUnpairedLowSurrogate
JsonInput.StringFieldUnpairedLowSurrogate
...
...
conformance/failure_list_ruby.txt
View file @
7437774a
...
@@ -156,6 +156,7 @@ JsonInput.RepeatedUint32Wrapper.JsonOutput
...
@@ -156,6 +156,7 @@ JsonInput.RepeatedUint32Wrapper.JsonOutput
JsonInput.RepeatedUint32Wrapper.ProtobufOutput
JsonInput.RepeatedUint32Wrapper.ProtobufOutput
JsonInput.RepeatedUint64Wrapper.JsonOutput
JsonInput.RepeatedUint64Wrapper.JsonOutput
JsonInput.RepeatedUint64Wrapper.ProtobufOutput
JsonInput.RepeatedUint64Wrapper.ProtobufOutput
JsonInput.StringEndsWithEscapeChar
JsonInput.StringFieldNotAString
JsonInput.StringFieldNotAString
JsonInput.StringFieldSurrogateInWrongOrder
JsonInput.StringFieldSurrogateInWrongOrder
JsonInput.StringFieldSurrogatePair.JsonOutput
JsonInput.StringFieldSurrogatePair.JsonOutput
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment