/[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 8 - (show annotations)
Wed Jan 4 15:04:58 2006 UTC (18 years, 3 months ago) by dpavlin
File MIME type: application/x-troff
File size: 2018 byte(s)
added $doc->attr('name'), fixed $doc->add_attr('name','value');
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 #print Search::Estraier::Document::_s('foo');
11
12 #cmp_ok(Search::Estraier::Document::_s(" this is a text "), 'eq', 'this is a text', '_s - strip spaces');
13
14
15 my $attr_data = {
16 '@uri' => 'http://localhost/Search-Estraier/',
17 'size' => 42,
18 };
19
20 ok(my $doc = new Search::Estraier::Document, 'new');
21
22 cmp_ok($doc->id, '==', -1, 'id');
23
24 ok($doc->delete, "delete");
25
26 ok($doc = new Search::Estraier::Document, 'new');
27
28 foreach my $a (keys %{$attr_data}) {
29 my $d = $attr_data->{$a} || die;
30 ok($doc->add_attr($a, $d), "add_attr $a");
31 cmp_ok($doc->attr($a), 'eq', $d, "attr $a = $d");
32 }
33
34 ok($doc->add_text('This is a demo'), 'add_text');
35 ok($doc->add_hidden_text('This is hidden text'), 'add_hidden_text');
36
37 ok(my $draft = $doc->dump_draft, 'dump_draft');
38
39 diag "dump_draft:\n$draft";
40
41 ok(my $doc2 = new_from_draft Search::Estraier::Document($draft), 'new_from_draft');
42 cmp_ok($doc2->dump_draft, 'eq', $draft, 'drafts same');
43
44 cmp_ok($doc->id, '==', -1, 'id');
45 cmp_ok($doc2->id, '==', -1, 'id');
46
47 my @attr = $doc->attr_names;
48 diag "attr_names: ", join(',',@attr), "\n";
49
50 cmp_ok(scalar @attr, '==', 2, 'attr_names');
51
52 ok(! $doc->attr('foobar'), "non-existant attr");
53
54 foreach my $a (keys %{$attr_data}) {
55 cmp_ok($attr_data->{$a}, 'eq', $doc->attr($a), "attr $a = ".$attr_data->{$a});
56 ok($doc->add_attr($a, ''), "delete attribute");
57 }
58
59 #diag "attr_names left: ", join(',',$doc->attr_names), "\n";
60 cmp_ok($doc->attr_names, '==' , 0, "attributes removed");
61
62 my @texts = $doc->texts;
63 diag "texts: ", join(',',@texts), "\n";
64
65 cmp_ok(scalar @texts, '==', 1, 'texts');
66
67 SKIP: {
68 skip "est_keywords not implemented", 2;
69
70 my @keywords = $doc->keywords;
71 diag "keywords: ", join(',',@keywords), "\n";
72
73 cmp_ok(scalar @keywords, '==', 1, 'keywords');
74 }
75
76
77 ok(my $snippet = $doc->make_snippet(480, 96, 96, qw(demo is)), "make_snippet");
78 diag "make_snippet:\n$snippet";
79
80 ok($doc->scan_words(qw(this is demo)), "scan_words");

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26