-Fixed not throwing JsonReaderException when parsing certain invalid numbers

This commit is contained in:
James Newton-King
2014-06-15 01:30:21 +12:00
parent af102d637f
commit f0c79cd0ea
5 changed files with 59 additions and 16 deletions
@@ -47,6 +47,27 @@ namespace Newtonsoft.Json.Tests
[TestFixture]
public class JsonTextReaderTest : TestFixtureBase
{
[Test]
public void ReadInvalidNonBase10Number()
{
string json = "0aq2dun13.hod";
JsonTextReader reader = new JsonTextReader(new StringReader(json));
ExceptionAssert.Throws<JsonReaderException>("Input string '0a' is not a valid number. Path '', line 1, position 2.",
() => { reader.Read(); });
reader = new JsonTextReader(new StringReader(json));
ExceptionAssert.Throws<JsonReaderException>("Input string '0a' is not a valid decimal. Path '', line 1, position 2.",
() => { reader.ReadAsDecimal(); });
reader = new JsonTextReader(new StringReader(json));
ExceptionAssert.Throws<JsonReaderException>("Input string '0a' is not a valid integer. Path '', line 1, position 2.",
() => { reader.ReadAsInt32(); });
}
[Test]
public void ThrowErrorWhenParsingUnquoteStringThatStartsWithNE()
{