From 8866d6a80ed30e1ff32f1c5420f1a803c26fa13a Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 15 Jan 2016 13:54:17 +0000 Subject: Reject JSON containing the same oneof field twice --- csharp/src/Google.Protobuf.Test/JsonParserTest.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'csharp/src/Google.Protobuf.Test/JsonParserTest.cs') diff --git a/csharp/src/Google.Protobuf.Test/JsonParserTest.cs b/csharp/src/Google.Protobuf.Test/JsonParserTest.cs index fb5e083e..bfbde364 100644 --- a/csharp/src/Google.Protobuf.Test/JsonParserTest.cs +++ b/csharp/src/Google.Protobuf.Test/JsonParserTest.cs @@ -895,6 +895,13 @@ namespace Google.Protobuf Assert.Throws(() => TestAllTypes.Parser.ParseJson(json)); } + [Test] + public void OneofDuplicate_Invalid() + { + string json = "{ \"oneofString\": \"x\", \"oneofUint32\": 10 }"; + Assert.Throws(() => TestAllTypes.Parser.ParseJson(json)); + } + /// /// Various tests use strings which have quotes round them for parsing or as the result /// of formatting, but without those quotes being specified in the tests (for the sake of readability). -- cgit v1.2.3