Skip to content

Commit

Permalink
Merge pull request #34 from ExpandingMan/fix-empty-prim
Browse files Browse the repository at this point in the history
Fixed a bug that was preventing empty Primitives from being created
  • Loading branch information
ExpandingMan committed Oct 16, 2018
2 parents f78ac6c + 51e2efb commit b03e403
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ matrix:
# - julia -e 'Pkg.clone(pwd()); Pkg.build("Arrow"); Pkg.test("Arrow"; coverage=true)'
after_success:
# push coverage results to Coveralls
- julia -e 'using Pkg; cd(Pkg.dir("Arrow")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
- julia --project -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
# push coverage results to Codecov
- julia -e 'using Pkg; cd(Pkg.dir("Arrow")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
- julia --project -e 'using Pkg; Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
1 change: 1 addition & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ end

# this is only for values buffers
function check_buffer_bounds(::Type{U}, A::AbstractVector, i::Integer, len::Integer) where U
len == 0 && (return nothing) # if the array being created is empty these bounds don't matter
checkbounds(A, i)
checkbounds(A, i+len*sizeof(U)-1)
end
Expand Down
36 changes: 36 additions & 0 deletions test/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ end
end


@testset "indexing_Primitive_empty" begin
for i 1:N_OUTER
dtype = rand(PRIMITIVE_ELTYPES)
p = Primitive(dtype[])
@test isempty(p)
@test_throws BoundsError p[1]
end
end


@testset "indexing_NullablePrimitive_buffer" begin
for i 1:N_OUTER
len, dtype, bmask, lpad, b, v = rand_nullableprimitive_buffer()
Expand Down Expand Up @@ -141,6 +151,16 @@ end
end


@testset "indexing_NullablePrimitive_empty" begin
for i 1:N_OUTER
dtype = rand(PRIMITIVE_ELTYPES)
p = NullablePrimitive(dtype[])
@test isempty(p)
@test_throws BoundsError p[1]
end
end


@testset "indexing_List_buffer" begin
len = 5
offstype = rand(OFFSET_ELTYPES)
Expand Down Expand Up @@ -183,6 +203,14 @@ end
end


@testset "indexing_List_empty" begin
for i 1:N_OUTER
l = List(fill("", i))
@test l[rand(1:i)] == ""
end
end


@testset "indexing_NullableList_buffer" begin
len = 7
offstype = rand(OFFSET_ELTYPES)
Expand Down Expand Up @@ -234,6 +262,14 @@ end
end


@testset "indexing_NullableList_empty" begin
for i 1:N_OUTER
l = NullableList(fill("", i))
@test l[rand(1:i)] == ""
end
end


@testset "indexing_BitPrimitive_buffer" begin
len = 10
bits = vcat(UInt8[0xfd,0x02], zeros(UInt8, 6))
Expand Down

0 comments on commit b03e403

Please sign in to comment.