diff options
Diffstat (limited to 'csharp/src/Google.Protobuf.Test')
-rw-r--r-- | csharp/src/Google.Protobuf.Test/JsonParserTest.cs | 44 | ||||
-rw-r--r-- | csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs | 4 |
2 files changed, 24 insertions, 24 deletions
diff --git a/csharp/src/Google.Protobuf.Test/JsonParserTest.cs b/csharp/src/Google.Protobuf.Test/JsonParserTest.cs index b1c7b46c..29b3088c 100644 --- a/csharp/src/Google.Protobuf.Test/JsonParserTest.cs +++ b/csharp/src/Google.Protobuf.Test/JsonParserTest.cs @@ -370,19 +370,19 @@ namespace Google.Protobuf } [Test] - [TestCase("+0")] - [TestCase("00")] - [TestCase("-00")] - [TestCase("--1")] - [TestCase("+1")] - [TestCase("1.5", Ignore = true, Reason = "Desired behaviour unclear")] - [TestCase("1e10")] - [TestCase("2147483648")] - [TestCase("-2147483649")] - public void NumberToInt32_Invalid(string jsonValue) + [TestCase("+0", typeof(InvalidJsonException))] + [TestCase("00", typeof(InvalidJsonException))] + [TestCase("-00", typeof(InvalidJsonException))] + [TestCase("--1", typeof(InvalidJsonException))] + [TestCase("+1", typeof(InvalidJsonException))] + [TestCase("1.5", typeof(InvalidProtocolBufferException), Ignore = true, Reason = "Desired behaviour unclear")] + [TestCase("1e10", typeof(InvalidProtocolBufferException))] + [TestCase("2147483648", typeof(InvalidProtocolBufferException))] + [TestCase("-2147483649", typeof(InvalidProtocolBufferException))] + public void NumberToInt32_Invalid(string jsonValue, System.Type expectedExceptionType) { string json = "{ \"singleInt32\": " + jsonValue + "}"; - Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json)); + Assert.Throws(expectedExceptionType, () => TestAllTypes.Parser.ParseJson(json)); } [Test] @@ -486,7 +486,7 @@ namespace Google.Protobuf public void NumberToDouble_Invalid(string jsonValue) { string json = "{ \"singleDouble\": " + jsonValue + "}"; - Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json)); + Assert.Throws<InvalidJsonException>(() => TestAllTypes.Parser.ParseJson(json)); } [Test] @@ -506,17 +506,17 @@ namespace Google.Protobuf } [Test] - [TestCase("3.402824e38")] - [TestCase("-3.402824e38")] - [TestCase("1,0")] - [TestCase("1.0.0")] - [TestCase("+1")] - [TestCase("00")] - [TestCase("--1")] - public void NumberToFloat_Invalid(string jsonValue) + [TestCase("3.402824e38", typeof(InvalidProtocolBufferException))] + [TestCase("-3.402824e38", typeof(InvalidProtocolBufferException))] + [TestCase("1,0", typeof(InvalidJsonException))] + [TestCase("1.0.0", typeof(InvalidJsonException))] + [TestCase("+1", typeof(InvalidJsonException))] + [TestCase("00", typeof(InvalidJsonException))] + [TestCase("--1", typeof(InvalidJsonException))] + public void NumberToFloat_Invalid(string jsonValue, System.Type expectedExceptionType) { string json = "{ \"singleFloat\": " + jsonValue + "}"; - Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json)); + Assert.Throws(expectedExceptionType, () => TestAllTypes.Parser.ParseJson(json)); } // The simplest way of testing that the value has parsed correctly is to reformat it, @@ -721,7 +721,7 @@ namespace Google.Protobuf public void DataAfterObject() { string json = "{} 10"; - Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json)); + Assert.Throws<InvalidJsonException>(() => TestAllTypes.Parser.ParseJson(json)); } } } diff --git a/csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs b/csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs index 868d9f75..1b3c8e9f 100644 --- a/csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs +++ b/csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs @@ -223,7 +223,7 @@ namespace Google.Protobuf { Assert.IsNotNull(tokenizer.Next()); } - Assert.Throws<InvalidProtocolBufferException>(() => tokenizer.Next()); + Assert.Throws<InvalidJsonException>(() => tokenizer.Next()); } [Test] @@ -346,7 +346,7 @@ namespace Google.Protobuf } Assert.AreEqual(expectedTokens[i], actualToken); } - Assert.Throws<InvalidProtocolBufferException>(() => tokenizer.Next()); + Assert.Throws<InvalidJsonException>(() => tokenizer.Next()); } } } |