mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 19:10:32 +00:00
Added string binary compat test
This commit is contained in:
parent
dc0e07a851
commit
98d6e667b0
@ -486,6 +486,22 @@ public void TestReadingTruncatedString()
|
|||||||
Assert.Throws<System.IO.EndOfStreamException>(() => reader.ReadString());
|
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]
|
[Test]
|
||||||
public void TestToArray()
|
public void TestToArray()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user