-Fixed potential error when writing escaped unicode character

This commit is contained in:
James Newton-King
2015-10-03 14:28:13 +13:00
parent ad68ea8780
commit a2f9acf917
2 changed files with 20 additions and 6 deletions
@@ -60,6 +60,18 @@ namespace Newtonsoft.Json.Tests
[TestFixture]
public class JsonConvertTest : TestFixtureBase
{
[Test]
public void ToStringEnsureEscapedArrayLength()
{
const char nonAsciiChar = (char)257;
const char escapableNonQuoteAsciiChar = '\0';
string value = nonAsciiChar + @"\" + escapableNonQuoteAsciiChar;
string convertedValue = JsonConvert.ToString((object)value);
Assert.AreEqual(@"""" + nonAsciiChar + @"\\\u0000""", convertedValue);
}
public class PopulateTestObject
{
public decimal Prop { get; set; }