2 # Copyright (C) 2010, Parrot Foundation.
7 t/dynpmc/gziphandle.t - test the GzipHandle PMC
11 % parrot t/dynpmc/gziphandle.t
15 Tests the C<GzipHandle> PMC, a zlib wrapper.
22 .include 'test_more.pir'
23 .include 'iglobals.pasm'
24 .local pmc config_hash, interp
27 config_hash = interp[.IGLOBALS_CONFIG_HASH]
28 $S0 = config_hash['has_zlib']
29 unless $S0 goto no_zlib
32 $P0 = loadlib 'gziphandle'
40 skip_all('No zlib library available')
46 $P0 = new 'GzipHandle'
48 is($S0, 'GzipHandle', 'GzipHandle typeof')
49 $I0 = isa $P0, 'Handle'
56 $P0 = new 'FileHandle'
57 $S0 = $P0.'readall'('t/dynpmc/gziphandle.t')
60 .const string filename = 't/dynpmc/gziphandle.t.gz'
61 $P1 = new 'GzipHandle'
62 $P1.'open'(filename, 'wb')
65 $I1 = stat filename, .STAT_FILESIZE
69 $P2 = new 'GzipHandle'
70 $P2.'open'(filename, 'rb')
75 is($S1, $S0, "gzip stream")
82 $P0 = new 'GzipHandle'
86 is($I0, 0, 'zlib version')
90 $P0 = new 'GzipHandle'
91 .const string data = "message"
92 $I0 = $P0.'crc32'(0, data)
94 $S0 = $P0.'compress'(data)
96 is($I0, 15, "compress")
97 $S0 = $P0.'uncompress'($S0)
98 is($S0, data, "uncompress")
100 $S0 = repeat 'repeat', 100
102 $S1 = $P0.'compress'($S0)
106 $S2 = $P0.'uncompress'($S1)
107 is($S2, $S0, "uncompress with many realloc")
114 # vim: expandtab shiftwidth=4 ft=pir: