LZMA compression + tests
[slob.git] / t / Slob.t
CommitLineData
d3779104
MG
1#!/usr/bin/perl
2use strict;
3use warnings;
4
d50f3958 5use Test::More tests => 13;
d3779104
MG
6BEGIN { use_ok('Slob') };
7
d50f3958
MG
8for my $path (qw/freedict-uncompressed.slob freedict-lzma2.slob/) {
9 my $slob = Slob->new("t/$path");
d3779104 10
d50f3958 11 my $nr_of_entries = $slob->ref_count;
d3779104 12
d50f3958
MG
13 my $second_ref = $slob->seek_and_read_ref(4);
14 my $bin = $slob->seek_and_read_storage_bin($second_ref->{bin_index});
d3779104 15
d50f3958
MG
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;
d3779104 21
d50f3958 22 my $expected = <<'EOF';
d3779104
MG
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>
28EOF
d50f3958
MG
29 chomp $expected;
30 is $slob->get_entry_of_storage_bin($bin, $second_ref->{item_index}), $expected;
0e15b496 31
d50f3958
MG
32 is $slob->seek_and_read_ref_and_data(4)->{data}, $expected;
33}
This page took 0.011499 seconds and 4 git commands to generate.