Merge pull request #1689 from ousttrue/fix/nativearray_DisposeTest

[UnitTest] NativeArray の挙動変化に追随
This commit is contained in:
ousttrue 2022-06-13 15:17:58 +09:00 committed by GitHub
commit b8841855bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,6 +6,26 @@ namespace UniGLTF
{
public class NativeArrayTests
{
#if UNITY_2020_3_OR_NEWER
[Test]
public void DisposeTest()
{
var array = new NativeArray<byte>(64, Allocator.Persistent);
var sub = array.GetSubArray(10, 4);
// SubArray の Dispose が可能になった ! (Unity-2020.3)
// Assert.Throws<InvalidOperationException>(() => { sub.Dispose(); });
var cast = array.Reinterpret<int>(1);
// Dispose可能
cast.Dispose();
// ObjectDisposedException に変わった ! (Unity-2020.3)
Assert.Throws<ObjectDisposedException>(() => { var c = cast[0]; });
Assert.Throws<ObjectDisposedException>(() => { var a = array[0]; });
Assert.Throws<ObjectDisposedException>(() => { var s = sub[0]; });
}
#else
[Test]
public void DisposeTest()
{
@ -22,5 +42,6 @@ namespace UniGLTF
Assert.Throws<InvalidOperationException>(() => { var a = array[0]; });
Assert.Throws<InvalidOperationException>(() => { var s = sub[0]; });
}
#endif
}
}