Skip to content

Commit

Permalink
fix reconstruction of UInt32 and add regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Isensee committed Nov 25, 2024
1 parent c97edd1 commit 74729b0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/data/number_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function jltype(f::JLDFile, dt::FixedPointDatatype)
elseif dt.size == 1
return signed ? SameRepr{Int8}() : SameRepr{UInt8}()
elseif dt.size == 4
return signed ? SameRepr{Int32}() : SameRepr{Int32}()
return signed ? SameRepr{Int32}() : SameRepr{UInt32}()
elseif dt.size == 2
return signed ? SameRepr{Int16}() : SameRepr{UInt16}()
elseif dt.size == 16
Expand Down
19 changes: 18 additions & 1 deletion test/loadsave.jl
Original file line number Diff line number Diff line change
Expand Up @@ -847,4 +847,21 @@ end
loaded_data = load(fn, "data")
@test !isassigned(loaded_data, 2)
@test loaded_data[1] == :a
end
end

@testset "Issue #619 - Number type turnaround" begin
fn = joinpath(mktempdir(), "number_type_turnaround.jld2")
types = [UInt8, Int8, UInt16, Int16, UInt32, Int32, UInt64, Int64, UInt128, Int128, Float16, Float32, Float64]
jldopen(fn, "w") do f
for t in types
f[string(t)] = typemax(t)
end
end
jldopen(fn) do f
for t in types
v = f[string(t)]
@test v isa t
@test v == typemax(t)
end
end
end

0 comments on commit 74729b0

Please sign in to comment.