-Tests
This commit is contained in:
@@ -1249,6 +1249,37 @@ third line", jsonTextReader.Value);
|
|||||||
Assert.AreEqual(6, arrayPool.FreeArrays.Count);
|
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]
|
[Test]
|
||||||
public void ReadNullTerminatorStrings()
|
public void ReadNullTerminatorStrings()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -100,6 +100,42 @@ namespace Newtonsoft.Json.Tests
|
|||||||
Assert.AreEqual(3, arrayPool.FreeArrays.Count);
|
Assert.AreEqual(3, arrayPool.FreeArrays.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void BufferTest_WithError()
|
||||||
|
{
|
||||||
|
JsonTextReaderTest.FakeArrayPool arrayPool = new JsonTextReaderTest.FakeArrayPool();
|
||||||
|
|
||||||
|
StringWriter sw = new StringWriter(CultureInfo.InvariantCulture);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// dispose will free used buffers
|
||||||
|
using (JsonTextWriter writer = new JsonTextWriter(sw))
|
||||||
|
{
|
||||||
|
writer.ArrayPool = arrayPool;
|
||||||
|
|
||||||
|
writer.WriteStartObject();
|
||||||
|
|
||||||
|
writer.WritePropertyName("Prop1");
|
||||||
|
writer.WriteValue(new DateTime(2000, 12, 12, 12, 12, 12, DateTimeKind.Utc));
|
||||||
|
|
||||||
|
writer.WritePropertyName("Prop2");
|
||||||
|
writer.WriteValue("This is an escaped \n string!");
|
||||||
|
|
||||||
|
writer.WriteValue("Error!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Assert.Fail();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.AreEqual(0, arrayPool.UsedArrays.Count);
|
||||||
|
Assert.AreEqual(1, arrayPool.FreeArrays.Count);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void NewLine()
|
public void NewLine()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user