diff --git a/Assets/Mirror/Tests/NetworkWriterTest.cs b/Assets/Mirror/Tests/NetworkWriterTest.cs index e6d48d45d..e1520f784 100644 --- a/Assets/Mirror/Tests/NetworkWriterTest.cs +++ b/Assets/Mirror/Tests/NetworkWriterTest.cs @@ -486,6 +486,22 @@ public void TestReadingTruncatedString() Assert.Throws(() => 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() {