Skip to content

Commit 9c5ce7d

Browse files
committed
add more test cases
1 parent 3776487 commit 9c5ce7d

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/CircularArrayBuffers.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ function Base.push!(cb::CircularArrayBuffer{T,N}, data) where {T,N}
111111
end
112112
if N == 1
113113
i = _buffer_frame(cb, cb.nframes)
114-
cb.buffer[i:i] .= data
114+
cb.buffer[i:i] .= Ref(data)
115115
else
116116
cb.buffer[ntuple(_ -> (:), N - 1)..., _buffer_frame(cb, cb.nframes)] .= data
117117
end

test/runtests.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,17 @@ CUDA.allowscalar(false)
1111
# https://github.com/JuliaReinforcementLearning/ReinforcementLearning.jl/issues/551
1212
@testset "1D with 0d data" begin
1313
b = CircularArrayBuffer{Int}(3)
14-
push!(b, zeros(Int, ()))
14+
append!(b, zeros(Int, ())) # !!! not push!
1515
@test length(b) == 1
1616
@test b[1] == 0
1717
end
1818

19+
@testset "1D vector" begin
20+
b = CircularArrayBuffer([[1], [2, 3]])
21+
push!(b, [4, 5, 6])
22+
@test b == [[2, 3], [4, 5, 6]]
23+
end
24+
1925
@testset "1D Symbol" begin
2026
b = CircularArrayBuffer([:a, :b])
2127
push!(b, :c)
@@ -195,7 +201,7 @@ if CUDA.functional()
195201
# https://github.com/JuliaReinforcementLearning/ReinforcementLearning.jl/issues/551
196202
@testset "1D with 0d data" begin
197203
b = adapt(CuArray, CircularArrayBuffer{Int}(3))
198-
CUDA.@allowscalar push!(b, CUDA.zeros(Int, ()))
204+
append!(b, CUDA.zeros(Int, ())) # !!! not push!
199205
@test length(b) == 1
200206
@test CUDA.@allowscalar b[1] == 0
201207
end

0 commit comments

Comments
 (0)