--- trunk/t/wais.t 2004/07/14 07:35:56 115 +++ trunk/t/wais.t 2004/07/14 09:48:26 116 @@ -1,18 +1,7 @@ #!/usr/bin/perl -w -# -*- Mode: Perl -*- -# $Basename: wais.t $ -# $Revision: 1.14 $ -# Author : Ulrich Pfeifer -# Created On : Tue Dec 12 16:55:05 1995 -# Last Modified By: Ulrich Pfeifer -# Last Modified On: Sat Jan 19 21:46:24 2002 -# Language : Perl -# Update Count : 192 -# Status : Unknown, Use with caution! -# -# (C) Copyright 1997, Ulrich Pfeifer, all rights reserved. -# -# + +use Test::More; +use blib; use WAIT::Database; use WAIT::Wais; @@ -20,46 +9,42 @@ use strict; use File::Path qw(mkpath rmtree); +plan tests => 10; + $SIG{__DIE__} = $SIG{INT} = \&cleanup; my $pwd = getcwd(); mkpath "/tmp/wait-test-$$"; print "$^X -Mblib blib/script/bibdb -dir /tmp/wait-test-$$ -database sample\n"; system "$^X -Mblib blib/script/bibdb -dir /tmp/wait-test-$$ -database sample > /dev/null 2>&1"; -print "1..7\n"; use Fcntl; -if (1) { + +ok( my $db = WAIT::Database->open( name => 'sample', 'directory' => "/tmp/wait-test-$$", 'mode' => O_RDWR, - ); - print "not " unless $db; - print "ok 1\n"; - my $tb = $db->table(name => 'bibdb'); - print "not " unless $tb; - print "ok 2\n"; - - print "not " unless $tb->open; - print "ok 3\n"; + ), "open"); - print "not " unless $tb->set(top => 1); - print "ok 4\n"; +ok(my $tb = $db->table(name => 'bibdb'), "table"); + +ok($tb->open, "open"); - $tb->close; - $db->close; -} +ok($tb->set(top => 1), "set(top => 1)"); +ok($tb->close, "tb->close"); +ok($db->close, "db->close"); -my $db = "/tmp/wait-test-$$/sample/bibdb"; +$db = "/tmp/wait-test-$$/sample/bibdb"; print "# Testing WAIT searches\n"; -my $result = WAIT::Wais::Search({ +ok(my $result = WAIT::Wais::Search({ 'query' => 'pfeifer', 'database' => $db, - }); + }), + "WAIT::Wais::Search"); -&headlines($result); +ok(&headlines($result), "headlines"); my @header = $result->header; my $N; @@ -70,9 +55,7 @@ my $short = ($result->header)[$N]->[6]; my $result_text = $result->text; -print $#header >= 14 ? - "ok 5\n" : - "#\$\#header[$#header]result_text[$result_text]\nnot ok 5\n"; +ok($#header >= 14, "\$\#header[$#header]result_text[$result_text]"); print "# Testing local retrieve\n"; $result = WAIT::Wais::Retrieve( @@ -83,14 +66,10 @@ ); $result_text = $result->text; $result_text =~ s/^/# /gm; -print $result_text =~ m!Pfeifer/Fuhr:93! ? - "ok 6\n" : - "# result_text[$result_text]\nnot ok 6\n"; +ok($result_text =~ m!Pfeifer/Fuhr:93!, "result_text[$result_text]"); my @x = $short->split; -print $x[2] =~ /test.ste 3585 393$/ || $x[2] == 13 ? - "ok 7\n" : - "# \@x:[@x]\nnot ok 7\n"; +ok($x[2] =~ /test.ste 3585 393$/ || $x[2] == 13, "\@x:[@x]"); #######################################################################