--- trunk/t/swish.t 2004/12/03 23:30:22 7 +++ trunk/t/swish.t 2004/12/05 00:59:50 9 @@ -2,8 +2,9 @@ use strict; -use Test::More tests => 8; +use Test::More tests => 22; use Test::Exception; +use lib '.'; use blib; BEGIN { @@ -19,6 +20,8 @@ $i = SWISH::PlusPlus->open( index_dir => $index, + debug => 0, + meta_in_body => 1, ); ok($i, "open index"); @@ -30,8 +33,24 @@ ok($i->index_document( 42 => 'meaning of life' ), "index 42"); +ok($i->add( + path => 'life', + title => 'Ultimate question answer found here', + body => '42 is answer to all questions' +), "index life"); + # add one dummy document so that swish++ won't reject all words # with index of just one document ok($i->index_document( _dummy_ => '' ), "fillter"); cmp_ok($i->{'index_dir'}, 'eq', $index, "index_dir ok"); + +foreach my $word (qw(meaning of life)) { + my @r = $i->search($word); + cmp_ok(scalar @r, '==', 1, "find $word"); +} + +foreach my $word (qw(Ultimate question answer found here)) { + cmp_ok(scalar $i->search("title=($word)"), '==', 1, "find $word in title"); + cmp_ok(scalar $i->search("$word"), '==', 1, "find $word anywhere"); +}