Add note about JSON tests maybe being wrong. (#1992)

Add note about JSON tests maybe being wrong.

- Add note about the JSON test maybe not being correct yet.
- Add test to checks the generated names for double underscores to be sure they
  are what is expected.
This commit is contained in:
Thomas Van Lenten 2016-08-23 08:19:45 -04:00 committed by GitHub
parent b5794ed024
commit 80f65d2df8
8 changed files with 35 additions and 16 deletions

3
.gitignore vendored
View File

@ -111,7 +111,10 @@ conformance/conformance.pb.h
conformance/Conformance.pbobjc.h
conformance/Conformance.pbobjc.m
conformance/conformance_pb.rb
conformance/failing_tests.txt
conformance/google/
conformance/javac_middleman
conformance/lite/
conformance/nonexistent_tests.txt
conformance/protoc_middleman
conformance/succeeding_tests.txt

View File

@ -654,14 +654,16 @@ 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,
"FieldName4": 4
"fieldName3": 3,
"fieldName4": 4
})",
R"(
fieldname1: 1
@ -848,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",
@ -889,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(

View File

@ -22,9 +22,6 @@ JsonInput.FieldMaskInvalidCharacter
JsonInput.FieldNameDuplicate
JsonInput.FieldNameDuplicateDifferentCasing1
JsonInput.FieldNameDuplicateDifferentCasing2
JsonInput.FieldNameInLowerCamelCase.Validator
JsonInput.FieldNameInSnakeCase.JsonOutput
JsonInput.FieldNameInSnakeCase.ProtobufOutput
JsonInput.FieldNameNotQuoted
JsonInput.MapFieldValueIsNull
JsonInput.RepeatedFieldMessageElementIsNull

View File

@ -1,6 +1,3 @@
JsonInput.FieldNameInLowerCamelCase.Validator
JsonInput.FieldNameInSnakeCase.JsonOutput
JsonInput.FieldNameInSnakeCase.ProtobufOutput
JsonInput.FieldNameWithMixedCases.JsonOutput
JsonInput.FieldNameWithMixedCases.ProtobufOutput
JsonInput.FieldNameWithMixedCases.Validator

View File

@ -20,11 +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

View File

@ -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

View File

@ -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

View File

@ -58,10 +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