Added string binary compat test

This commit is contained in:
Rodol Phito 2019-04-08 11:20:19 -07:00 committed by Paul Pacheco
parent dc0e07a851
commit 98d6e667b0

View File

@ -486,6 +486,22 @@ public void TestReadingTruncatedString()
Assert.Throws<System.IO.EndOfStreamException>(() => reader.ReadString());
}
[Test]
public void TestStringBinaryCompat()
{
NetworkWriter writer = new NetworkWriter();
writer.Write("");
writer.Write("short string");
writer.Write(string.Join("0", new string[100000]));
byte[] data = writer.ToArray();
byte[] expect = new byte[]{1,0,1,12,115,104,111,114,116,32,115,116,114,105,110,103,1,159,141,6};
Assert.That(data.Length, Is.EqualTo(100019));
for (int i = 0; i < expect.Length; i++)
Assert.That(data[i], Is.EqualTo(expect[i]), $"index {i}");
for (int i = expect.Length; i < data.Length; i++)
Assert.That(data[i], Is.EqualTo(48), $"index {i}");
}
[Test]
public void TestToArray()
{