/[Search-Estraier]/trunk/t/3_ResultDocument.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/3_ResultDocument.t

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

revision 22 by dpavlin, Thu Jan 5 13:55:17 2006 UTC revision 23 by dpavlin, Thu Jan 5 14:30:42 2006 UTC
# Line 3  Line 3 
3  use strict;  use strict;
4  use blib;  use blib;
5    
6  use Test::More tests => 4;  use Test::More tests => 12;
7  use Test::Exception;  use Test::Exception;
8  #use Data::Dumper;  use Data::Dumper;
9    
10  BEGIN { use_ok('Search::Estraier') };  BEGIN { use_ok('Search::Estraier') };
11    
12  dies_ok { new Search::Estraier::ResultDocument } "new without args";  my $doc = {
 ok(my $rdoc = new Search::Estraier::ResultDocument(  
13          uri => 'file:///foo',          uri => 'file:///foo',
14          attrs => {          attrs => {
15                  foo => 1,                  foo => 1,
# Line 18  ok(my $rdoc = new Search::Estraier::Resu Line 17  ok(my $rdoc = new Search::Estraier::Resu
17          },          },
18          snippet => 'none at all',          snippet => 'none at all',
19          keywords => "foo\tbar\tbaz\tboo",          keywords => "foo\tbar\tbaz\tboo",
20  ), 'new');  };
21    
22    dies_ok { new Search::Estraier::ResultDocument } "new without args";
23    ok(my $rdoc = new Search::Estraier::ResultDocument( %$doc ), 'new');
24  isa_ok($rdoc, 'Search::Estraier::ResultDocument');  isa_ok($rdoc, 'Search::Estraier::ResultDocument');
25    
26    cmp_ok($rdoc->uri, 'eq', $doc->{uri}, 'uri');
27    
28    ok(my @attr_names = keys %{ $doc->{attrs} }, "attr_names from original");
29    ok(my @rdoc_attr_names = $rdoc->attr_names, "attr_names from rdoc");
30    ok(eq_set(\@rdoc_attr_names, \@attr_names), 'attr_names comparison');
31    
32    foreach my $attr (keys %{ $doc->{attrs} }) {
33            cmp_ok($rdoc->attr($attr), 'eq', $doc->{attrs}->{$attr}, "attr: $attr");
34    }
35    
36    cmp_ok($rdoc->snippet, 'eq', $doc->{snippet}, 'snippet');
37    cmp_ok($rdoc->keywords, 'eq', $doc->{keywords}, 'keywords');

Legend:
Removed from v.22  
changed lines
  Added in v.23

  ViewVC Help
Powered by ViewVC 1.1.26