|
69 | 69 |
|
70 | 70 | @testset "Cell Coordinates Hash Function" begin |
71 | 71 | # 1D coordinates |
72 | | - @test coordinates_hash((1)) == UInt128(reinterpret(UInt32, Int32(1))) |
73 | | - @test coordinates_hash((-1)) == UInt128(reinterpret(UInt32, Int32(-1))) |
74 | | - @test coordinates_hash((0)) == Int128(0) |
| 72 | + @test coordinates_hash([1]) == UInt128(reinterpret(UInt32, Int32(1))) |
| 73 | + @test coordinates_hash([-1]) == UInt128(reinterpret(UInt32, Int32(-1))) |
| 74 | + @test coordinates_hash([0]) == Int128(0) |
75 | 75 |
|
76 | 76 | # 2D coordinates |
77 | | - coord2 = (-1, 1) |
| 77 | + coord2 = [-1, 1] |
78 | 78 | hash2 = (UInt128(reinterpret(UInt32, Int32(coord2[2]))) << 32) | |
79 | 79 | UInt128(reinterpret(UInt32, Int32(coord2[1]))) |
80 | 80 | @test coordinates_hash(coord2) == hash2 |
81 | 81 |
|
82 | 82 | # 3D coordinates |
83 | | - coord3 = (1, 0, -1) |
| 83 | + coord3 = [1, 0, -1] |
84 | 84 | hash3 = (UInt128(reinterpret(UInt32, Int32(coord3[3]))) << 64) | |
85 | 85 | (UInt128(reinterpret(UInt32, Int32(coord3[2]))) << 32) | |
86 | 86 | UInt128(reinterpret(UInt32, Int32(coord3[1]))) |
|
93 | 93 | @test coordinates_hash((min_val)) == UInt128(reinterpret(UInt32, min_val)) |
94 | 94 |
|
95 | 95 | # 3D extreme Int32 bounds |
96 | | - coord_ex = (min_val, max_val, Int32(0)) |
| 96 | + coord_ex = [min_val, max_val, Int32(0)] |
97 | 97 | hash_ex = (UInt128(reinterpret(UInt32, coord_ex[3])) << (2*32)) | |
98 | 98 | (UInt128(reinterpret(UInt32, coord_ex[2])) << 32) | |
99 | 99 | UInt128(reinterpret(UInt32, coord_ex[1])) |
|
106 | 106 | small_val = typemin(Int32) - 1 |
107 | 107 | @test_throws InexactError coordinates_hash([small_val]) |
108 | 108 |
|
| 109 | + @test_throws InexactError coordinates_hash([Inf]) |
| 110 | + @test_throws InexactError coordinates_hash([NaN]) |
| 111 | + |
109 | 112 | # Too many dimensions should throw assertion |
110 | 113 | @test_throws AssertionError coordinates_hash([1, 2, 3, 4]) |
111 | 114 | end |
|
0 commit comments