-Fixed JSON string encoder not getting buffer from buffer pool

This commit is contained in:
James Newton-King
2016-03-09 16:34:02 +13:00
parent 443462f9f2
commit 5ddbc508f0
5 changed files with 50 additions and 20 deletions
@@ -49,6 +49,7 @@ using NUnit.Framework;
using Newtonsoft.Json;
using System.IO;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Utilities;
namespace Newtonsoft.Json.Tests
@@ -136,6 +137,33 @@ namespace Newtonsoft.Json.Tests
Assert.AreEqual(1, arrayPool.FreeArrays.Count);
}
#if !(NET20 || NET35 || NET40 || NETFX_CORE || PORTABLE || PORTABLE40 || DNXCORE50)
[Test]
public void BufferErroringWithInvalidSize()
{
JObject o = new JObject
{
{"BodyHtml", "<h3>Title!</h3>" + Environment.NewLine + new string(' ', 100) + "<p>Content!</p>"}
};
JsonArrayPool arrayPool = new JsonArrayPool();
StringWriter sw = new StringWriter();
using (JsonTextWriter writer = new JsonTextWriter(sw))
{
writer.ArrayPool = arrayPool;
o.WriteTo(writer);
}
string result = o.ToString();
Assert.AreEqual(@"{
""BodyHtml"": ""<h3>Title!</h3>\r\n <p>Content!</p>""
}", result);
}
#endif
[Test]
public void NewLine()
{