Skip to content

Commit 723d15a

Browse files
authored
Enable ZArray with eltype Char (#203)
1 parent 333b4d7 commit 723d15a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/ZArray.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ _zero(T) = zero(T)
143143
_zero(T::Type{<:MaxLengthString}) = T("")
144144
_zero(T::Type{ASCIIChar}) = ASCIIChar(0)
145145
_zero(::Type{<:Vector{T}}) where T = T[]
146+
_zero(::Type{Char}) = Char(0)
146147
getchunkarray(z::ZArray) = fill(_zero(eltype(z)), z.metadata.chunks)
147148

148149
maybeinner(a::Array) = a

test/runtests.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,18 @@ end
214214
@test_throws ArgumentError resize!(a,(-1,2))
215215
end
216216

217-
@testset "string array getindex/setindex" begin
217+
@testset "string/Char array getindex/setindex" begin
218218
aa = ["this", "is", "all ", "ascii"]
219219
bb = ["And" "Unicode"; "ματριξ" missing]
220+
cc = 'A':'D'
220221
a = ZArray(aa)
221222
b = ZArray(bb, fill_value = "")
223+
c = ZArray(cc)
222224
@test eltype(a) == String
223225
@test eltype(b) == Union{String,Missing}
226+
@test eltype(c) == Char
224227
@test a[:] == ["this", "is", "all ", "ascii"]
228+
@test c[:] == 'A':'D'
225229
@test all(isequal.(b[:,:],["And" "Unicode"; "ματριξ" missing]))
226230
end
227231

0 commit comments

Comments
 (0)