Debian Codegraph @

t/19nonpv.t

raw symbols SCIP
1 BEGIN {
2 if ($ENV{PERL_CORE}) {
3 chdir 't' if -d 't';
4 @INC = ("../lib", "lib/compress");
5 }
6 }
7
8 use lib qw(t t/compress);
9 use strict;
10 use warnings;
11
12 use Test::More ;
13 use CompTestUtils;
14
15 BEGIN
16 {
17 # use Test::NoWarnings, if available
18 my $extra = 0 ;
19 $extra = 1
20 if eval { require Test::NoWarnings ; import Test::NoWarnings; 1 };
21
22 plan tests => 21 + $extra ;
23
24 use_ok('Compress::Raw::Bzip2', 2) ;
25 }
26
27
28
29 my $hello = <<EOM ;
30 hello world
31 this is a test
32 EOM
33
34 my $len = length $hello ;
35
36 SKIP:
37 {
38
39 title "bzdeflate/bzinflate - non-PV buffers";
40 # ==============================
41
42 # temp workaround for
43 # https://github.com/pmqs/Compress-Raw-Bzip2/issues/13
44 skip "skipping tests for Perl 5.6.*", 19
45 if $] < 5.008 ;
46
47 my $hello = *hello;
48 $hello = *hello;
49 my ($err, $x, $X, $status);
50
51 ok( ($x, $err) = new Compress::Raw::Bzip2(0), "Create bzdeflate object" );
52 ok $x, "Compress::Raw::Bzip2 ok" ;
53 cmp_ok $err, '==', BZ_OK, "status is BZ_OK" ;
54
55 is $x->uncompressedBytes(), 0, "uncompressedBytes() == 0" ;
56 is $x->compressedBytes(), 0, "compressedBytes() == 0" ;
57
58 my $Answer = *Answer;
59 $Answer = *Answer;
60 $status = $x->bzdeflate($hello, $Answer) ;
61 cmp_ok $status, '==', BZ_RUN_OK, "bzdeflate returned BZ_RUN_OK" ;
62
63 $X = *X;
64 cmp_ok $x->bzflush($X), '==', BZ_RUN_OK, "bzflush returned BZ_RUN_OK" ;
65 $Answer .= $X ;
66
67 is $x->uncompressedBytes(), length $hello, "uncompressedBytes ok" ;
68 is $x->compressedBytes(), length $Answer, "compressedBytes ok" ;
69
70 $X = *X;
71 cmp_ok $x->bzclose($X), '==', BZ_STREAM_END, "bzclose returned BZ_STREAM_END";
72 $Answer .= $X ;
73
74 my @Answer = split('', $Answer) ;
75
76 my $k;
77 ok(($k, $err) = new Compress::Raw::Bunzip2(0, 0));
78 ok $k, "Compress::Raw::Bunzip2 ok" ;
79 cmp_ok $err, '==', BZ_OK, "status is BZ_OK" ;
80
81 is $k->compressedBytes(), 0, "compressedBytes() == 0" ;
82 is $k->uncompressedBytes(), 0, "uncompressedBytes() == 0" ;
83 my $GOT = *GOT;
84 $GOT = *GOT;
85 my $Z;
86 $status = $k->bzinflate($Answer, $GOT) ;
87
88
89 cmp_ok $status, '==', BZ_STREAM_END, "Got BZ_STREAM_END" ;
90 is $GOT, $hello, "uncompressed data matches ok" ;
91 is $k->compressedBytes(), length $Answer, "compressedBytes ok" ;
92 is $k->uncompressedBytes(), length $hello , "uncompressedBytes ok";
93
94 }