File: 01version.t

package info (click to toggle)
perl 5.42.0-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 128,392 kB
  • sloc: perl: 534,963; ansic: 240,563; sh: 72,042; pascal: 6,934; xml: 2,428; yacc: 1,360; makefile: 1,197; cpp: 208; lisp: 1
file content (105 lines) | stat: -rw-r--r-- 3,870 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
BEGIN {
    if ($ENV{PERL_CORE}) {
	chdir 't' if -d 't';
	@INC = ("../lib", "lib/compress");
    }
}

use lib qw(t t/compress);
use strict ;
use warnings ;

use Test::More ;

BEGIN
{
    # use Test::NoWarnings, if available
    my $extra = 0 ;
    $extra = 1
        if eval { require Test::NoWarnings ;  import Test::NoWarnings; 1 };

    plan tests => 9 + $extra ;

    use_ok('Compress::Raw::Zlib', 2) ;
}

use CompTestUtils;


# Check zlib_version and ZLIB_VERSION are the same.
test_zlib_header_matches_library();

SKIP:
{
    # If running a github workflow that tests upstream zlib/zlib-ng, check we have the version requested

    # Not github or not asking for explicit verson, so skip
    skip "Not github", 7
        if ! (defined $ENV{GITHUB_ACTION} && defined $ENV{ZLIB_VERSION}) ;

    my $expected_version = $ENV{ZLIB_VERSION} ;
    # zlib prefixes tags with a "v", so remove
    $expected_version =~ s/^v//i;

    skip "Skipping version tests for 'develop' branch", 7
        if ($expected_version eq 'develop') ;

    if ($ENV{USE_ZLIB_NG})
    {
        # zlib-ng native
        my $zv = Compress::Raw::Zlib::zlibng_version();
        is substr($zv, 0, length($expected_version)), $expected_version, "Expected version is $expected_version";
        ok ! Compress::Raw::Zlib::is_zlib_native(), "! is_zlib_native";
        ok   Compress::Raw::Zlib::is_zlibng(), "is_zlibng";
        ok   Compress::Raw::Zlib::is_zlibng_native(), "is_zlibng_native";
        ok ! Compress::Raw::Zlib::is_zlibng_compat(), "! is_zlibng_compat";
        is   Compress::Raw::Zlib::zlib_version(), '', "zlib_version() should be empty";
        is   Compress::Raw::Zlib::ZLIB_VERSION, '', "ZLIB_VERSION should be empty";
    }
    elsif ($ENV{ZLIB_NG_PRESENT})
    {
        # zlib-ng compat
        my %zlibng2zlib = (
            '2.0.0' => '1.2.11.zlib-ng',
            '2.0.1' => '1.2.11.zlib-ng',
            '2.0.2' => '1.2.11.zlib-ng',
            '2.0.3' => '1.2.11.zlib-ng',
            '2.0.4' => '1.2.11.zlib-ng',
            '2.0.5' => '1.2.11.zlib-ng',
            '2.0.6' => '1.2.11.zlib-ng',
            '2.0.7' => '1.2.11.zlib-ng',
            '2.1.2' => '1.2.13.zlib-ng',
            '2.1.3' => '1.2.13.zlib-ng',
            '2.1.4' => '1.3.0.zlib-ng',
            '2.1.5' => '1.3.0.zlib-ng',
            '2.1.6' => '1.3.0.zlib-ng',
            '2.1.7' => '1.3.1.zlib-ng',
            '2.2.0' => '1.3.1.zlib-ng',
            '2.2.1' => '1.3.1.zlib-ng',
        );

        my $zv = Compress::Raw::Zlib::zlibng_version();

        my $compat_ver = $zlibng2zlib{$expected_version};

        is substr($zv, 0, length($expected_version)), $expected_version, "Expected Version is $expected_version";
        ok ! Compress::Raw::Zlib::is_zlib_native(), "! is_zlib_native";
        ok   Compress::Raw::Zlib::is_zlibng(), "is_zlibng";
        ok ! Compress::Raw::Zlib::is_zlibng_native(), "! is_zlibng_native";
        ok   Compress::Raw::Zlib::is_zlibng_compat(), "is_zlibng_compat";
        is   Compress::Raw::Zlib::zlib_version(), $compat_ver, "zlib_version() should be $compat_ver";
        is   Compress::Raw::Zlib::ZLIB_VERSION, $compat_ver, "ZLIB_VERSION should be $compat_ver";
    }
    else
    {
        # zlib native
        my $zv = Compress::Raw::Zlib::zlib_version();
        is substr($zv, 0, length($expected_version)), $expected_version, "Expected Version is $expected_version";
        ok   Compress::Raw::Zlib::is_zlib_native(), "is_zlib_native";
        ok ! Compress::Raw::Zlib::is_zlibng(), "! is_zlibng";
        ok ! Compress::Raw::Zlib::is_zlibng_native(), "! is_zlibng_native";
        ok ! Compress::Raw::Zlib::is_zlibng_compat(), "! is_zlibng_compat";
        is   Compress::Raw::Zlib::zlibng_version(), '', "zlibng_version() should be empty";
        is   Compress::Raw::Zlib::ZLIBNG_VERSION, '', "ZLIBNG_VERSION should be empty";    }

}