Skip to content

Commit

Permalink
Add spec for Compress::Gzip::Writer with extra (#14788)
Browse files Browse the repository at this point in the history
  • Loading branch information
straight-shoota authored Jul 8, 2024
1 parent 3d007b1 commit 0571f19
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions spec/std/compress/gzip/gzip_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,27 @@ describe Compress::Gzip do
end
end
end

it "writes and reads file with extra fields" do
io = IO::Memory.new
Compress::Gzip::Writer.open(io) do |gzip|
header = gzip.header
header.modification_time = Time.utc(2012, 9, 4, 22, 6, 5)
header.os = 3_u8
header.extra = Bytes[1, 2, 3, 4, 5]
header.name = "test.txt"
header.comment = "happy birthday"
gzip << "One\nTwo"
end
io.rewind
Compress::Gzip::Reader.open(io) do |gzip|
header = gzip.header.not_nil!
header.modification_time.to_utc.should eq(Time.utc(2012, 9, 4, 22, 6, 5))
header.os.should eq(3_u8)
header.extra.should eq(Bytes[1, 2, 3, 4, 5])
header.name.should eq("test.txt")
header.comment.should eq("happy birthday")
gzip.gets_to_end.should eq("One\nTwo")
end
end
end

0 comments on commit 0571f19

Please sign in to comment.