From 96e8b12772778f1a6e02fd60e0633f96829c9cf1 Mon Sep 17 00:00:00 2001 From: ikpil Date: Sun, 21 Jan 2024 19:53:00 +0900 Subject: [PATCH] fix: random size of an array for testing could be 0 --- test/DotRecast.Core.Test/RcRentedArrayTest.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/DotRecast.Core.Test/RcRentedArrayTest.cs b/test/DotRecast.Core.Test/RcRentedArrayTest.cs index 48a1cd2..b099ffa 100644 --- a/test/DotRecast.Core.Test/RcRentedArrayTest.cs +++ b/test/DotRecast.Core.Test/RcRentedArrayTest.cs @@ -29,7 +29,7 @@ public class RcRentedArrayTest { RcRentedArray rentedArray; { - int length = (int)(rand.Next() * 2048); + int length = Math.Max(2, (int)(rand.Next() * 2048)); var values = RandomValues(length); using var array = RcRentedArray.RentDisposableArray(length); @@ -44,12 +44,12 @@ public class RcRentedArrayTest } Assert.That(array[^1], Is.EqualTo(values[^1])); - + Assert.Throws(() => array[-1] = 0); Assert.Throws(() => array[array.Length + 1] = 0); Assert.Throws(() => _ = array[-1]); Assert.Throws(() => _ = array[array.Length + 1]); - + // danger rentedArray = array; }