Tests for the new functionality in RPM::Header
authorrjray <devnull@localhost>
Wed, 2 Aug 2000 08:23:55 +0000 (08:23 +0000)
committerrjray <devnull@localhost>
Wed, 2 Aug 2000 08:23:55 +0000 (08:23 +0000)
CVS patchset: 4000
CVS date: 2000/08/02 08:23:55

Perl-RPM/t/02_headers.t

index 1934bef..4808e92 100755 (executable)
@@ -5,7 +5,7 @@ use RPM::Database;
 
 chomp($rpmstr = qx{rpm -q rpm});
 
-print "1..11\n";
+print "1..16\n";
 
 tie %DB, "RPM::Database" or die "$RPM::err";
 
@@ -47,31 +47,58 @@ for $idx (0 .. $#rpmlines)
 }
 print "ok 5\n";
 
+# Starting with 0.27, we have a method to do that for you
+$rpmlines = $hdr->filenames;
+print "not " unless ($rpmlines and (@$rpmlines == @rpmlines));
+print "ok 6\n";
+
+for $idx (0 .. $#rpmlines)
+{
+    if ($rpmlines[$idx] ne $rpmlines->[$idx])
+    {
+       print "not ";
+       last;
+    }
+}
+print "ok 7\n";
+
 # Can't really test RPM::Header->size(), except to see that it works.
 print "not " if ($hdr->size <= 0);
-print "ok 6\n";
+print "ok 8\n";
 
 # Check tagtype()
 use RPM::Constants ':rpmtype';
 
 print "not " unless ($hdr->tagtype(q{size}) == RPM_INT32_TYPE);
-print "ok 7\n";
+print "ok 9\n";
 
 print "not " unless ($hdr->tagtype(q{dirnames}) == RPM_STRING_ARRAY_TYPE);
-print "ok 8\n";
+print "ok 10\n";
 
 # Test the NVR method
 print "not " unless ($rpmstr eq join('-', $hdr->NVR));
-print "ok 9\n";
+print "ok 11\n";
 
 # Some tests on empty RPM::Header objects
 $hdr = new RPM::Header;
 
 print "not " unless (defined $hdr and (ref($hdr) eq 'RPM::Header'));
-print "ok 10\n";
+print "ok 12\n";
 
 print "not " if (scalar($hdr->NVR));
-print "ok 11\n";
+print "ok 13\n";
 
-exit 0;
+# And now the scalar_tag predicate:
+print "not " unless (RPM::Header->scalar_tag(q{size}));
+print "ok 14\n";
 
+use RPM::Constants ':rpmtag';
+print "not " if (RPM::Header->scalar_tag(RPMTAG_DIRNAMES));
+print "ok 15\n";
+
+use RPM::Constants ':rpmerr';
+print "not " unless ((! RPM::Header->scalar_tag(q{not_a_tag})) and
+                     ($RPM::err == RPMERR_BADARG));
+print "ok 16\n";
+
+exit 0;