/[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 8 by dpavlin, Wed Jan 4 15:04:58 2006 UTC revision 9 by dpavlin, Wed Jan 4 15:28:39 2006 UTC
# Line 3  Line 3 
3  use strict;  use strict;
4  use blib;  use blib;
5    
6  use Test::More tests => 25;  use Test::More tests => 27;
7    use Test::Exception;
8    
9  BEGIN { use_ok('Search::Estraier') };  BEGIN { use_ok('Search::Estraier') };
10    
# Line 19  my $attr_data = { Line 20  my $attr_data = {
20    
21  ok(my $doc = new Search::Estraier::Document, 'new');  ok(my $doc = new Search::Estraier::Document, 'new');
22    
23    isa_ok($doc, 'Search::Estraier::Document');
24    
25  cmp_ok($doc->id, '==', -1, 'id');  cmp_ok($doc->id, '==', -1, 'id');
26    
27  ok($doc->delete, "delete");  ok($doc->delete, "delete");
# Line 34  foreach my $a (keys %{$attr_data}) { Line 37  foreach my $a (keys %{$attr_data}) {
37  ok($doc->add_text('This is a demo'), 'add_text');  ok($doc->add_text('This is a demo'), 'add_text');
38  ok($doc->add_hidden_text('This is hidden text'), 'add_hidden_text');  ok($doc->add_hidden_text('This is hidden text'), 'add_hidden_text');
39    
40    throws_ok { my $text = $doc->texts } qr/return array/, 'texts scalar';
41    ok(my @texts = $doc->texts, 'texts array');
42    
43  ok(my $draft = $doc->dump_draft, 'dump_draft');  ok(my $draft = $doc->dump_draft, 'dump_draft');
44    
45  diag "dump_draft:\n$draft";  diag "dump_draft:\n$draft";
46    
47  ok(my $doc2 = new_from_draft Search::Estraier::Document($draft), 'new_from_draft');  #ok(my $doc2 = new_from_draft Search::Estraier::Document($draft), 'new_from_draft');
48  cmp_ok($doc2->dump_draft, 'eq', $draft, 'drafts same');  #cmp_ok($doc2->dump_draft, 'eq', $draft, 'drafts same');
49    
50  cmp_ok($doc->id, '==', -1, 'id');  cmp_ok($doc->id, '==', -1, 'id');
51  cmp_ok($doc2->id, '==', -1, 'id');  #cmp_ok($doc2->id, '==', -1, 'id');
52    
53  my @attr = $doc->attr_names;  ok(my @attr = $doc->attr_names, 'attr_names');
54  diag "attr_names: ", join(',',@attr), "\n";  diag "attr_names: ", join(',',@attr), "\n";
55    
56  cmp_ok(scalar @attr, '==', 2, 'attr_names');  cmp_ok(scalar @attr, '==', 2, 'attr_names');
# Line 53  ok(! $doc->attr('foobar'), "non-existant Line 59  ok(! $doc->attr('foobar'), "non-existant
59    
60  foreach my $a (keys %{$attr_data}) {  foreach my $a (keys %{$attr_data}) {
61          cmp_ok($attr_data->{$a}, 'eq', $doc->attr($a), "attr $a = ".$attr_data->{$a});          cmp_ok($attr_data->{$a}, 'eq', $doc->attr($a), "attr $a = ".$attr_data->{$a});
62          ok($doc->add_attr($a, ''), "delete attribute");          ok($doc->add_attr($a, undef), "delete attribute");
63  }  }
64    
65    @attr = $doc->attr_names, 'attr_names';
66  #diag "attr_names left: ", join(',',$doc->attr_names), "\n";  #diag "attr_names left: ", join(',',$doc->attr_names), "\n";
67  cmp_ok($doc->attr_names, '==' , 0, "attributes removed");  cmp_ok(@attr, '==' , 0, "attributes removed");
68    
 my @texts = $doc->texts;  
69  diag "texts: ", join(',',@texts), "\n";  diag "texts: ", join(',',@texts), "\n";
70    
71  cmp_ok(scalar @texts, '==', 1, 'texts');  cmp_ok(scalar @texts, '==', 1, 'texts');
# Line 74  SKIP: { Line 80  SKIP: {
80  }  }
81    
82    
83  ok(my $snippet = $doc->make_snippet(480, 96, 96, qw(demo is)), "make_snippet");  #ok(my $snippet = $doc->make_snippet(480, 96, 96, qw(demo is)), "make_snippet");
84  diag "make_snippet:\n$snippet";  #diag "make_snippet:\n$snippet";
85    
86  ok($doc->scan_words(qw(this is demo)), "scan_words");  #ok($doc->scan_words(qw(this is demo)), "scan_words");

Legend:
Removed from v.8  
changed lines
  Added in v.9

  ViewVC Help
Powered by ViewVC 1.1.26