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

Diff of /trunk/t/1_document.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 5 by dpavlin, Wed Jan 4 13:33:07 2006 UTC revision 6 by dpavlin, Wed Jan 4 14:48:11 2006 UTC
# Line 17  my $attr_data = { Line 17  my $attr_data = {
17          'size' => 42,          'size' => 42,
18  };  };
19    
20  ok(my $estdoc = new Search::Estraier::Document, 'new');  ok(my $doc = new Search::Estraier::Document, 'new');
21    
22  ok($estdoc->delete, "delete");  cmp_ok($doc->id, '==', -1, 'id');
23    
24  ok($estdoc = new Search::Estraier::Document, 'new');  ok($doc->delete, "delete");
25    
26    ok($doc = new Search::Estraier::Document, 'new');
27    
28  foreach my $a (keys %{$attr_data}) {  foreach my $a (keys %{$attr_data}) {
29          ok($estdoc->add_attr($a, $attr_data->{$a}), "add_attr $a");          ok($doc->add_attr($a, $attr_data->{$a}), "add_attr $a");
30  }  }
31    
32  ok($estdoc->add_text('This is a demo'), 'add_text');  ok($doc->add_text('This is a demo'), 'add_text');
33  ok($estdoc->add_hidden_text('This is hidden text'), 'add_hidden_text');  ok($doc->add_hidden_text('This is hidden text'), 'add_hidden_text');
34    
35  ok(my $draft = $estdoc->dump_draft, 'dump_draft');  ok(my $draft = $doc->dump_draft, 'dump_draft');
36    
37  diag "dump_draft:\n$draft";  diag "dump_draft:\n$draft";
38    
39  ok(my $estdoc2 = new_from_draft Search::Estraier::Document($draft), 'new_from_draft');  ok(my $doc2 = new_from_draft Search::Estraier::Document($draft), 'new_from_draft');
40  cmp_ok($estdoc2->dump_draft, 'eq', $draft, 'drafts same');  cmp_ok($doc2->dump_draft, 'eq', $draft, 'drafts same');
41    
42  cmp_ok($estdoc->id, '==', -1, 'id');  cmp_ok($doc->id, '==', -1, 'id');
43  cmp_ok($estdoc2->id, '==', -1, 'id');  cmp_ok($doc2->id, '==', -1, 'id');
44    
45  my @attr = $estdoc->attr_names;  my @attr = $doc->attr_names;
46  diag "attr_names: ", join(',',@attr), "\n";  diag "attr_names: ", join(',',@attr), "\n";
47    
48  cmp_ok(scalar @attr, '==', 2, 'attr_names');  cmp_ok(scalar @attr, '==', 2, 'attr_names');
49    
50  ok(! $estdoc->attr('foobar'), "non-existant attr");  ok(! $doc->attr('foobar'), "non-existant attr");
51    
52  foreach my $a (keys %{$attr_data}) {  foreach my $a (keys %{$attr_data}) {
53          cmp_ok($attr_data->{$a}, 'eq', $estdoc->attr($a), "attr $a = ".$attr_data->{$a});          cmp_ok($attr_data->{$a}, 'eq', $doc->attr($a), "attr $a = ".$attr_data->{$a});
54          ok($estdoc->add_attr($a, ''), "delete attribute");          ok($doc->add_attr($a, ''), "delete attribute");
55  }  }
56    
57  #diag "attr_names left: ", join(',',$estdoc->attr_names), "\n";  #diag "attr_names left: ", join(',',$doc->attr_names), "\n";
58  cmp_ok($estdoc->attr_names, '==' , 0, "attributes removed");  cmp_ok($doc->attr_names, '==' , 0, "attributes removed");
59    
60  my @texts = $estdoc->texts;  my @texts = $doc->texts;
61  diag "texts: ", join(',',@texts), "\n";  diag "texts: ", join(',',@texts), "\n";
62    
63  cmp_ok(scalar @texts, '==', 1, 'texts');  cmp_ok(scalar @texts, '==', 1, 'texts');
# Line 63  cmp_ok(scalar @texts, '==', 1, 'texts'); Line 65  cmp_ok(scalar @texts, '==', 1, 'texts');
65  SKIP: {  SKIP: {
66          skip "est_keywords not implemented", 2;          skip "est_keywords not implemented", 2;
67    
68          my @keywords = $estdoc->keywords;          my @keywords = $doc->keywords;
69          diag "keywords: ", join(',',@keywords), "\n";          diag "keywords: ", join(',',@keywords), "\n";
70    
71          cmp_ok(scalar @keywords, '==', 1, 'keywords');          cmp_ok(scalar @keywords, '==', 1, 'keywords');
72  }  }
73    
74    
75  ok(my $snippet = $estdoc->make_snippet(480, 96, 96, qw(demo is)), "make_snippet");  ok(my $snippet = $doc->make_snippet(480, 96, 96, qw(demo is)), "make_snippet");
76  diag "make_snippet:\n$snippet";  diag "make_snippet:\n$snippet";
77    
78  ok($estdoc->scan_words(qw(this is demo)), "scan_words");  ok($doc->scan_words(qw(this is demo)), "scan_words");

Legend:
Removed from v.5  
changed lines
  Added in v.6

  ViewVC Help
Powered by ViewVC 1.1.26