1 -- $Id: test_gzip.lua,v 1.2 2003/12/28 01:26:16 tngd Exp $
3 local function line(header
, c
)
6 print(string.rep(string.sub(c
, 1, 1), 78 - string.len(header
))..header
)
14 local testfile
= "test.gz"
16 local of
= gzip
.open(testfile
, "wb9")
19 error("Failed to open file test.gz for writing")
29 for l
in gzip
.lines(testfile
) do
31 if (tostring(i
) ~= l
) then
40 local inf
= gzip
.open(testfile
)
43 error("Failed to open file test.gz for reading")
47 if (tostring(i
) ~= inf
:read("*l")) then
55 line(' compress seek')
57 of
= gzip
.open(testfile
, "wb1")
60 error("Failed to open file test.gz for writing")
63 assert(of
:seek("cur", 5) == 5)
64 assert(of
:seek("set", 10) == 10)
71 line(' uncompress seek')
73 inf
= gzip
.open(testfile
)
76 error("Failed to open file test.gz for reading")
79 assert(inf
:seek("set", 6) == 6)
80 assert(inf
:seek("set", 4) == 4)
81 assert(inf
:seek("cur", 1) == 5)
82 assert(inf
:seek("cur", -1) == 4)
83 assert(inf
:seek("cur", 1) == 5)
84 assert(inf
:seek("set", 6) == 6)
88 assert(inf
:read(1) == "1")