@@ -6,13 +6,14 @@ namespace VoltstroStudios.NativeArraySpanExtensions.Tests
66{
77 public class NativeSliceExtensionsTests
88 {
9- [ GenericTestCase ( typeof ( byte ) , new byte [ ] { 1 , 4 , 6 , 7 , 54 , 98 } ) ]
10- [ GenericTestCase ( typeof ( int ) , new [ ] { 54 , 76 , 129 , 7000 , 438 , 57 , 192 , 69 } ) ]
11- [ GenericTestCase ( typeof ( float ) , new [ ] { 0.0002456f , 69.420f , 23f , 90032.2f , 47.6f } ) ]
9+ [ GenericTestCase ( typeof ( byte ) , new byte [ ] { 1 , 4 , 6 , 7 , 54 , 98 } ) ]
10+ [ GenericTestCase ( typeof ( int ) , new [ ] { 54 , 76 , 129 , 7000 , 438 , 57 , 192 , 69 } ) ]
11+ [ GenericTestCase ( typeof ( float ) , new [ ] { 0.0002456f , 69.420f , 23f , 90032.2f , 47.6f } ) ]
1212 public void CopyFromTest < T > ( T [ ] testData )
1313 where T : unmanaged
1414 {
15- NativeArray < T > testNativeArray = new ( testData . Length , Allocator . Temp , NativeArrayOptions . UninitializedMemory ) ;
15+ NativeArray < T > testNativeArray =
16+ new ( testData . Length , Allocator . Temp , NativeArrayOptions . UninitializedMemory ) ;
1617 NativeSlice < T > testNativeSlice = testNativeArray . Slice ( ) ;
1718
1819 try
@@ -21,24 +22,24 @@ public void CopyFromTest<T>(T[] testData)
2122
2223 Span < T > testSpan = testData ;
2324 testNativeSlice . CopyFrom ( testSpan ) ;
24-
25+
2526 ValidateArrays ( testNativeSlice , testSpan ) ;
2627 }
2728 finally
2829 {
2930 testNativeArray . Dispose ( ) ;
3031 }
3132 }
32-
33- [ GenericTestCase ( typeof ( byte ) , new byte [ ] { 1 , 4 , 6 , 7 , 54 , 98 } ) ]
34- [ GenericTestCase ( typeof ( int ) , new [ ] { 54 , 76 , 129 , 7000 , 438 , 57 , 192 , 69 } ) ]
35- [ GenericTestCase ( typeof ( float ) , new [ ] { 0.0002456f , 69.420f , 23f , 90032.2f , 47.6f } ) ]
33+
34+ [ GenericTestCase ( typeof ( byte ) , new byte [ ] { 1 , 4 , 6 , 7 , 54 , 98 } ) ]
35+ [ GenericTestCase ( typeof ( int ) , new [ ] { 54 , 76 , 129 , 7000 , 438 , 57 , 192 , 69 } ) ]
36+ [ GenericTestCase ( typeof ( float ) , new [ ] { 0.0002456f , 69.420f , 23f , 90032.2f , 47.6f } ) ]
3637 public void CopyTo < T > ( T [ ] testData )
3738 where T : unmanaged
3839 {
3940 NativeArray < T > testNativeArray = new ( testData , Allocator . Temp ) ;
4041 NativeSlice < T > testNativeSlice = testNativeArray . Slice ( ) ;
41-
42+
4243 try
4344 {
4445 Assert . IsTrue ( testNativeArray . IsCreated ) ;
@@ -53,15 +54,12 @@ public void CopyTo<T>(T[] testData)
5354 testNativeArray . Dispose ( ) ;
5455 }
5556 }
56-
57+
5758 private static void ValidateArrays < T > ( NativeSlice < T > nativeArray , ReadOnlySpan < T > span )
5859 where T : unmanaged
5960 {
6061 Assert . AreEqual ( nativeArray . Length , span . Length ) ;
61- for ( int i = 0 ; i < nativeArray . Length ; i ++ )
62- {
63- Assert . AreEqual ( nativeArray [ i ] , span [ i ] ) ;
64- }
62+ for ( int i = 0 ; i < nativeArray . Length ; i ++ ) Assert . AreEqual ( nativeArray [ i ] , span [ i ] ) ;
6563 }
6664 }
6765}
0 commit comments