Add bz2 and zlib support
[slob.git] / t / Slob.t
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4
5 use Test::More tests => 25;
6 BEGIN { use_ok('Slob') };
7
8 for my $path (<t/freedict-*.slob>) {
9 note "Now using $path";
10 my $slob = Slob->new($path);
11
12 my $nr_of_entries = $slob->ref_count;
13
14 my $second_ref = $slob->seek_and_read_ref(4);
15 my $bin = $slob->seek_and_read_storage_bin($second_ref->{bin_index});
16
17 is $second_ref->{key}, 'abacus';
18 is $second_ref->{bin_index}, 0;
19 is $second_ref->{item_index}, 161;
20 my $count = scalar @{$bin->{positions}};
21 is $count, 637;
22
23 my $expected = <<'EOF';
24 <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">
25 <div class="orth">abacus</div><div class="pron">æbəkəs</div></div><ol class="sense single"><li class="sense">
26 <ol class="cit single"><li class="cit trans">
27 <ol class="quote single"><li class="quote">Rechenbrett</li></ol><div class="gramGrp">
28 <div class="gen">m</div></div></li></ol></li></ol></body></html>
29 EOF
30 chomp $expected;
31 is $slob->get_entry_of_storage_bin($bin, $second_ref->{item_index}), $expected;
32
33 is $slob->seek_and_read_ref_and_data(4)->{data}, $expected;
34 }
This page took 0.025674 seconds and 4 git commands to generate.