First five matrix tests
[Fedora-Rebuild.git] / t / 02is_satisfied.t
blobed1a662fd456a70d399ad0dabe4bfa80ace4c52b
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4 use lib qw(..);
6 use Test::Simple tests => 4 + 5;
8 use Fedora::Rebuild::RPM;
10 # The ok() labels have format "REQUIRES ? COMMA_SEPARATED_PROVIDES".
11 # Non-flag-qualified cases
12 ok(
13 Fedora::Rebuild::RPM::is_satisfied(
14 'a', Fedora::Rebuild::RPM::ANY, '',
16 'a' => [ [Fedora::Rebuild::RPM::ANY, ''] ]
18 ), 'a ? a'
21 ok(
22 ! Fedora::Rebuild::RPM::is_satisfied(
23 'a', Fedora::Rebuild::RPM::ANY, '',
25 'b' => [ [Fedora::Rebuild::RPM::ANY, ''] ]
27 ), 'a ? b'
30 ok(
31 Fedora::Rebuild::RPM::is_satisfied(
32 'a', Fedora::Rebuild::RPM::ANY, '',
34 'b' => [ [Fedora::Rebuild::RPM::ANY, ''] ],
35 'a' => [ [Fedora::Rebuild::RPM::ANY, ''] ],
36 'c' => [ [Fedora::Rebuild::RPM::ANY, ''] ]
38 ), 'a ? b, a, c'
41 ok(
42 ! Fedora::Rebuild::RPM::is_satisfied(
43 'a', Fedora::Rebuild::RPM::ANY, '',
46 ), 'a ? '
50 # Matrix cases. See module comments for the matrices. There should be 3*5*5
51 # cases in total.
52 sub matrix_test {
53 my ($order, $rflag, $pflag, $result) = @_;
55 my ($rversion, $pversion) = (1, 1);
56 if ($order < 0) {
57 $rversion = 0;
58 } elsif ($order > 0) {
59 $rversion = 2;
62 ok(
63 $result == Fedora::Rebuild::RPM::is_satisfied(
64 'a', $rflag, $rversion,
66 'a' => [ [$pflag, $pversion] ]
69 'a ' . Fedora::Rebuild::RPM::flag_as_string($rflag) . " $rversion" .
70 ' ? a ' . Fedora::Rebuild::RPM::flag_as_string($pflag) .
71 " $pversion"
75 matrix_test(0, Fedora::Rebuild::RPM::LESS, Fedora::Rebuild::RPM::LESS, 1);
76 matrix_test(0, Fedora::Rebuild::RPM::LESS,
77 Fedora::Rebuild::RPM::LESS|Fedora::Rebuild::RPM::EQUAL, 1);
78 matrix_test(0, Fedora::Rebuild::RPM::LESS, Fedora::Rebuild::RPM::EQUAL, 0);
79 matrix_test(0, Fedora::Rebuild::RPM::LESS,
80 Fedora::Rebuild::RPM::GREATER|Fedora::Rebuild::RPM::EQUAL, 0);
81 matrix_test(0, Fedora::Rebuild::RPM::LESS, Fedora::Rebuild::RPM::GREATER, 0);