Add bz2 and zlib support
[slob.git] / t / Slob.t
index b0ab28f8921c9a35d591948e041f5b5e302fb957..70bc6e2a3399162f1a2de504ffc4ebb9dfdd45a0 100644 (file)
--- a/t/Slob.t
+++ b/t/Slob.t
@@ -2,28 +2,33 @@
 use strict;
 use warnings;
 
-use Test::More tests => 6;
+use Test::More tests => 25;
 BEGIN { use_ok('Slob') };
 
-my $slob = Slob->new('t/freedict-01.slob');
+for my $path (<t/freedict-*.slob>) {
+       note "Now using $path";
+       my $slob = Slob->new($path);
 
-my $nr_of_entries = $slob->ref_count;
+       my $nr_of_entries = $slob->ref_count;
 
-my $second_ref = $slob->seek_and_read_ref(4);
-my $bin = $slob->seek_and_read_storage_bin($second_ref->{bin_index});
+       my $second_ref = $slob->seek_and_read_ref(4);
+       my $bin = $slob->seek_and_read_storage_bin($second_ref->{bin_index});
 
-is $second_ref->{key}, 'abacus';
-is $second_ref->{bin_index}, 0;
-is $second_ref->{item_index}, 161;
-my $count = scalar @{$bin->{positions}};
-is $count, 637;
+       is $second_ref->{key}, 'abacus';
+       is $second_ref->{bin_index}, 0;
+       is $second_ref->{item_index}, 161;
+       my $count = scalar @{$bin->{positions}};
+       is $count, 637;
 
-my $expected = <<'EOF';
+       my $expected = <<'EOF';
 <html><head><link href="~/css/default.css" rel="stylesheet" type="text/css"><link href="~/css/night.css" rel="alternate stylesheet" title="Night" type="text/css"></head><script src="~/js/styleswitcher.js"></script><body><div class="form">
           <div class="orth">abacus</div><div class="pron">æbəkəs</div></div><ol class="sense single"><li class="sense">
           <ol class="cit single"><li class="cit trans">
             <ol class="quote single"><li class="quote">Rechenbrett</li></ol><div class="gramGrp">
               <div class="gen">m</div></div></li></ol></li></ol></body></html>
 EOF
-chomp $expected;
-is $slob->get_entry_of_storage_bin($bin, $second_ref->{item_index}), $expected;
+       chomp $expected;
+       is $slob->get_entry_of_storage_bin($bin, $second_ref->{item_index}), $expected;
+
+       is $slob->seek_and_read_ref_and_data(4)->{data}, $expected;
+}
This page took 0.010414 seconds and 4 git commands to generate.