mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-17 18:40:33 +00:00
GrowCapacity test
This commit is contained in:
parent
d43cd0b68d
commit
38d28e7d54
@ -97,5 +97,31 @@ public void ShrinkCapacity()
|
||||
Assert.That(c, !Is.Null);
|
||||
Assert.That(c == a || c == b);
|
||||
}
|
||||
|
||||
// if we grow the capacity, things should still work fine
|
||||
[Test]
|
||||
public void GrowCapacity()
|
||||
{
|
||||
NetworkWriterPool.Capacity = 1;
|
||||
|
||||
// create and recycle one
|
||||
PooledNetworkWriter a = NetworkWriterPool.GetWriter();
|
||||
NetworkWriterPool.Recycle(a);
|
||||
|
||||
// grow capacity
|
||||
NetworkWriterPool.Capacity = 2;
|
||||
|
||||
// get two
|
||||
PooledNetworkWriter b = NetworkWriterPool.GetWriter();
|
||||
PooledNetworkWriter c = NetworkWriterPool.GetWriter();
|
||||
Assert.That(b, !Is.Null);
|
||||
Assert.That(c, !Is.Null);
|
||||
|
||||
// exactly one should be reused, one should be new
|
||||
bool bReused = b == a;
|
||||
bool cReused = c == a;
|
||||
Assert.That(( bReused && !cReused) ||
|
||||
(!bReused && cReused));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user