Merge branch 'patch-1' of https://github.com/Romasz/Newtonsoft.Json into Romasz-patch-1

This commit is contained in:
James Newton-King
2017-10-15 11:31:48 +13:00
3 changed files with 45 additions and 1 deletions
@@ -273,6 +273,46 @@ namespace Newtonsoft.Json.Tests.JsonTextReaderTests
Assert.AreEqual(JsonToken.EndObject, reader.TokenType);
}
[Test]
public void ReadLargeObjects()
{
const int nrItems = 2;
const int length = int.MaxValue / 3;
byte apostrophe = Encoding.ASCII.GetBytes(@"""").First();
byte openingBracket = Encoding.ASCII.GetBytes(@"[").First();
byte comma = Encoding.ASCII.GetBytes(@",").First();
byte closingBracket = Encoding.ASCII.GetBytes(@"]").First();
using (MemoryStream ms = new MemoryStream())
{
ms.WriteByte(openingBracket);
for (int i = 0; i < nrItems; i++)
{
ms.WriteByte(apostrophe);
for (int j = 0; j <= length; j++)
ms.WriteByte(7);
ms.WriteByte(apostrophe);
if (i < nrItems - 1)
ms.WriteByte(comma);
}
ms.WriteByte(closingBracket);
ms.Seek(0, SeekOrigin.Begin);
var reader = new JsonTextReader(new StreamReader(ms));
Assert.IsTrue(reader.Read());
for (int i = 0; i < nrItems; i++)
Assert.IsTrue(reader.Read());
Assert.IsTrue(reader.Read());
Assert.IsFalse(reader.Read());
}
}
[Test]
public void ReadSingleBytes()
{