-Fixed JSON string encoder not getting buffer from buffer pool
This commit is contained in:
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user