]> git.donarmstrong.com Git - debbugs.git/blob - t/02_version_dpkg.t
fix syntax error in bug
[debbugs.git] / t / 02_version_dpkg.t
1 # -*- mode: cperl;-*-
2
3 use Test::More;
4
5 use warnings;
6 use strict;
7
8 use utf8;
9 use Encode;
10
11 # Default cmp '>'
12 my @versions = ({a      => '1.0-1',
13                  b      => '2.0-2',
14                  result => -1,
15                  relation => 'lt',
16                 },
17                 {a      => '2.2~rc-4',
18                  b      => '2.2-1',
19                  result => -1,
20                  relation => 'lt',
21                 },
22                 {a      => '2.2-1',
23                  b      => '2.2~rc-4',
24                  result => 1,
25                  relation => 'gt',
26                 },
27                 {a      => '1.0000-1',
28                  b      => '1.0-1',
29                  result => 0,
30                  relation => 'eq',
31                 },
32                 # q(1.1-20080727-1),q(1.1-20080316-1)
33                 {a      => '1.1-20080727-1',
34                  b      => '1.1-20080316-1',
35                  result => 1,
36                  relation => 'gt',
37                 },
38                 {a      => '1.1-20080316-1',
39                  b      => '1.1-20080727-1',
40                  result => -1,
41                  relation => 'lt',
42                 },
43                );
44
45 plan tests => @versions * 2 + 1;
46
47 sub dpkg_vercmp{
48      my ($a,$b,$cmp) = @_;
49      $cmp = 'gt' if not defined $cmp;
50      return system('dpkg','--compare-versions',$a,$cmp,$b) == 0;
51 }
52
53
54 use_ok('Debbugs::Versions::Dpkg');
55
56 for my $version_cmp (@versions) {
57      ok(Debbugs::Versions::Dpkg::vercmp($$version_cmp{a},$$version_cmp{b}) == $$version_cmp{result},
58         "Version $$version_cmp{a} $$version_cmp{relation} $$version_cmp{b} ok");
59      ok(dpkg_vercmp($$version_cmp{a},$$version_cmp{b},$$version_cmp{relation}),
60         "Dpkg concures: Version $$version_cmp{a} $$version_cmp{relation} $$version_cmp{b}");
61 }
62