This commit is contained in:
James Newton-King
2015-12-22 14:19:13 +13:00
parent 9c1dbfe44d
commit f2f87880be
2 changed files with 67 additions and 0 deletions
@@ -1249,6 +1249,37 @@ third line", jsonTextReader.Value);
Assert.AreEqual(6, arrayPool.FreeArrays.Count);
}
[Test]
public void BufferTest_WithError()
{
string json = @"{
""CPU"": ""Intel?\nYes"",
""Description"": ""Amazin";
FakeArrayPool arrayPool = new FakeArrayPool();
try
{
// dispose will free used buffers
using (JsonTextReader reader = new JsonTextReader(new StringReader(json)))
{
reader.ArrayPool = arrayPool;
while (reader.Read())
{
}
}
Assert.Fail();
}
catch
{
}
Assert.AreEqual(0, arrayPool.UsedArrays.Count);
Assert.AreEqual(2, arrayPool.FreeArrays.Count);
}
[Test]
public void ReadNullTerminatorStrings()
{