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