Skip to content

Commit 9edc93d

Browse files
committed
CSHARP-2305: Added more tests.
1 parent 1db6945 commit 9edc93d

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

tests/MongoDB.Bson.Tests/IO/JsonReaderTests.cs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,9 +526,9 @@ public void TestInt32()
526526
}
527527

528528
[Theory]
529-
[InlineData("{ $numberInt: 1 }", 1)]
530-
[InlineData("{ $numberInt: -2147483648 }", -2147483648)]
531-
[InlineData("{ $numberInt: 2147483647 }", 2147483647)]
529+
[InlineData("{ $numberInt : 1 }", 1)]
530+
[InlineData("{ $numberInt : -2147483648 }", -2147483648)]
531+
[InlineData("{ $numberInt : 2147483647 }", 2147483647)]
532532
public void TestInt32ExtendedJson(string json, int expectedResult)
533533
{
534534
using (var reader = new JsonReader(json))
@@ -540,6 +540,25 @@ public void TestInt32ExtendedJson(string json, int expectedResult)
540540
}
541541
}
542542

543+
[Theory]
544+
// truncated input
545+
[InlineData("{ $numberInt")]
546+
[InlineData("{ $numberInt :")]
547+
[InlineData("{ $numberInt : 1")]
548+
// invalid extended json
549+
[InlineData("{ $numberInt ,")]
550+
[InlineData("{ $numberInt : \"abc\"")]
551+
[InlineData("{ $numberInt : 1,")]
552+
public void TestInt32ExtendedJsonInvalid(string json)
553+
{
554+
using (var reader = new JsonReader(json))
555+
{
556+
var execption = Record.Exception(() => reader.ReadInt32());
557+
558+
execption.Should().BeOfType<FormatException>();
559+
}
560+
}
561+
543562
[Theory]
544563
[InlineData("Number(123)")]
545564
[InlineData("NumberInt(123)")]

0 commit comments

Comments
 (0)