Skip to content

Commit 59826fb

Browse files
committed
Position should be reset if length is too small
1 parent 0d0ef77 commit 59826fb

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

MLAPI.Tests/NetworkingManagerComponents/Binary/BitStreamTest.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,30 @@ public void TestBool()
2727
Assert.That(bitStream.Length, Is.EqualTo(100));
2828
}
2929

30+
[Test]
31+
public void TestSetLength()
32+
{
33+
BitStream bitStream = new BitStream(4);
34+
bitStream.SetLength(100);
35+
36+
Assert.That(bitStream.Capacity, Is.GreaterThanOrEqualTo(100));
37+
}
38+
39+
[Test]
40+
public void TestSetLength2()
41+
{
42+
BitStream bitStream = new BitStream(4);
43+
44+
bitStream.WriteByte(1);
45+
bitStream.WriteByte(1);
46+
bitStream.WriteByte(1);
47+
bitStream.WriteByte(1);
48+
49+
bitStream.SetLength(0);
50+
51+
Assert.That(bitStream.Position, Is.EqualTo(0));
52+
}
53+
3054
[Test]
3155
public void TestGrow()
3256
{

0 commit comments

Comments
 (0)