/[wait]/trunk/t/wais.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/wais.t

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

revision 115 by dpavlin, Mon May 24 13:44:01 2004 UTC revision 116 by dpavlin, Wed Jul 14 09:48:26 2004 UTC
# Line 1  Line 1 
1  #!/usr/bin/perl -w  #!/usr/bin/perl -w
2  #                              -*- Mode: Perl -*-  
3  # $Basename: wais.t $  use Test::More;
4  # $Revision: 1.14 $  use blib;
 # 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.  
 #  
 #  
5    
6  use WAIT::Database;  use WAIT::Database;
7  use WAIT::Wais;  use WAIT::Wais;
# Line 20  use Cwd; Line 9  use Cwd;
9  use strict;  use strict;
10  use File::Path qw(mkpath rmtree);  use File::Path qw(mkpath rmtree);
11    
12    plan tests => 10;
13    
14  $SIG{__DIE__} = $SIG{INT} = \&cleanup;  $SIG{__DIE__} = $SIG{INT} = \&cleanup;
15    
16  my $pwd = getcwd();  my $pwd = getcwd();
17  mkpath "/tmp/wait-test-$$";  mkpath "/tmp/wait-test-$$";
18  print  "$^X -Mblib blib/script/bibdb -dir /tmp/wait-test-$$ -database sample\n";  print  "$^X -Mblib blib/script/bibdb -dir /tmp/wait-test-$$ -database sample\n";
19  system "$^X -Mblib blib/script/bibdb -dir /tmp/wait-test-$$ -database sample > /dev/null 2>&1";  system "$^X -Mblib blib/script/bibdb -dir /tmp/wait-test-$$ -database sample > /dev/null 2>&1";
 print "1..7\n";  
20    
21  use Fcntl;  use Fcntl;
22  if (1) {  
23    ok(
24    my $db = WAIT::Database->open(    my $db = WAIT::Database->open(
25                                  name        => 'sample',                                  name        => 'sample',
26                                  'directory' => "/tmp/wait-test-$$",                                  'directory' => "/tmp/wait-test-$$",
27                                  'mode'      => O_RDWR,                                  'mode'      => O_RDWR,
28                                 );    ), "open");
   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";  
29    
30    print "not " unless $tb->set(top => 1);  ok(my $tb = $db->table(name => 'bibdb'), "table");
31    print "ok 4\n";    
32    ok($tb->open, "open");
33    
34    $tb->close;  ok($tb->set(top => 1), "set(top => 1)");
   $db->close;  
 }  
35    
36    ok($tb->close, "tb->close");
37    ok($db->close, "db->close");
38    
39  my $db = "/tmp/wait-test-$$/sample/bibdb";  $db = "/tmp/wait-test-$$/sample/bibdb";
40  print "# Testing WAIT searches\n";  print "# Testing WAIT searches\n";
41  my $result = WAIT::Wais::Search({  ok(my $result = WAIT::Wais::Search({
42                                   'query'    => 'pfeifer',                                   'query'    => 'pfeifer',
43                                   'database' => $db,                                   'database' => $db,
44                                  });                                  }),
45      "WAIT::Wais::Search");
46    
47  &headlines($result);  ok(&headlines($result), "headlines");
48    
49  my @header = $result->header;  my @header = $result->header;
50  my $N;  my $N;
# Line 70  my $id    = ($result->header)[$N]->[6]; Line 55  my $id    = ($result->header)[$N]->[6];
55  my $short = ($result->header)[$N]->[6];  my $short = ($result->header)[$N]->[6];
56    
57  my $result_text = $result->text;  my $result_text = $result->text;
58  print $#header >= 14 ?  ok($#header >= 14, "\$\#header[$#header]result_text[$result_text]");
     "ok 5\n" :  
     "#\$\#header[$#header]result_text[$result_text]\nnot ok 5\n";  
59    
60  print "# Testing local retrieve\n";  print "# Testing local retrieve\n";
61  $result = WAIT::Wais::Retrieve(  $result = WAIT::Wais::Retrieve(
# Line 83  $result = WAIT::Wais::Retrieve( Line 66  $result = WAIT::Wais::Retrieve(
66                               );                               );
67  $result_text = $result->text;  $result_text = $result->text;
68  $result_text =~ s/^/# /gm;  $result_text =~ s/^/# /gm;
69  print $result_text =~ m!Pfeifer/Fuhr:93! ?  ok($result_text =~ m!Pfeifer/Fuhr:93!, "result_text[$result_text]");
     "ok 6\n" :  
     "# result_text[$result_text]\nnot ok 6\n";  
70    
71  my @x = $short->split;  my @x = $short->split;
72  print $x[2] =~ /test.ste 3585 393$/ || $x[2] == 13 ?  ok($x[2] =~ /test.ste 3585 393$/ || $x[2] == 13, "\@x:[@x]");
     "ok 7\n" :  
     "# \@x:[@x]\nnot ok 7\n";  
73    
74    
75  #######################################################################  #######################################################################

Legend:
Removed from v.115  
changed lines
  Added in v.116

  ViewVC Help
Powered by ViewVC 1.1.26