Skip to content

Commit bf4d141

Browse files
Merge pull request #1913 from CliMA/ck/fixup_struct_tests
Fixup get_struct unit tests
2 parents feb7247 + c0f4c9a commit bf4d141

File tree

1 file changed

+70
-196
lines changed

1 file changed

+70
-196
lines changed

test/DataLayouts/unit_struct.jl

Lines changed: 70 additions & 196 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ using Revise; include(joinpath("test", "DataLayouts", "unit_struct.jl"))
44
=#
55
using Test
66
using ClimaCore.DataLayouts
7+
using ClimaCore.DataLayouts: get_struct
78
using StaticArrays
89

910
function one_to_n(a::Array)
@@ -14,49 +15,8 @@ function one_to_n(a::Array)
1415
end
1516
one_to_n(s::Tuple, ::Type{FT}) where {FT} = one_to_n(zeros(FT, s...))
1617
ncomponents(::Type{FT}, ::Type{S}) where {FT, S} = div(sizeof(S), sizeof(FT))
17-
18-
function test_get_struct(::Type{FT}, ::Type{S}) where {FT, S}
19-
s = (2,)
20-
a = one_to_n(s, FT)
21-
CI = CartesianIndices(map-> Base.OneTo(ξ), s))
22-
for (i, ci) in enumerate(CI)
23-
for j in 1:length(s)
24-
@test DataLayouts.get_struct(a, S, Val(j), ci) == FT(i)
25-
end
26-
end
27-
28-
s = (2, 3)
29-
a = one_to_n(s, FT)
30-
CI = CartesianIndices(map-> Base.OneTo(ξ), s))
31-
for (i, ci) in enumerate(CI)
32-
for j in 1:length(s)
33-
@test DataLayouts.get_struct(a, S, Val(j), ci) == FT(i)
34-
end
35-
end
36-
37-
s = (2, 3, 4)
38-
a = one_to_n(s, FT)
39-
CI = CartesianIndices(map-> Base.OneTo(ξ), s))
40-
for (i, ci) in enumerate(CI)
41-
for j in 1:length(s)
42-
@test DataLayouts.get_struct(a, S, Val(j), ci) == FT(i)
43-
end
44-
end
45-
46-
s = (2, 3, 4, 5)
47-
a = one_to_n(s, FT)
48-
CI = CartesianIndices(map-> Base.OneTo(ξ), s))
49-
for (i, ci) in enumerate(CI)
50-
for j in 1:length(s)
51-
@test DataLayouts.get_struct(a, S, Val(j), ci) == FT(i)
52-
end
53-
end
54-
end
55-
56-
@testset "get_struct - Float" begin
57-
test_get_struct(Float64, Float64)
58-
test_get_struct(Float32, Float32)
59-
end
18+
field_dim_to_one(s, dim) = Tuple(map(j-> j == dim ? 1 : s[j], 1:length(s)))
19+
CI(s) = CartesianIndices(map-> Base.OneTo(ξ), s))
6020

6121
struct Foo{T}
6222
x::T
@@ -65,175 +25,89 @@ end
6525

6626
Base.zero(::Type{Foo{T}}) where {T} = Foo{T}(0, 0)
6727

