/[Search-Estraier]/trunk/t/1_document.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/t/1_document.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations)
Wed Jan 4 13:11:43 2006 UTC (18 years, 3 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1816 byte(s)
begin work on pure perl implementation of HyperEstraier module
1 #!/usr/bin/perl -w
2
3 use strict;
4 use blib;
5
6 use Test::More tests => 25;
7
8 BEGIN { use_ok('Search::Estraier') };
9
10 my $attr_data = {
11 '@uri' => 'http://localhost/Search-Estraier/',
12 'size' => 42,
13 };
14
15 ok(my $estdoc = new Search::Estraier::Document, 'new');
16
17 ok($estdoc->delete, "delete");
18
19 ok($estdoc = new Search::Estraier::Document, 'new');
20
21 foreach my $a (keys %{$attr_data}) {
22 ok($estdoc->add_attr($a, $attr_data->{$a}), "add_attr $a");
23 }
24
25 ok($estdoc->add_text('This is a demo'), 'add_text');
26 ok($estdoc->add_hidden_text('This is hidden text'), 'add_hidden_text');
27
28 ok(my $draft = $estdoc->dump_draft, 'dump_draft');
29
30 diag "dump_draft:\n$draft";
31
32 ok(my $estdoc2 = new_from_draft Search::Estraier::Document($draft), 'new_from_draft');
33 cmp_ok($estdoc2->dump_draft, 'eq', $draft, 'drafts same');
34
35 cmp_ok($estdoc->id, '==', -1, 'id');
36 cmp_ok($estdoc2->id, '==', -1, 'id');
37
38 my @attr = $estdoc->attr_names;
39 diag "attr_names: ", join(',',@attr), "\n";
40
41 cmp_ok(scalar @attr, '==', 2, 'attr_names');
42
43 ok(! $estdoc->attr('foobar'), "non-existant attr");
44
45 foreach my $a (keys %{$attr_data}) {
46 cmp_ok($attr_data->{$a}, 'eq', $estdoc->attr($a), "attr $a = ".$attr_data->{$a});
47 ok($estdoc->add_attr($a, ''), "delete attribute");
48 }
49
50 #diag "attr_names left: ", join(',',$estdoc->attr_names), "\n";
51 cmp_ok($estdoc->attr_names, '==' , 0, "attributes removed");
52
53 my @texts = $estdoc->texts;
54 diag "texts: ", join(',',@texts), "\n";
55
56 cmp_ok(scalar @texts, '==', 1, 'texts');
57
58 SKIP: {
59 skip "est_keywords not implemented", 2;
60
61 my @keywords = $estdoc->keywords;
62 diag "keywords: ", join(',',@keywords), "\n";
63
64 cmp_ok(scalar @keywords, '==', 1, 'keywords');
65 }
66
67
68 ok(my $snippet = $estdoc->make_snippet(480, 96, 96, qw(demo is)), "make_snippet");
69 diag "make_snippet:\n$snippet";
70
71 ok($estdoc->scan_words(qw(this is demo)), "scan_words");

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26