public void RentTest() { using (var rent = new Rent <byte>(100)) { Assert.True(rent.Array != null && rent.Array.Length >= rent.Length); Assert.Catch <IndexOutOfRangeException>(() => { int _ = rent[100]; }); } using (var rent = new Rent <byte>(1000)) { Assert.True(rent.Array != null && rent.Array.Length >= rent.Length); } using (var rent = new Rent <byte>(0)) { Assert.True(rent.Array != null && rent.Array.Length == 0); } using (var rent = Rent.Empty <byte>()) { Assert.True(rent.Array != null && rent.Array.Length == 0); } var rent2 = new UniqueRef <string>(200, true); Assert.True(rent2.Array != null && rent2.Array.Length >= rent2.Length); string[] rent2Array = rent2.Array; rent2.Dispose(); Assert.Catch <IndexOutOfRangeException>(() => { string _ = rent2[0]; }); Assert.Catch <ObjectDisposedException>(() => { var _ = rent2.Array; }); Assert.True(rent2Array[0] == null); }