| 1 | BEGIN { |
| 2 | if ($ENVscip-perl cpan Compress-Raw-Bzip2 2.224 main/`%ENV`.{PERL_CORE}) { |
| 3 | chdirscip-perl cpan Compress-Raw-Bzip2 2.224 main/chdir(). 't' if -d 't'; |
| 4 | @INCscip-perl cpan Compress-Raw-Bzip2 2.224 main/`@INC`. = ("../lib", "lib/compress"); |
| 5 | } |
| 6 | } |
| 7 | |
| 8 | use libscip-perl cpan Compress-Raw-Bzip2 2.224 lib/ qw(t t/compress); |
| 9 | use strictscip-perl cpan Compress-Raw-Bzip2 2.224 strict/; |
| 10 | use warningsscip-perl cpan Compress-Raw-Bzip2 2.224 warnings/; |
| 11 | use bytesscip-perl cpan Compress-Raw-Bzip2 2.224 bytes/; |
| 12 | |
| 13 | use Test::Morescip-perl cpan Compress-Raw-Bzip2 2.224 Test/More/ ; |
| 14 | use CompTestUtilsscip-perl cpan Compress-Raw-Bzip2 2.224 CompTestUtils/; |
| 15 | |
| 16 | BEGIN |
| 17 | { |
| 18 | # use Test::NoWarnings, if available |
| 19 | my $extra = 0 ; |
| 20 | $extra = 1 |
| 21 | if eval { requirescip-perl cpan Compress-Raw-Bzip2 2.224 main/require(). Test::NoWarnings ; import Test::NoWarnings; 1 }; |
| 22 | |
| 23 | planscip-perl cpan Compress-Raw-Bzip2 2.224 main/plan(). tests => 88 + $extra ; |
| 24 | |
| 25 | use_okscip-perl cpan Compress-Raw-Bzip2 2.224 main/use_ok().('Compress::Raw::Bzip2') ; |
| 26 | } |
| 27 | |
| 28 | |
| 29 | |
| 30 | my $hello = "I am a HAL 9000 computer" x 2001; |
| 31 | my $tmp = $hello ; |
| 32 | |
| 33 | my ($err, $x, $X, $status); |
| 34 | |
| 35 | okscip-perl cpan Compress-Raw-Bzip2 2.224 main/ok().( ($x, $err) = new Compress::Raw::Bzip2 (1)); |
| 36 | okscip-perl cpan Compress-Raw-Bzip2 2.224 main/ok(). $x ; |
| 37 | cmp_okscip-perl cpan Compress-Raw-Bzip2 2.224 main/cmp_ok(). $err, '==', BZ_OK, " status is BZ_OK" ; |
| 38 | |
| 39 | my $out ; |
| 40 | $status = $x->bzdeflatescip-perl cpan Compress-Raw-Bzip2 2.224 main/bzdeflate().($tmp, $out) ; |
| 41 | cmp_okscip-perl cpan Compress-Raw-Bzip2 2.224 main/cmp_ok(). $status, '==', BZ_RUN_OK, " status is BZ_RUN_OK" ; |
| 42 | |
| 43 | cmp_okscip-perl cpan Compress-Raw-Bzip2 2.224 main/cmp_ok(). $x->bzclosescip-perl cpan Compress-Raw-Bzip2 2.224 main/bzclose().($out), '==', BZ_STREAM_END, " bzflush returned BZ_STREAM_END" ; |
| 44 | |
| 45 | { |
| 46 | my $t = $out; |
| 47 | my $b = new Compress::Raw::Bunzip2(0,0); |
| 48 | |
| 49 | my $GOT; |
| 50 | my $status = $b->bzinflatescip-perl cpan Compress-Raw-Bzip2 2.224 main/bzinflate().($t, $GOT) ; |
| 51 | cmp_okscip-perl cpan Compress-Raw-Bzip2 2.224 main/cmp_ok(). $status, "==", BZ_STREAM_END; |
| 52 | ok $GOT eqscip-perl cpan Compress-Raw-Bzip2 2.224 main/eq(). $hello; |
| 53 | |
| 54 | } |
| 55 | |
| 56 | sub getOutscip-perl cpan Compress-Raw-Bzip2 2.224 main/getOut(). { my $x = ''; return \$x } |
| 57 | |
| 58 | for my $bufsize (1, 2, 3, 13, 4096, 1024*10) |
| 59 | { |
| 60 | printscip-perl cpan Compress-Raw-Bzip2 2.224 main/print(). "#\n#Bufsize $bufsize\n#\n"; |
| 61 | $tmp = $out; |
| 62 | |
| 63 | my $k; |
| 64 | okscip-perl cpan Compress-Raw-Bzip2 2.224 main/ok().(($k, $err) = new Compress::Raw::Bunzip2( 1,1,0,0,1 |
| 65 | #AppendOutput => 1, |
| 66 | #LimitOutput => 1, |
| 67 | #Bufsize => $bufsize |
| 68 | )); |
| 69 | okscip-perl cpan Compress-Raw-Bzip2 2.224 main/ok(). $k ; |
| 70 | cmp_okscip-perl cpan Compress-Raw-Bzip2 2.224 main/cmp_ok(). $err, '==', BZ_OK, " status is BZ_OK" ; |
| 71 | |
| 72 | isscip-perl cpan Compress-Raw-Bzip2 2.224 main/is(). $k->total_in_lo32scip-perl cpan Compress-Raw-Bzip2 2.224 main/total_in_lo32().(), 0, " total_in_lo32 == 0" ; |
| 73 | isscip-perl cpan Compress-Raw-Bzip2 2.224 main/is(). $k->total_out_lo32scip-perl cpan Compress-Raw-Bzip2 2.224 main/total_out_lo32().(), 0, " total_out_lo32 == 0" ; |
| 74 | my $GOT = getOutscip-perl cpan Compress-Raw-Bzip2 2.224 main/getOut().(); |
| 75 | my $prev; |
| 76 | my $deltaOK = 1; |
| 77 | my $looped = 0; |
| 78 | while (lengthscip-perl cpan Compress-Raw-Bzip2 2.224 main/length(). $tmp) |
| 79 | { |
| 80 | ++ $looped; |
| 81 | my $prev = lengthscip-perl cpan Compress-Raw-Bzip2 2.224 main/length(). $GOT; |
| 82 | $status = $k->bzinflatescip-perl cpan Compress-Raw-Bzip2 2.224 main/bzinflate().($tmp, $GOT) ; |
| 83 | last if $status != BZ_OK; |
| 84 | $deltaOK = 0 if lengthscip-perl cpan Compress-Raw-Bzip2 2.224 main/length().($GOT) - $prev > $bufsize; |
| 85 | } |
| 86 | |
| 87 | okscip-perl cpan Compress-Raw-Bzip2 2.224 main/ok(). $deltaOK, " Output Delta never > $bufsize"; |
| 88 | cmp_okscip-perl cpan Compress-Raw-Bzip2 2.224 main/cmp_ok(). $looped, '>=', 1, " looped $looped"; |
| 89 | isscip-perl cpan Compress-Raw-Bzip2 2.224 main/is(). lengthscip-perl cpan Compress-Raw-Bzip2 2.224 main/length().($tmp), 0, " length of input buffer is zero"; |
| 90 | |
| 91 | cmp_okscip-perl cpan Compress-Raw-Bzip2 2.224 main/cmp_ok(). $status, "==", BZ_STREAM_END, " status is BZ_STREAM_END" ; |
| 92 | ok $$GOT eqscip-perl cpan Compress-Raw-Bzip2 2.224 main/eq(). $hello, " got expected output" ; |
| 93 | isscip-perl cpan Compress-Raw-Bzip2 2.224 main/is(). $k->total_in_lo32scip-perl cpan Compress-Raw-Bzip2 2.224 main/total_in_lo32().(), lengthscip-perl cpan Compress-Raw-Bzip2 2.224 main/length(). $out, " length total_in_lo32 ok" ; |
| 94 | isscip-perl cpan Compress-Raw-Bzip2 2.224 main/is(). $k->total_out_lo32scip-perl cpan Compress-Raw-Bzip2 2.224 main/total_out_lo32().(), lengthscip-perl cpan Compress-Raw-Bzip2 2.224 main/length(). $hello, " length total_out_lo32 ok " . $k->total_out_lo32scip-perl cpan Compress-Raw-Bzip2 2.224 main/total_out_lo32().() ; |
| 95 | } |
| 96 | |
| 97 | sub getitscip-perl cpan Compress-Raw-Bzip2 2.224 main/getit(). |
| 98 | { |
| 99 | my $obj = shiftscip-perl cpan Compress-Raw-Bzip2 2.224 main/shift(). ; |
| 100 | my $input = shiftscip-perl cpan Compress-Raw-Bzip2 2.224 main/shift().; |
| 101 | |
| 102 | my $data ; |
| 103 | 1 while $obj->bzinflatescip-perl cpan Compress-Raw-Bzip2 2.224 main/bzinflate().($input, $data) != BZ_STREAM_END ; |
| 104 | return \$data ; |
| 105 | } |
| 106 | |
| 107 | { |
| 108 | titlescip-perl cpan Compress-Raw-Bzip2 2.224 main/title(). "regression test"; |
| 109 | |
| 110 | my ($err, $x, $X, $status); |
| 111 | |
| 112 | okscip-perl cpan Compress-Raw-Bzip2 2.224 main/ok().( ($x, $err) = new Compress::Raw::Bzip2 (1)); |
| 113 | okscip-perl cpan Compress-Raw-Bzip2 2.224 main/ok(). $x ; |
| 114 | cmp_okscip-perl cpan Compress-Raw-Bzip2 2.224 main/cmp_ok(). $err, '==', BZ_OK, " status is BZ_OK" ; |
| 115 | |
| 116 | my $line1 = ("abcdefghijklmnopq" x 1000) . "\n" ; |
| 117 | my $line2 = "second line\n" ; |
| 118 | my $text = $line1 . $line2 ; |
| 119 | my $tmp = $text; |
| 120 | |
| 121 | my $out ; |
| 122 | $status = $x->bzdeflatescip-perl cpan Compress-Raw-Bzip2 2.224 main/bzdeflate().($tmp, $out) ; |
| 123 | cmp_okscip-perl cpan Compress-Raw-Bzip2 2.224 main/cmp_ok(). $status, '==', BZ_RUN_OK, " status is BZ_RUN_OK" ; |
| 124 | |
| 125 | cmp_okscip-perl cpan Compress-Raw-Bzip2 2.224 main/cmp_ok(). $x->bzclosescip-perl cpan Compress-Raw-Bzip2 2.224 main/bzclose().($out), '==', BZ_STREAM_END, " bzclose returned BZ_STREAM_END" ; |
| 126 | |
| 127 | my $k; |
| 128 | okscip-perl cpan Compress-Raw-Bzip2 2.224 main/ok().(($k, $err) = new Compress::Raw::Bunzip2( 1,1,0,0,1 |
| 129 | #AppendOutput => 1, |
| 130 | #LimitOutput => 1 |
| 131 | )); |
| 132 | |
| 133 | |
| 134 | my $c = getitscip-perl cpan Compress-Raw-Bzip2 2.224 main/getit().($k, $out); |
| 135 | is $$c, $text; |
| 136 | |
| 137 | |
| 138 | } |