68-
@testset "get_struct - flat struct 2-fields 1-dim" begin
28+
@testset "get_struct - IFH indexing" begin
6929
FT = Float64
7030
S = Foo{FT}
71-
s = (4,)
72-
a = one_to_n(s, FT)
73-
CI = CartesianIndices(map-> Base.OneTo(ξ), s))
31+
s_array = (3, 2, 4)
7432
@test ncomponents(FT, S) == 2
75-
@test DataLayouts.get_struct(a, S, Val(1), CI[1]) == Foo{FT}(1.0, 2.0)
76-
@test DataLayouts.get_struct(a, S, Val(1), CI[2]) == Foo{FT}(2.0, 3.0)
77-
@test DataLayouts.get_struct(a, S, Val(1), CI[3]) == Foo{FT}(3.0, 4.0)
78-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(1), CI[4])
33+
s = field_dim_to_one(s_array, 2)
34+
a = one_to_n(s_array, FT)
35+
@test get_struct(a, S, Val(2), CI(s)[1]) == Foo{FT}(1.0, 4.0)
36+
@test get_struct(a, S, Val(2), CI(s)[2]) == Foo{FT}(2.0, 5.0)
37+
@test get_struct(a, S, Val(2), CI(s)[3]) == Foo{FT}(3.0, 6.0)
38+
@test get_struct(a, S, Val(2), CI(s)[4]) == Foo{FT}(7.0, 10.0)
39+
@test get_struct(a, S, Val(2), CI(s)[5]) == Foo{FT}(8.0, 11.0)
40+
@test get_struct(a, S, Val(2), CI(s)[6]) == Foo{FT}(9.0, 12.0)
41+
@test get_struct(a, S, Val(2), CI(s)[7]) == Foo{FT}(13.0, 16.0)
42+
@test get_struct(a, S, Val(2), CI(s)[8]) == Foo{FT}(14.0, 17.0)
43+
@test get_struct(a, S, Val(2), CI(s)[9]) == Foo{FT}(15.0, 18.0)
44+
@test get_struct(a, S, Val(2), CI(s)[10]) == Foo{FT}(19.0, 22.0)
45+
@test get_struct(a, S, Val(2), CI(s)[11]) == Foo{FT}(20.0, 23.0)
46+
@test get_struct(a, S, Val(2), CI(s)[12]) == Foo{FT}(21.0, 24.0)
47+
@test_throws BoundsError get_struct(a, S, Val(2), CI(s)[13])
7948
end
8049

81-
@testset "get_struct - flat struct 2-fields 3-dims" begin
50+
@testset "get_struct - IJF indexing" begin
8251
FT = Float64
8352
S = Foo{FT}
84-
s = (2, 3, 4)
85-
a = one_to_n(s, FT)
86-
CI = CartesianIndices(map-> Base.OneTo(ξ), s))
53+
s_array = (3, 4, 2)
8754
@test ncomponents(FT, S) == 2
88-
# Call get_struct, and span `a` (access elements to 24.0): 12 cases
89-
90-
# No datalayouts have field dim of 1
91-
@test DataLayouts.get_struct(a, S, Val(1), CI[1]) == Foo{FT}(1.0, 2.0)
92-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(1), CI[2])
93-
@test DataLayouts.get_struct(a, S, Val(1), CI[3]) == Foo{FT}(3.0, 4.0)
94-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(1), CI[4])
95-
@test DataLayouts.get_struct(a, S, Val(1), CI[5]) == Foo{FT}(5.0, 6.0)
96-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(1), CI[6])
97-
@test DataLayouts.get_struct(a, S, Val(1), CI[7]) == Foo{FT}(7.0, 8.0)
98-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(1), CI[8])
99-
@test DataLayouts.get_struct(a, S, Val(1), CI[9]) == Foo{FT}(9.0, 10.0)
100-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(1), CI[10])
101-
@test DataLayouts.get_struct(a, S, Val(1), CI[11]) == Foo{FT}(11.0, 12.0)
102-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(1), CI[12])
103-
@test DataLayouts.get_struct(a, S, Val(1), CI[13]) == Foo{FT}(13.0, 14.0)
104-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(1), CI[14])
105-
@test DataLayouts.get_struct(a, S, Val(1), CI[15]) == Foo{FT}(15.0, 16.0)
106-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(1), CI[16])
107-
@test DataLayouts.get_struct(a, S, Val(1), CI[17]) == Foo{FT}(17.0, 18.0)
108-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(1), CI[18])
109-
@test DataLayouts.get_struct(a, S, Val(1), CI[19]) == Foo{FT}(19.0, 20.0)
110-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(1), CI[20])
111-
@test DataLayouts.get_struct(a, S, Val(1), CI[21]) == Foo{FT}(21.0, 22.0)
112-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(1), CI[22])
113-
@test DataLayouts.get_struct(a, S, Val(1), CI[23]) == Foo{FT}(23.0, 24.0)
114-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(1), CI[24])
115-
116-
# e.g., how IFH is indexed (field dim 2)
117-
@test DataLayouts.get_struct(a, S, Val(2), CI[1]) == Foo{FT}(1.0, 3.0)
118-
@test DataLayouts.get_struct(a, S, Val(2), CI[2]) == Foo{FT}(2.0, 4.0)
119-
@test DataLayouts.get_struct(a, S, Val(2), CI[3]) == Foo{FT}(3.0, 5.0)
120-
@test DataLayouts.get_struct(a, S, Val(2), CI[4]) == Foo{FT}(4.0, 6.0)
121-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(2), CI[5])
122-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(2), CI[6])
123-
@test DataLayouts.get_struct(a, S, Val(2), CI[7]) == Foo{FT}(7.0, 9.0)
124-
@test DataLayouts.get_struct(a, S, Val(2), CI[8]) == Foo{FT}(8.0, 10.0)
125-
@test DataLayouts.get_struct(a, S, Val(2), CI[9]) == Foo{FT}(9.0, 11.0)
126-
@test DataLayouts.get_struct(a, S, Val(2), CI[10]) == Foo{FT}(10.0, 12.0)
127-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(2), CI[11])
128-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(2), CI[12])
129-
@test DataLayouts.get_struct(a, S, Val(2), CI[13]) == Foo{FT}(13.0, 15.0)
130-
@test DataLayouts.get_struct(a, S, Val(2), CI[14]) == Foo{FT}(14.0, 16.0)
131-
@test DataLayouts.get_struct(a, S, Val(2), CI[15]) == Foo{FT}(15.0, 17.0)
132-
@test DataLayouts.get_struct(a, S, Val(2), CI[16]) == Foo{FT}(16.0, 18.0)
133-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(2), CI[17])
134-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(2), CI[18])
135-
@test DataLayouts.get_struct(a, S, Val(2), CI[19]) == Foo{FT}(19.0, 21.0)
136-
@test DataLayouts.get_struct(a, S, Val(2), CI[20]) == Foo{FT}(20.0, 22.0)
137-
@test DataLayouts.get_struct(a, S, Val(2), CI[21]) == Foo{FT}(21.0, 23.0)
138-
@test DataLayouts.get_struct(a, S, Val(2), CI[22]) == Foo{FT}(22.0, 24.0)
139-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(2), CI[23])
140-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(2), CI[24])
141-
142-
# e.g., how IJF is indexed (field dim 3)
143-
@test DataLayouts.get_struct(a, S, Val(3), CI[1]) == Foo{FT}(1.0, 7.0)
144-
@test DataLayouts.get_struct(a, S, Val(3), CI[2]) == Foo{FT}(2.0, 8.0)
145-
@test DataLayouts.get_struct(a, S, Val(3), CI[3]) == Foo{FT}(3.0, 9.0)
146-
@test DataLayouts.get_struct(a, S, Val(3), CI[4]) == Foo{FT}(4.0, 10.0)
147-
@test DataLayouts.get_struct(a, S, Val(3), CI[5]) == Foo{FT}(5.0, 11.0)
148-
@test DataLayouts.get_struct(a, S, Val(3), CI[6]) == Foo{FT}(6.0, 12.0)
149-
@test DataLayouts.get_struct(a, S, Val(3), CI[7]) == Foo{FT}(7.0, 13.0)
150-
@test DataLayouts.get_struct(a, S, Val(3), CI[8]) == Foo{FT}(8.0, 14.0)
151-
@test DataLayouts.get_struct(a, S, Val(3), CI[9]) == Foo{FT}(9.0, 15.0)
152-
@test DataLayouts.get_struct(a, S, Val(3), CI[10]) == Foo{FT}(10.0, 16.0)
153-
@test DataLayouts.get_struct(a, S, Val(3), CI[11]) == Foo{FT}(11.0, 17.0)
154-
@test DataLayouts.get_struct(a, S, Val(3), CI[12]) == Foo{FT}(12.0, 18.0)
155-
@test DataLayouts.get_struct(a, S, Val(3), CI[13]) == Foo{FT}(13.0, 19.0)
156-
@test DataLayouts.get_struct(a, S, Val(3), CI[14]) == Foo{FT}(14.0, 20.0)
157-
@test DataLayouts.get_struct(a, S, Val(3), CI[15]) == Foo{FT}(15.0, 21.0)
158-
@test DataLayouts.get_struct(a, S, Val(3), CI[16]) == Foo{FT}(16.0, 22.0)
159-
@test DataLayouts.get_struct(a, S, Val(3), CI[17]) == Foo{FT}(17.0, 23.0)
160-
@test DataLayouts.get_struct(a, S, Val(3), CI[18]) == Foo{FT}(18.0, 24.0)
161-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(3), CI[19])
55+
s = field_dim_to_one(s_array, 3)
56+
a = one_to_n(s_array, FT)
57+
@test get_struct(a, S, Val(3), CI(s)[1]) == Foo{FT}(1.0, 13.0)
58+
@test get_struct(a, S, Val(3), CI(s)[2]) == Foo{FT}(2.0, 14.0)
59+
@test get_struct(a, S, Val(3), CI(s)[3]) == Foo{FT}(3.0, 15.0)
60+
@test get_struct(a, S, Val(3), CI(s)[4]) == Foo{FT}(4.0, 16.0)
61+
@test get_struct(a, S, Val(3), CI(s)[5]) == Foo{FT}(5.0, 17.0)
62+
@test get_struct(a, S, Val(3), CI(s)[6]) == Foo{FT}(6.0, 18.0)
63+
@test get_struct(a, S, Val(3), CI(s)[7]) == Foo{FT}(7.0, 19.0)
64+
@test get_struct(a, S, Val(3), CI(s)[8]) == Foo{FT}(8.0, 20.0)
65+
@test get_struct(a, S, Val(3), CI(s)[9]) == Foo{FT}(9.0, 21.0)
66+
@test get_struct(a, S, Val(3), CI(s)[10]) == Foo{FT}(10.0, 22.0)
67+
@test get_struct(a, S, Val(3), CI(s)[11]) == Foo{FT}(11.0, 23.0)
68+
@test get_struct(a, S, Val(3), CI(s)[12]) == Foo{FT}(12.0, 24.0)
69+
@test_throws BoundsError get_struct(a, S, Val(3), CI(s)[13])
16270
end
16371

