Skip to content

Commit

Permalink
add detect_compressor() tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alyst committed Mar 17, 2021
1 parent 4d4fd70 commit 50e9cbf
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/files/dummy.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is a dummy file for FileIO.detect_compressor() test
Binary file added test/files/dummy.txt.bz2
Binary file not shown.
Binary file added test/files/dummy.txt.gz
Binary file not shown.
Binary file added test/files/dummy.txt.lz4
Binary file not shown.
Binary file added test/files/dummy.txt.xz
Binary file not shown.
20 changes: 20 additions & 0 deletions test/query.jl
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,26 @@ end
end
end

@testset "detect $format compression" for (ext, format) in [(nothing, nothing), (".gz", "GZIP"), (".bz2", "BZIP2"),
(".lz4", "LZ4"), (".xz", "XZ")]
fname = joinpath(@__DIR__, "files", "dummy.txt")
if ext !== nothing
fname *= ext
end
open(fname) do io
@test FileIO.detect_compressor(io, formats=[format]) == format # test with specific format only
end
open(fname) do io
@test FileIO.detect_compressor(io, formats=[]) === nothing # test with no formats
end
open(fname) do io
@test FileIO.detect_compressor(io) == format # test with all formats
end
open(fname) do io
@test FileIO.detect_compressed(io) == (format !== nothing)
end
end

let file_dir = joinpath(@__DIR__, "files"), file_path = Path(file_dir)
@testset "Querying with $(typeof(fp))" for fp in (file_dir, file_path)
@testset "bedGraph" begin
Expand Down

0 comments on commit 50e9cbf

Please sign in to comment.