Skip to content

Commit

Permalink
improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
meggart committed Dec 1, 2023
1 parent 0d487e0 commit f5f04d1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
9 changes: 2 additions & 7 deletions src/ZGroup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export attributes
ZGroup(storage, path::AbstractString, arrays, groups, attrs, writeable) =
ZGroup(storage, String(path), arrays, groups, attrs, writeable)

zname(g::ZGroup) = zname(g.path)
zname(g::ZGroup) = zname(path(g))

#Open an existing ZGroup
function ZGroup(s::T,mode="r",path="";fill_as_missing=false) where T <: AbstractStore
Expand Down Expand Up @@ -71,12 +71,7 @@ function Base.show(io::IO, g::ZGroup)
!isempty(groups(g)) && print(io, "\nGroups: ", map(i -> string(zname(i), " "), values(groups(g)))...)
nothing
end
Base.haskey(g::ZGroup,k)= haskey(groups(g),k) || haskey(arrays(g),k)


const SymbolOrString = Union{Symbol,AbstractString}
Base.haskey(x::Dict{String,ZGroup}, key::Symbol) = haskey(x, "$key")
Base.haskey(x::Dict{String,ZArray}, key::Symbol) = haskey(x, "$key")
Base.haskey(g::ZGroup,k)= haskey(groups(g),string(k)) || haskey(arrays(g),string(k))

function Base.getindex(g::ZGroup, k::AbstractString)
if haskey(groups(g), k)
Expand Down
13 changes: 11 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,23 @@ end

zzeros(Float64,a,"a",3,3)
zzeros(Int,a,"b",5,4,2)
zgroup(a,"subgroup")

@test a["a"] isa ZArray
@test a[:a] isa ZArray
@test a.b isa ZArray
@test issetequal(propertynames(a),(:a,:b))
@test issetequal(propertynames(a,true),(:a,:b,:attrs))
@test a.subgroup isa ZGroup
@test haskey(a,"a")
@test haskey(a,:a)
@test !haskey(a,"something")
@test !haskey(a,:something)
@test issetequal(propertynames(a),(:a,:b,:subgroup))
@test issetequal(propertynames(a,true),(:a,:b,:subgroup,:attrs))
@test @test_warn "Accessing attributes" a.attrs["a"]==5
@test attributes(a) == Dict("a"=>5)
buf=IOBuffer()
show(buf,a)
@test startswith(String(take!(buf)),"ZarrGroup at Dictionary Storage and path \nVariables:")
end

@testset "Metadata" begin
Expand Down

0 comments on commit f5f04d1

Please sign in to comment.