@@ -7,6 +7,64 @@ using UnsafeArrays
7
7
8
8
9
9
@testset " vector_of_arrays" begin
10
+ ref_AoA1 (T:: Type , n:: Integer ) = n == 0 ? [Array {T} (undef, 5 )][1 : 0 ] : [rand (T, rand (1 : 9 )) for i in 1 : n]
11
+ ref_AoA2 (T:: Type , n:: Integer ) = n == 0 ? [Array {T} (undef, 4 , 2 )][1 : 0 ] : [rand (T, rand (1 : 4 ), rand (1 : 4 )) for i in 1 : n]
12
+ ref_AoA3 (T:: Type , n:: Integer ) = n == 0 ? [Array {T} (undef, 3 , 2 , 4 )][1 : 0 ] : [rand (T, rand (1 : 3 ), rand (1 : 3 ), rand (1 : 3 )) for i in 1 : n]
13
+
14
+
15
+ @testset " ctors" begin
16
+ A1 = ref_AoA1 (Float32, 5 )
17
+ @test @inferred (VectorOfArrays (deepcopy (A1))) isa VectorOfArrays{Float32,1 ,0 ,Array{Float32,1 },Array{Int64,1 },Array{Tuple{},1 }}
18
+ @test VectorOfArrays (deepcopy (A1)) == A1
19
+ @test @inferred (VectorOfArrays {Float64} (deepcopy (A1))) isa VectorOfArrays{Float64,1 ,0 ,Array{Float64,1 },Array{Int64,1 },Array{Tuple{},1 }}
20
+ @test VectorOfArrays {Float64} (deepcopy (A1)) == A1
21
+ @test @inferred (VectorOfArrays {Float64,1} (deepcopy (A1))) isa VectorOfArrays{Float64,1 ,0 ,Array{Float64,1 },Array{Int64,1 },Array{Tuple{},1 }}
22
+ @test VectorOfArrays {Float64,1} (deepcopy (A1)) == A1
23
+
24
+ @test @inferred (VectorOfVectors (deepcopy (A1))) isa VectorOfArrays{Float32,1 ,0 ,Array{Float32,1 },Array{Int64,1 },Array{Tuple{},1 }}
25
+ @test VectorOfVectors (deepcopy (A1)) == A1
26
+ @test @inferred (VectorOfVectors {Float64} (deepcopy (A1))) isa VectorOfArrays{Float64,1 ,0 ,Array{Float64,1 },Array{Int64,1 },Array{Tuple{},1 }}
27
+ @test VectorOfVectors {Float64} (deepcopy (A1)) == A1
28
+
29
+ A1_empty = ref_AoA1 (Float32, 0 )
30
+ @test @inferred (VectorOfArrays (deepcopy (A1_empty))) isa VectorOfArrays{Float32,1 ,0 ,Array{Float32,1 },Array{Int64,1 },Array{Tuple{},1 }}
31
+ @test VectorOfArrays (deepcopy (A1_empty)) == A1_empty
32
+ @test @inferred (VectorOfArrays {Float64} (deepcopy (A1_empty))) isa VectorOfArrays{Float64,1 ,0 ,Array{Float64,1 },Array{Int64,1 },Array{Tuple{},1 }}
33
+ @test VectorOfArrays {Float64} (deepcopy (A1_empty)) == A1_empty
34
+ @test @inferred (VectorOfArrays {Float64,1} (deepcopy (A1_empty))) isa VectorOfArrays{Float64,1 ,0 ,Array{Float64,1 },Array{Int64,1 },Array{Tuple{},1 }}
35
+ @test VectorOfArrays {Float64,1} (deepcopy (A1_empty)) == A1_empty
36
+
37
+ @test @inferred (VectorOfVectors (deepcopy (A1_empty))) isa VectorOfArrays{Float32,1 ,0 ,Array{Float32,1 },Array{Int64,1 },Array{Tuple{},1 }}
38
+ @test VectorOfVectors (deepcopy (A1_empty)) == A1_empty
39
+ @test @inferred (VectorOfVectors {Float64} (deepcopy (A1_empty))) isa VectorOfArrays{Float64,1 ,0 ,Array{Float64,1 },Array{Int64,1 },Array{Tuple{},1 }}
40
+ @test VectorOfVectors {Float64} (deepcopy (A1_empty)) == A1_empty
41
+
42
+ A2 = ref_AoA2 (Float32, 4 )
43
+ @test @inferred (VectorOfArrays (deepcopy (A2))) isa VectorOfArrays{Float32,2 ,1 ,Array{Float32,1 },Array{Int64,1 },Array{Tuple{Int64},1 }}
44
+ @test VectorOfArrays (deepcopy (A2)) == A2
45
+ @test @inferred (VectorOfArrays {Float64} (deepcopy (A2))) isa VectorOfArrays{Float64,2 ,1 ,Array{Float64,1 },Array{Int64,1 },Array{Tuple{Int64},1 }}
46
+ @test VectorOfArrays {Float64} (deepcopy (A2)) == A2
47
+ @test @inferred (VectorOfArrays {Float64,2} (deepcopy (A2))) isa VectorOfArrays{Float64,2 ,1 ,Array{Float64,1 },Array{Int64,1 },Array{Tuple{Int64},1 }}
48
+ @test VectorOfArrays {Float64,2} (deepcopy (A2)) == A2
49
+
50
+ A3 = ref_AoA3 (Float32, 3 )
51
+ @test @inferred (VectorOfArrays (deepcopy (A3))) isa VectorOfArrays{Float32,3 ,2 ,Array{Float32,1 },Array{Int64,1 },Array{Tuple{Int64,Int64},1 }}
52
+ @test VectorOfArrays (deepcopy (A3)) == A3
53
+ @test @inferred (VectorOfArrays {Float64} (deepcopy (A3))) isa VectorOfArrays{Float64,3 ,2 ,Array{Float64,1 },Array{Int64,1 },Array{Tuple{Int64,Int64},1 }}
54
+ @test VectorOfArrays {Float64} (deepcopy (A3)) == A3
55
+ @test @inferred (VectorOfArrays {Float64,3} (deepcopy (A3))) isa VectorOfArrays{Float64,3 ,2 ,Array{Float64,1 },Array{Int64,1 },Array{Tuple{Int64,Int64},1 }}
56
+ @test VectorOfArrays {Float64,3} (deepcopy (A3)) == A3
57
+
58
+ A3_empty = ref_AoA3 (Float32, 0 )
59
+ @test @inferred (VectorOfArrays (deepcopy (A3_empty))) isa VectorOfArrays{Float32,3 ,2 ,Array{Float32,1 },Array{Int64,1 },Array{Tuple{Int64,Int64},1 }}
60
+ @test VectorOfArrays (deepcopy (A3_empty)) == A3_empty
61
+ @test @inferred (VectorOfArrays {Float64} (deepcopy (A3_empty))) isa VectorOfArrays{Float64,3 ,2 ,Array{Float64,1 },Array{Int64,1 },Array{Tuple{Int64,Int64},1 }}
62
+ @test VectorOfArrays {Float64} (deepcopy (A3_empty)) == A3_empty
63
+ @test @inferred (VectorOfArrays {Float64,3} (deepcopy (A3_empty))) isa VectorOfArrays{Float64,3 ,2 ,Array{Float64,1 },Array{Int64,1 },Array{Tuple{Int64,Int64},1 }}
64
+ @test VectorOfArrays {Float64,3} (deepcopy (A3_empty)) == A3_empty
65
+ end
66
+
67
+
10
68
@testset " examples" begin
11
69
VA = VectorOfArrays {Float64, 2} ()
12
70
0 commit comments