aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/Google.Protobuf.Test/JsonParserTest.cs
diff options
context:
space:
mode:
Diffstat (limited to 'csharp/src/Google.Protobuf.Test/JsonParserTest.cs')
-rw-r--r--csharp/src/Google.Protobuf.Test/JsonParserTest.cs12
1 files changed, 11 insertions, 1 deletions
diff --git a/csharp/src/Google.Protobuf.Test/JsonParserTest.cs b/csharp/src/Google.Protobuf.Test/JsonParserTest.cs
index bfbde364..612a7b12 100644
--- a/csharp/src/Google.Protobuf.Test/JsonParserTest.cs
+++ b/csharp/src/Google.Protobuf.Test/JsonParserTest.cs
@@ -124,7 +124,9 @@ namespace Google.Protobuf
[Test]
public void SingularWrappers_ExplicitNulls()
{
- var message = new TestWellKnownTypes();
+ // When we parse the "valueField": null part, we remember it... basically, it's one case
+ // where explicit default values don't fully roundtrip.
+ var message = new TestWellKnownTypes { ValueField = Value.ForNull() };
var json = new JsonFormatter(new JsonFormatter.Settings(true)).Format(message);
var parsed = JsonParser.Default.Parse<TestWellKnownTypes>(json);
Assert.AreEqual(message, parsed);
@@ -151,6 +153,14 @@ namespace Google.Protobuf
}
[Test]
+ public void ExplicitNullValue()
+ {
+ string json = "{\"valueField\": null}";
+ var message = JsonParser.Default.Parse<TestWellKnownTypes>(json);
+ Assert.AreEqual(new TestWellKnownTypes { ValueField = Value.ForNull() }, message);
+ }
+
+ [Test]
public void BytesWrapper_Standalone()
{
ByteString data = ByteString.CopyFrom(1, 2, 3);