aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/Google.Protobuf.Test
diff options
context:
space:
mode:
authorJon Skeet <jonskeet@google.com>2016-01-15 12:02:07 +0000
committerJon Skeet <jonskeet@google.com>2016-01-15 12:02:07 +0000
commitf437b67f600545f432863457a39870cb74675d34 (patch)
tree608f813163899f678c04726117f36a006199b332 /csharp/src/Google.Protobuf.Test
parent022a9b267561a3fccfcfaa7023779b969692bf74 (diff)
downloadprotobuf-f437b67f600545f432863457a39870cb74675d34.tar.gz
protobuf-f437b67f600545f432863457a39870cb74675d34.tar.bz2
protobuf-f437b67f600545f432863457a39870cb74675d34.zip
Extra strictness for FieldMask conversion
Diffstat (limited to 'csharp/src/Google.Protobuf.Test')
-rw-r--r--csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs10
-rw-r--r--csharp/src/Google.Protobuf.Test/JsonParserTest.cs8
2 files changed, 18 insertions, 0 deletions
diff --git a/csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs b/csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs
index 09308556..98b00f46 100644
--- a/csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs
+++ b/csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs
@@ -418,6 +418,16 @@ namespace Google.Protobuf
}
[Test]
+ [TestCase("foo__bar")]
+ [TestCase("foo_3_ar")]
+ [TestCase("fooBar")]
+ public void FieldMaskInvalid(string input)
+ {
+ var mask = new FieldMask { Paths = { input } };
+ Assert.Throws<InvalidOperationException>(() => JsonFormatter.Default.Format(mask));
+ }
+
+ [Test]
public void FieldMaskStandalone()
{
var fieldMask = new FieldMask { Paths = { "", "single", "with_underscore", "nested.field.name", "nested..double_dot" } };
diff --git a/csharp/src/Google.Protobuf.Test/JsonParserTest.cs b/csharp/src/Google.Protobuf.Test/JsonParserTest.cs
index aa090d12..e8666b36 100644
--- a/csharp/src/Google.Protobuf.Test/JsonParserTest.cs
+++ b/csharp/src/Google.Protobuf.Test/JsonParserTest.cs
@@ -779,6 +779,14 @@ namespace Google.Protobuf
}
[Test]
+ [TestCase("foo_bar")]
+ public void FieldMask_Invalid(string jsonValue)
+ {
+ string json = WrapInQuotes(jsonValue);
+ Assert.Throws<InvalidProtocolBufferException>(() => FieldMask.Parser.ParseJson(json));
+ }
+
+ [Test]
public void Any_RegularMessage()
{
var registry = TypeRegistry.FromMessages(TestAllTypes.Descriptor);