/[SWISH-PlusPlus]/trunk/t/01swish.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/01swish.t

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

revision 20 by dpavlin, Sun Dec 5 21:50:47 2004 UTC revision 22 by dpavlin, Tue Dec 7 16:05:43 2004 UTC
# Line 2  Line 2 
2    
3  use strict;  use strict;
4    
5  use Test::More tests => 47;  use Test::More tests => 56;
6  use Test::Exception;  use Test::Exception;
7  use blib;  use blib;
8    
# Line 16  throws_ok { SWISH::PlusPlus->new() } qr/ Line 16  throws_ok { SWISH::PlusPlus->new() } qr/
16    
17  ## FIXME  ## FIXME
18  my $index = '/tmp/swish-pp';  my $index = '/tmp/swish-pp';
19    my $debug = 0;
20    $debug = 4 if (@ARGV);
21    
22  $i = SWISH::PlusPlus->new(  $i = SWISH::PlusPlus->new(
23          index_dir => $index,          index_dir => $index,
24          meta_in_body => 1,          meta_in_body => 1,
25  #       debug => 1,          debug => $debug,
26  );  );
27  ok($i, "open index");  ok($i, "open index");
28    
# Line 61  foreach my $word (qw(meaning of life)) { Line 63  foreach my $word (qw(meaning of life)) {
63          cmp_ok(scalar @r, '==', 1, "find $word");          cmp_ok(scalar @r, '==', 1, "find $word");
64  }  }
65    
66  # test_find('words to test against meta','meta')  # test_find('words to test against meta','meta', nr_results)
67  sub test_find {  sub test_find {
68          my $words = shift || die "no words?";          my $words = shift || die "no words?";
69          my $meta = shift;          my $meta = shift;
70            my $nr = shift;
71    
72            $nr = 1 unless defined($nr);
73    
74          foreach my $word (split(/\s+/,$words)) {          foreach my $word (split(/\s+/,$words)) {
75                  my $path;                  my $path;
# Line 72  sub test_find { Line 77  sub test_find {
77                  $q = "$meta=($word)" if ($meta);                  $q = "$meta=($word)" if ($meta);
78                                    
79                  my @r = $i->search($q);                  my @r = $i->search($q);
80                  cmp_ok(scalar @r, '==', 1, "search $q");                  cmp_ok(scalar @r, '==', $nr, "search $q - $nr results");
81                  if ($meta) {                  if ($meta) {
82                          like($i->property(shift @r, $meta), qr/$word/i, "find $word in $meta property");                          like($i->property(shift @r, $meta), qr/$word/i, "find $word in $meta property");
83                          cmp_ok(scalar $i->search("$word"), '==', 1, "find $word anywhere");                          cmp_ok(scalar $i->search("$word"), '==', $nr, "find $word anywhere -- $nr results");
84                  }                  }
85                                    
86          }          }
# Line 87  foreach (qw(title author date comment)) Line 92  foreach (qw(title author date comment))
92          test_find(( $data->{$_} || $data->{'meta'}->{$_} ), $_);          test_find(( $data->{$_} || $data->{'meta'}->{$_} ), $_);
93  }  }
94    
95    ok($i->delete("life"), "delete life");
96    ok($i->{'_deleted'}->{'life'}, "life marked as deleted");
97    
98    ok($i->finish_update, "finish_update");
99    
100    test_find($data->{'body'}, undef, '0');

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

  ViewVC Help
Powered by ViewVC 1.1.26