164-
@testset "get_struct - flat struct 2-fields 5-dims" begin
72+
@testset "get_struct - VIJFH indexing" begin
16573
FT = Float64
16674
S = Foo{FT}
16775
s = (2, 2, 2, 2, 2)
16876
a = one_to_n(s, FT)
169-
CI = CartesianIndices(map-> Base.OneTo(ξ), s))
17077
@test ncomponents(FT, S) == 2
17178

172-
# Call get_struct, and span `a` (access elements to 2^5 = 32.0):
173-
@test DataLayouts.get_struct(a, S, Val(1), CI[1]) == Foo{FT}(1.0, 2.0)
174-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(1), CI[2])
175-
176-
@test DataLayouts.get_struct(a, S, Val(2), CI[1]) == Foo{FT}(1.0, 3.0)
177-
@test DataLayouts.get_struct(a, S, Val(2), CI[2]) == Foo{FT}(2.0, 4.0)
178-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(2), CI[3])
179-
180-
@test DataLayouts.get_struct(a, S, Val(3), CI[1]) == Foo{FT}(1.0, 5.0)
181-
@test DataLayouts.get_struct(a, S, Val(3), CI[2]) == Foo{FT}(2.0, 6.0)
182-
@test DataLayouts.get_struct(a, S, Val(3), CI[3]) == Foo{FT}(3.0, 7.0)
183-
@test DataLayouts.get_struct(a, S, Val(3), CI[4]) == Foo{FT}(4.0, 8.0)
184-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(3), CI[5])
185-
186-
# e.g., how VIJFH is indexed (field dim 4)
187-
@test DataLayouts.get_struct(a, S, Val(4), CI[1]) == Foo{FT}(1.0, 9.0)
188-
@test DataLayouts.get_struct(a, S, Val(4), CI[2]) == Foo{FT}(2.0, 10.0)
189-
@test DataLayouts.get_struct(a, S, Val(4), CI[3]) == Foo{FT}(3.0, 11.0)
190-
@test DataLayouts.get_struct(a, S, Val(4), CI[4]) == Foo{FT}(4.0, 12.0)
191-
@test DataLayouts.get_struct(a, S, Val(4), CI[5]) == Foo{FT}(5.0, 13.0)
192-
@test DataLayouts.get_struct(a, S, Val(4), CI[6]) == Foo{FT}(6.0, 14.0)
193-
@test DataLayouts.get_struct(a, S, Val(4), CI[7]) == Foo{FT}(7.0, 15.0)
194-
@test DataLayouts.get_struct(a, S, Val(4), CI[8]) == Foo{FT}(8.0, 16.0)
195-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(4), CI[9])
196-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(4), CI[10])
197-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(4), CI[11])
198-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(4), CI[12])
199-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(4), CI[13])
200-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(4), CI[14])
201-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(4), CI[15])
202-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(4), CI[16])
203-
@test DataLayouts.get_struct(a, S, Val(4), CI[17]) == Foo{FT}(17.0, 25.0)
204-
@test DataLayouts.get_struct(a, S, Val(4), CI[18]) == Foo{FT}(18.0, 26.0)
205-
@test DataLayouts.get_struct(a, S, Val(4), CI[19]) == Foo{FT}(19.0, 27.0)
206-
@test DataLayouts.get_struct(a, S, Val(4), CI[20]) == Foo{FT}(20.0, 28.0)
207-
@test DataLayouts.get_struct(a, S, Val(4), CI[21]) == Foo{FT}(21.0, 29.0)
208-
@test DataLayouts.get_struct(a, S, Val(4), CI[22]) == Foo{FT}(22.0, 30.0)
209-
@test DataLayouts.get_struct(a, S, Val(4), CI[23]) == Foo{FT}(23.0, 31.0)
210-
@test DataLayouts.get_struct(a, S, Val(4), CI[24]) == Foo{FT}(24.0, 32.0)
211-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(4), CI[25])
212-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(4), CI[26])
213-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(4), CI[27])
214-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(4), CI[28])
215-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(4), CI[29])
216-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(4), CI[30])
217-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(4), CI[31])
218-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(4), CI[32])
219-
220-
@test DataLayouts.get_struct(a, S, Val(5), CI[1]) == Foo{FT}(1.0, 17.0)
221-
@test DataLayouts.get_struct(a, S, Val(5), CI[2]) == Foo{FT}(2.0, 18.0)
222-
@test DataLayouts.get_struct(a, S, Val(5), CI[3]) == Foo{FT}(3.0, 19.0)
223-
@test DataLayouts.get_struct(a, S, Val(5), CI[4]) == Foo{FT}(4.0, 20.0)
224-
@test DataLayouts.get_struct(a, S, Val(5), CI[5]) == Foo{FT}(5.0, 21.0)
225-
@test DataLayouts.get_struct(a, S, Val(5), CI[6]) == Foo{FT}(6.0, 22.0)
226-
@test DataLayouts.get_struct(a, S, Val(5), CI[7]) == Foo{FT}(7.0, 23.0)
227-
@test DataLayouts.get_struct(a, S, Val(5), CI[8]) == Foo{FT}(8.0, 24.0)
228-
@test DataLayouts.get_struct(a, S, Val(5), CI[9]) == Foo{FT}(9.0, 25.0)
229-
@test DataLayouts.get_struct(a, S, Val(5), CI[10]) == Foo{FT}(10.0, 26.0)
230-
@test DataLayouts.get_struct(a, S, Val(5), CI[11]) == Foo{FT}(11.0, 27.0)
231-
@test DataLayouts.get_struct(a, S, Val(5), CI[12]) == Foo{FT}(12.0, 28.0)
232-
@test DataLayouts.get_struct(a, S, Val(5), CI[13]) == Foo{FT}(13.0, 29.0)
233-
@test DataLayouts.get_struct(a, S, Val(5), CI[14]) == Foo{FT}(14.0, 30.0)
234-
@test DataLayouts.get_struct(a, S, Val(5), CI[15]) == Foo{FT}(15.0, 31.0)
235-
@test DataLayouts.get_struct(a, S, Val(5), CI[16]) == Foo{FT}(16.0, 32.0)
236-
@test_throws BoundsError DataLayouts.get_struct(a, S, Val(5), CI[17])
79+
@test get_struct(a, S, Val(4), CI(s)[1]) == Foo{FT}(1.0, 9.0)
80+
@test get_struct(a, S, Val(4), CI(s)[2]) == Foo{FT}(2.0, 10.0)
81+
@test get_struct(a, S, Val(4), CI(s)[3]) == Foo{FT}(3.0, 11.0)
82+
@test get_struct(a, S, Val(4), CI(s)[4]) == Foo{FT}(4.0, 12.0)
83+
@test get_struct(a, S, Val(4), CI(s)[5]) == Foo{FT}(5.0, 13.0)
84+
@test get_struct(a, S, Val(4), CI(s)[6]) == Foo{FT}(6.0, 14.0)
85+
@test get_struct(a, S, Val(4), CI(s)[7]) == Foo{FT}(7.0, 15.0)
86+
@test get_struct(a, S, Val(4), CI(s)[8]) == Foo{FT}(8.0, 16.0)
87+
@test_throws BoundsError get_struct(a, S, Val(4), CI(s)[9])
88+
@test_throws BoundsError get_struct(a, S, Val(4), CI(s)[10])
89+
@test_throws BoundsError get_struct(a, S, Val(4), CI(s)[11])
90+
@test_throws BoundsError get_struct(a, S, Val(4), CI(s)[12])
91+
@test_throws BoundsError get_struct(a, S, Val(4), CI(s)[13])
92+
@test_throws BoundsError get_struct(a, S, Val(4), CI(s)[14])
93+
@test_throws BoundsError get_struct(a, S, Val(4), CI(s)[15])
94+
@test_throws BoundsError get_struct(a, S, Val(4), CI(s)[16])
95+
@test get_struct(a, S, Val(4), CI(s)[17]) == Foo{FT}(17.0, 25.0)
96+
@test get_struct(a, S, Val(4), CI(s)[18]) == Foo{FT}(18.0, 26.0)
97+
@test get_struct(a, S, Val(4), CI(s)[19]) == Foo{FT}(19.0, 27.0)
98+
@test get_struct(a, S, Val(4), CI(s)[20]) == Foo{FT}(20.0, 28.0)
99+
@test get_struct(a, S, Val(4), CI(s)[21]) == Foo{FT}(21.0, 29.0)
100+
@test get_struct(a, S, Val(4), CI(s)[22]) == Foo{FT}(22.0, 30.0)
101+
@test get_struct(a, S, Val(4), CI(s)[23]) == Foo{FT}(23.0, 31.0)
102+
@test get_struct(a, S, Val(4), CI(s)[24]) == Foo{FT}(24.0, 32.0)
103+
@test_throws BoundsError get_struct(a, S, Val(4), CI(s)[25])
104+
@test_throws BoundsError get_struct(a, S, Val(4), CI(s)[26])
105+
@test_throws BoundsError get_struct(a, S, Val(4), CI(s)[27])
106+
@test_throws BoundsError get_struct(a, S, Val(4), CI(s)[28])
107+
@test_throws BoundsError get_struct(a, S, Val(4), CI(s)[29])
108+
@test_throws BoundsError get_struct(a, S, Val(4), CI(s)[30])
109+
@test_throws BoundsError get_struct(a, S, Val(4), CI(s)[31])
110+
@test_throws BoundsError get_struct(a, S, Val(4), CI(s)[32])
237111
end
238112

239113
# TODO: add set_struct!

0 commit comments

Comments
 (0)