/[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

Annotation of /trunk/t/1_Document.t

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26