1169d92004-05-02Martin Nilsson START_MARKER
24ddc71998-03-28Henrik Grubbström (Grubba) 
4232702004-02-04Martin Nilsson cond_resolv(Gz.deflate,
ab6aec1997-02-11Fredrik Hübinette (Hubbe) [[
36e14f1997-02-11Fredrik Hübinette (Hubbe)  test_true(Gz.deflate()) test_true(Gz.deflate()->deflate) test_true(Gz.inflate()) test_true(Gz.inflate()->inflate)
87b8be1999-06-08Mirar (Pontus Hagland) 
ab6aec1997-02-11Fredrik Hübinette (Hubbe) define(dotest,[[
c1924d1999-09-11Fredrik Hübinette (Hubbe)  test_do([[add_constant("____gz_tmp_constant",$1);]]) test_true([[Gz.deflate(1)->deflate(____gz_tmp_constant)]]) test_true([[Gz.inflate()->inflate(Gz.deflate(1)->deflate(____gz_tmp_constant))==____gz_tmp_constant]]) test_true([[Gz.inflate()->inflate(Gz.deflate(9)->deflate(____gz_tmp_constant))==____gz_tmp_constant]]) test_true([[object o=Gz.deflate(); Gz.inflate()->inflate(o->deflate(____gz_tmp_constant,o->PARTIAL_FLUSH) + o->deflate(____gz_tmp_constant,o->FINISH)) == (____gz_tmp_constant)+(____gz_tmp_constant)]])
df4be42000-04-13Fredrik Hübinette (Hubbe)  test_do([[add_constant("____gz_tmp_constant");]])
ab6aec1997-02-11Fredrik Hübinette (Hubbe) ]])
87b8be1999-06-08Mirar (Pontus Hagland) 
ab6aec1997-02-11Fredrik Hübinette (Hubbe)  dotest("") dotest("foo") dotest(sprintf("%'fomp'1000n")) dotest(sprintf("%'fomp'100000n"))
87b8be1999-06-08Mirar (Pontus Hagland) 
3ab3a52002-11-24Marcus Agehall  test_true(Gz.File) test_any([[
dfc88a2002-11-28Martin Stjernholm  string orig = ((string) Array.enumerate(256)) * 1024;
3ab3a52002-11-24Marcus Agehall  object f = Gz.File("gz_test.gz", "wb"); f->write(orig); f->close(); f = Gz.File("gz_test.gz", "rb"); rm("gz_test.gz"); string readback = f->read(); f->close(); return orig==readback;
9d3ebf2016-12-23Martin Nilsson  ]], 1) test_any([[ Stdio.FakeFile f = Stdio.FakeFile("","wb"); Gz.File g = Gz.File(f, "wb"); g->write("gazonk"); g->close(); return (string)f; ]], "\37\213\b\0\0\0\0\0\0\3KO\254\312\317\313\6\0\240\362vf\6\0\0\0") test_any([[ Stdio.FakeFile f = Stdio.FakeFile("","wb"); Gz.File g = Gz.File(f, "wb9"); g->write("gazonk"); g->close(); return (string)f; ]], "\37\213\b\0\0\0\0\0\0\3KO\254\312\317\313\6\0\240\362vf\6\0\0\0") test_any([[ Stdio.FakeFile f = Stdio.FakeFile("","wb"); Gz.File g = Gz.File(f, "wb0"); g->write("gazonk"); g->close(); return (string)f; ]], "\37\213\b\0\0\0\0\0\0\3x\1\1\6\0\371\377gazonk\b\321\2\213\240\362vf\6\0\0\0") test_any([[ Stdio.FakeFile f = Stdio.FakeFile("","wb"); Gz.File g = Gz.File(f, "wb"); g->setparams(0); g->write("gazonk"); g->close(); return (string)f; ]], "\37\213\b\0\0\0\0\0\0\3x\1\1\6\0\371\377gazonk\b\321\2\213\240\362vf\6\0\0\0")
3ab3a52002-11-24Marcus Agehall 
4232702004-02-04Martin Nilsson  dotest(random_string(32768)) dotest(random_string(524288))
48916d2007-05-01Martin Nilsson  test_eq(Gz.uncompress(Gz.compress("hello")),"hello") test_eq(Gz.uncompress(Gz.compress("")),"") test_eq(Gz.uncompress(Gz.compress("hello",1),1),"hello") test_eq(Gz.uncompress(Gz.compress("",1),1),"")
25dfec2007-06-02Martin Nilsson  test_eq(Gz.uncompress(Gz.compress("a test",0,0)),"a test") test_eq(Gz.uncompress(Gz.compress("a test",0,9)),"a test") test_eq(Gz.compress("a test",0,9,Gz.DEFAULT_STRATEGY),Gz.compress("a test",0,9)) test_eq(Gz.uncompress(Gz.compress("a test",0,9,Gz.FILTERED)),"a test") test_eq(Gz.uncompress(Gz.compress("a test",0,9,Gz.HUFFMAN_ONLY)),"a test")
f982ee2008-12-30Henrik Grubbström (Grubba) ]])
25dfec2007-06-02Martin Nilsson cond_resolv(Gz.RLE, [[ test_eq(Gz.uncompress(Gz.compress("a test",0,9,Gz.RLE)),"a test") ]]) cond_resolv(Gz.FIXED, [[ test_eq(Gz.uncompress(Gz.compress("a test",0,9,Gz.FIXED)),"a test") ]])
f982ee2008-12-30Henrik Grubbström (Grubba) cond_resolv(Gz.deflate, [[
25dfec2007-06-02Martin Nilsson  test_eq(Gz.uncompress(Gz.compress("a test",0,9,Gz.DEFAULT_STRATEGY,8)),"a test") test_eq(Gz.uncompress(Gz.compress("a test",0,9,Gz.DEFAULT_STRATEGY,15)),"a test")
48916d2007-05-01Martin Nilsson  test_eval_error(Gz.uncompress("");) test_eval_error(Gz.uncompress("x");) test_eval_error(Gz.uncompress(Gz.compress("x",1))) test_eval_error(Gz.uncompress(Gz.compress("x"),1))
320cc12007-06-10Martin Nilsson  test_eval_error([[ int x = 1 + max(Gz.FILTERED, Gz.HUFFMAN_ONLY
25dfec2007-06-02Martin Nilsson #if constant(Gz.RLE) Gz.RLE, #endif #if constant(Gz.FIXED) Gz.FIXED, #endif );
320cc12007-06-10Martin Nilsson return Gz.compress("x",0,9,x); ]])
25dfec2007-06-02Martin Nilsson  test_eval_error(return Gz.compress("x",0,-1);) test_eval_error(return Gz.compress("x",0,10);) test_eval_error(return Gz.compress("x",0,-1);) test_eval_error(return Gz.compress("x",0,9,Gz.DEFAULT_STRATEGY,7);) test_eval_error(return Gz.compress("x",0,9,Gz.DEFAULT_STRATEGY,16);)
48916d2007-05-01Martin Nilsson 
ab6aec1997-02-11Fredrik Hübinette (Hubbe) ]])
b7ccde2011-12-30Henrik Grubbström (Grubba) cond_resolv(Gz.crc32, [[
7d59a42015-11-11Martin Nilsson  test_eq(Gz.crc32(""), 0) test_eq(Gz.crc32("a"), 0xe8b7be43) test_eq(Gz.crc32("abc"), 0x352441c2)
0fc4272015-11-15Martin Nilsson  test_eq(Gz.crc32("12345678901234567890123456789012345678901234567890123456789012345678901234567890"), 0x7ca94a72)
7d59a42015-11-11Martin Nilsson  test_eq(Gz.adler32(""), 1) test_eq(Gz.adler32("a"), 0x620062) test_eq(Gz.adler32("abc"), 0x24d0127)
0fc4272015-11-15Martin Nilsson  test_eq(Gz.adler32("12345678901234567890123456789012345678901234567890123456789012345678901234567890"), 0x97b61069)
b7ccde2011-12-30Henrik Grubbström (Grubba) ]])
1169d92004-05-02Martin Nilsson END_MARKER