forked from mirror/DotRecast
fix: random size of an array for testing could be 0
This commit is contained in:
parent
0d4344dabb
commit
96e8b12772
|
@ -29,7 +29,7 @@ public class RcRentedArrayTest
|
||||||
{
|
{
|
||||||
RcRentedArray<int> rentedArray;
|
RcRentedArray<int> rentedArray;
|
||||||
{
|
{
|
||||||
int length = (int)(rand.Next() * 2048);
|
int length = Math.Max(2, (int)(rand.Next() * 2048));
|
||||||
var values = RandomValues(length);
|
var values = RandomValues(length);
|
||||||
using var array = RcRentedArray.RentDisposableArray<int>(length);
|
using var array = RcRentedArray.RentDisposableArray<int>(length);
|
||||||
|
|
||||||
|
@ -44,12 +44,12 @@ public class RcRentedArrayTest
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.That(array[^1], Is.EqualTo(values[^1]));
|
Assert.That(array[^1], Is.EqualTo(values[^1]));
|
||||||
|
|
||||||
Assert.Throws<IndexOutOfRangeException>(() => array[-1] = 0);
|
Assert.Throws<IndexOutOfRangeException>(() => array[-1] = 0);
|
||||||
Assert.Throws<IndexOutOfRangeException>(() => array[array.Length + 1] = 0);
|
Assert.Throws<IndexOutOfRangeException>(() => array[array.Length + 1] = 0);
|
||||||
Assert.Throws<IndexOutOfRangeException>(() => _ = array[-1]);
|
Assert.Throws<IndexOutOfRangeException>(() => _ = array[-1]);
|
||||||
Assert.Throws<IndexOutOfRangeException>(() => _ = array[array.Length + 1]);
|
Assert.Throws<IndexOutOfRangeException>(() => _ = array[array.Length + 1]);
|
||||||
|
|
||||||
// danger
|
// danger
|
||||||
rentedArray = array;
|
rentedArray = array;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue