diff options
author | Jon Skeet <jonskeet@google.com> | 2018-03-01 13:20:40 +0000 |
---|---|---|
committer | Jon Skeet <jonskeet@google.com> | 2018-03-01 13:20:40 +0000 |
commit | 822b924d593f67d2536c7bdeaf55cedf614da244 (patch) | |
tree | 507654051869fb7eabd94378a33c15b88b642aa5 /csharp/src/Google.Protobuf.Test/JsonParserTest.cs | |
parent | 9dc0a4d5cf181845c4c8ca6c482ec38cc1835bbc (diff) | |
download | protobuf-822b924d593f67d2536c7bdeaf55cedf614da244.tar.gz protobuf-822b924d593f67d2536c7bdeaf55cedf614da244.tar.bz2 protobuf-822b924d593f67d2536c7bdeaf55cedf614da244.zip |
Allow list values to be null when parsing
Diffstat (limited to 'csharp/src/Google.Protobuf.Test/JsonParserTest.cs')
-rw-r--r-- | csharp/src/Google.Protobuf.Test/JsonParserTest.cs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/csharp/src/Google.Protobuf.Test/JsonParserTest.cs b/csharp/src/Google.Protobuf.Test/JsonParserTest.cs index 329ae9be..a6cf04ab 100644 --- a/csharp/src/Google.Protobuf.Test/JsonParserTest.cs +++ b/csharp/src/Google.Protobuf.Test/JsonParserTest.cs @@ -696,6 +696,22 @@ namespace Google.Protobuf } [Test] + public void Value_List_WithNullElement() + { + var expected = Value.ForList(Value.ForString("x"), Value.ForNull(), Value.ForString("y")); + var actual = Value.Parser.ParseJson("[\"x\", null, \"y\"]"); + Assert.AreEqual(expected, actual); + } + + [Test] + public void StructValue_NullElement() + { + var expected = Value.ForStruct(new Struct { Fields = { { "x", Value.ForNull() } } }); + var actual = Value.Parser.ParseJson("{ \"x\": null }"); + Assert.AreEqual(expected, actual); + } + + [Test] public void ParseListValue() { Assert.AreEqual(new ListValue { Values = { Value.ForNumber(1), Value.ForString("x") } }, ListValue.Parser.ParseJson("[1, \"x\"]")); |