File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 225225 @test isapprox (dc, dc_num; rtol = 1e-4 , atol = 1e-6 )
226226 end
227227end
228+
229+ # -- Functions: getindex, length, setindex! ------------------------------------------------
230+
231+ @testset " General Functions of CRP: Iterable Object API" begin
232+ c = CRP (randn (), randn (), randn ())
233+ @test length (c) == 3
234+ @test c[1 ] == c. q1
235+ @test c[2 ] == c. q2
236+ @test c[3 ] == c. q3
237+
238+ @test_throws BoundsError c[0 ]
239+ @test_throws BoundsError c[4 ]
240+
241+ v = zeros (10 )
242+
243+ v[4 : 6 ] = c
244+
245+ @test v[1 ] == 0
246+ @test v[2 ] == 0
247+ @test v[3 ] == 0
248+ @test v[4 ] == c. q1
249+ @test v[5 ] == c. q2
250+ @test v[6 ] == c. q3
251+ @test v[7 ] == 0
252+ @test v[8 ] == 0
253+ @test v[9 ] == 0
254+ @test v[10 ] == 0
255+
256+ @test firstindex (c) === 1
257+ @test lastindex (c) === 3
258+
259+ v = c[:]
260+
261+ @test v[1 ] == c. q1
262+ @test v[2 ] == c. q2
263+ @test v[3 ] == c. q3
264+ end
Original file line number Diff line number Diff line change 238238 @test isapprox (dm, dm_num; rtol = 1e-4 , atol = 1e-6 )
239239 end
240240end
241+
242+ # -- Functions: getindex, length, setindex! ------------------------------------------------
243+
244+ @testset " General Functions of MRP: Iterable Object API" begin
245+ m = MRP (randn (), randn (), randn ())
246+ @test length (m) == 3
247+ @test m[1 ] == m. q1
248+ @test m[2 ] == m. q2
249+ @test m[3 ] == m. q3
250+
251+ @test_throws BoundsError m[0 ]
252+ @test_throws BoundsError m[4 ]
253+
254+ v = zeros (10 )
255+
256+ v[4 : 6 ] = m
257+
258+ @test v[1 ] == 0
259+ @test v[2 ] == 0
260+ @test v[3 ] == 0
261+ @test v[4 ] == m. q1
262+ @test v[5 ] == m. q2
263+ @test v[6 ] == m. q3
264+ @test v[7 ] == 0
265+ @test v[8 ] == 0
266+ @test v[9 ] == 0
267+ @test v[10 ] == 0
268+
269+ @test firstindex (m) === 1
270+ @test lastindex (m) === 3
271+
272+ v = m[:]
273+
274+ @test v[1 ] == m. q1
275+ @test v[2 ] == m. q2
276+ @test v[3 ] == m. q3
277+ end
You can’t perform that action at this time.
0 commit comments