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