Commit 662f9784 authored by Anuraag Agrawal's avatar Anuraag Agrawal

Fix duplicate fields test. The repeated version is passing because null values…

Fix duplicate fields test. The repeated version is passing because null values in a repeated field are rejected and not testing what it wanted to. Also adds a oneof version that verifies the case of oneof fields of different names (currently only same name check seems to be tested).

Also fix spelling of a test.
parent 373809e5
......@@ -264,7 +264,7 @@ public class JsonFormatTest extends TestCase {
assertRoundTripEquals(message);
}
public void testParserAcceptStringForNumbericField() throws Exception {
public void testParserAcceptStringForNumericField() throws Exception {
TestAllTypes.Builder builder = TestAllTypes.newBuilder();
mergeFromJson(
"{\n"
......@@ -479,8 +479,8 @@ public class JsonFormatTest extends TestCase {
TestAllTypes.Builder builder = TestAllTypes.newBuilder();
mergeFromJson(
"{\n"
+ " \"repeatedNestedMessage\": [null, null],\n"
+ " \"repeated_nested_message\": [null, null]\n"
+ " \"repeatedInt32\": [1, 2],\n"
+ " \"repeated_int32\": [5, 6]\n"
+ "}",
builder);
fail();
......@@ -488,7 +488,7 @@ public class JsonFormatTest extends TestCase {
// Exception expected.
}
// Duplicated oneof fields.
// Duplicated oneof fields, same name.
try {
TestOneof.Builder builder = TestOneof.newBuilder();
mergeFromJson("{\n" + " \"oneofInt32\": 1,\n" + " \"oneof_int32\": 2\n" + "}", builder);
......@@ -496,6 +496,16 @@ public class JsonFormatTest extends TestCase {
} catch (InvalidProtocolBufferException e) {
// Exception expected.
}
// Duplicated oneof fields, different name.
try {
TestOneof.Builder builder = TestOneof.newBuilder();
mergeFromJson(
"{\n" + " \"oneofInt32\": 1,\n" + " \"oneofNullValue\": null\n" + "}", builder);
fail();
} catch (InvalidProtocolBufferException e) {
// Exception expected.
}
}
public void testMapFields() throws Exception {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment