diff options
author | Thierry Vignaud <tv@mageia.org> | 2012-06-25 18:20:01 +0000 |
---|---|---|
committer | Thierry Vignaud <tv@mageia.org> | 2012-06-25 18:20:01 +0000 |
commit | 4e573e14073b99b2b422f1fef4ef7cbb97fecf37 (patch) | |
tree | 380b474d71f4c3d44b1890b692482cf9a0b17b51 | |
parent | 0331c9f5dec24ba8f853b0c554b0462d10390cb8 (diff) | |
download | perl-URPM-4e573e14073b99b2b422f1fef4ef7cbb97fecf37.tar perl-URPM-4e573e14073b99b2b422f1fef4ef7cbb97fecf37.tar.gz perl-URPM-4e573e14073b99b2b422f1fef4ef7cbb97fecf37.tar.bz2 perl-URPM-4e573e14073b99b2b422f1fef4ef7cbb97fecf37.tar.xz perl-URPM-4e573e14073b99b2b422f1fef4ef7cbb97fecf37.zip |
check flag getters & setters
-rw-r--r-- | t/01setter-getter.t | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/t/01setter-getter.t b/t/01setter-getter.t new file mode 100644 index 0000000..871433d --- /dev/null +++ b/t/01setter-getter.t @@ -0,0 +1,69 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use Test::More tests => 63; +use URPM; + + +chdir 't' if -d 't'; + +my $u = URPM->new; +ok($u, 'URPM'); + +$u->parse_rpm("tmp/RPMS/noarch/test-rpm-1.0-1mdk.noarch.rpm"); +ok(@{$u->{depslist}} == 1, 'depslist'); + +my $pkg = $u->{depslist}[0]; +ok($pkg, 'Package'); + +is($pkg->rflags, undef, 'default rflags'); +is($pkg->set_rflags(1, 3), undef, 'storing rflags'); +is(join(',', $pkg->set_rflags(1, 4)), "1,3", 'storing rflags'); +is(join(',', $pkg->rflags), "1,4", 'retrieving stored rflags'); + +######################################## + +test_flags($pkg, ()); + +$pkg->set_flag_skip; +test_flags($pkg, skip => 33554432); +$pkg->set_flag_skip(0); + +$pkg->set_flag_base; +test_flags($pkg, base => 16777216); +$pkg->set_flag_base(0); + +$pkg->set_flag_installed; +test_flags($pkg, installed => 134217728); +$pkg->set_flag_installed(0); + +$pkg->set_flag_upgrade; +test_flags($pkg, upgrade => 1073741824); +$pkg->set_flag_upgrade(0); + +$pkg->set_flag_required; +test_flags($pkg, required => 536870912); +$pkg->set_flag_required(0); + +$pkg->set_flag_requested; +test_flags($pkg, requested => 268435456); +$pkg->set_flag_requested(0); + +$pkg->set_flag_disable_obsolete; +test_flags($pkg, disable_obsolete => 67108864); +$pkg->set_flag_disable_obsolete(0); + +sub test_flags { + my ($pkg, %flags) = @_; + is($pkg->flag_base, $flags{base} || 0, 'base flag'); + is($pkg->flag_skip, $flags{skip} || 0, 'skip flag'); + is($pkg->flag_disable_obsolete, $flags{disable_obsolete} || 0, 'disable_obsolete flag'); + is($pkg->flag_installed, $flags{installed} || 0, 'installed flag'); + is($pkg->flag_requested, $flags{requested} || 0, 'requested flag'); + is($pkg->flag_required, $flags{required} || 0, 'required flag'); + is($pkg->flag_upgrade, $flags{upgrade} || 0, 'upgrade flag'); +} + + + |