]>
Commit | Line | Data |
---|---|---|
d3779104 MG |
1 | #!/usr/bin/perl |
2 | use strict; | |
3 | use warnings; | |
4 | ||
1ca60f55 | 5 | use Test::More tests => 25; |
d3779104 MG |
6 | BEGIN { use_ok('Slob') }; |
7 | ||
1ca60f55 MG |
8 | for my $path (<t/freedict-*.slob>) { |
9 | note "Now using $path"; | |
10 | my $slob = Slob->new($path); | |
d3779104 | 11 | |
d50f3958 | 12 | my $nr_of_entries = $slob->ref_count; |
d3779104 | 13 | |
d50f3958 MG |
14 | my $second_ref = $slob->seek_and_read_ref(4); |
15 | my $bin = $slob->seek_and_read_storage_bin($second_ref->{bin_index}); | |
d3779104 | 16 | |
d50f3958 MG |
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; | |
d3779104 | 22 | |
d50f3958 | 23 | my $expected = <<'EOF'; |
d3779104 MG |
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 | |
d50f3958 MG |
30 | chomp $expected; |
31 | is $slob->get_entry_of_storage_bin($bin, $second_ref->{item_index}), $expected; | |
0e15b496 | 32 | |
d50f3958 MG |
33 | is $slob->seek_and_read_ref_and_data(4)->{data}, $expected; |
34 | } |