Skip to content

Commit dfa88a1

Browse files
authored
Merge pull request #119 from hpoit/pull-request/02484021
Adding GZIP format and tests
2 parents 42255b8 + 0248402 commit dfa88a1

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/registry.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# data formats
44
add_format(format"JLD", "Julia data file (HDF5)", ".jld", [:JLD])
5+
add_format(format"GZIP", [0x1f, 0x8b], ".gz", [:Libz])
56

67
# test for RD?2 magic sequence at the beginning of R data input stream
78
function detect_rdata(io)

test/loadsave.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ load(file::File{format"PBMText"}) = "PBMText"
1010
load(file::File{format"PBMBinary"}) = "PBMBinary"
1111
load(file::File{format"HDF5"}) = "HDF5"
1212
load(file::File{format"JLD"}) = "JLD"
13+
load(file::File{format"GZIP"}) = "GZIP"
1314
end
1415

1516
sym2loader = copy(FileIO.sym2loader)
@@ -25,9 +26,11 @@ try
2526
add_loader(format"PBMBinary", :TestLoadSave)
2627
add_loader(format"HDF5", :TestLoadSave)
2728
add_loader(format"JLD", :TestLoadSave)
29+
add_loader(format"GZIP", :TestLoadSave)
2830

2931
@test load(joinpath(file_dir,"file1.pbm")) == "PBMText"
3032
@test load(joinpath(file_dir,"file2.pbm")) == "PBMBinary"
33+
3134
# Regular HDF5 file with magic bytes starting at position 0
3235
@test load(joinpath(file_dir,"file1.h5")) == "HDF5"
3336
# This one is actually a JLD file saved with an .h5 extension,
@@ -39,7 +42,8 @@ try
3942
@test load(joinpath(file_dir,"file2.h5")) == "HDF5"
4043
# JLD file saved with .jld extension
4144
@test load(joinpath(file_dir,"file.jld")) == "JLD"
42-
45+
# GZIP file saved with .gz extension
46+
@test load(joinpath(file_dir,"file.csv.gz")) == "GZIP"
4347
@test_throws Exception load("missing.fmt")
4448
end
4549
finally

0 commit comments

Comments
 (0)