1 |
#!/usr/bin/perl |
2 |
# -*- Mode: Perl -*- |
3 |
# $Basename: wais.t $ |
4 |
# $Revision: 1.6 $ |
5 |
# Author : Ulrich Pfeifer |
6 |
# Created On : Tue Dec 12 16:55:05 1995 |
7 |
# Last Modified By: Ulrich Pfeifer |
8 |
# Last Modified On: Wed Nov 12 19:46:12 1997 |
9 |
# Language : Perl |
10 |
# Update Count : 157 |
11 |
# Status : Unknown, Use with caution! |
12 |
# |
13 |
# (C) Copyright 1997, Ulrich Pfeifer, all rights reserved. |
14 |
# |
15 |
# |
16 |
|
17 |
use WAIT::Database; |
18 |
use WAIT::Wais; |
19 |
use Cwd; |
20 |
use strict; |
21 |
|
22 |
$SIG{__DIE__} = $SIG{INT} = \&cleanup; |
23 |
|
24 |
my $pwd = getcwd(); |
25 |
print "$^X -Iblib blib/script/bibdb -dir /tmp -database sample\n"; |
26 |
system "$^X -Iblib blib/script/bibdb -dir /tmp -database sample > /dev/null 2>&1"; |
27 |
|
28 |
print "1..3\n"; |
29 |
my $db = '/tmp/sample/bibdb'; |
30 |
print "# Testing WAIT searches\n"; |
31 |
my $result = WAIT::Wais::Search({ |
32 |
'query' => 'pfeifer', |
33 |
'database' => $db, |
34 |
}); |
35 |
|
36 |
&headlines($result); |
37 |
my $id = ($result->header)[9]->[6]; |
38 |
#$length = ($result->header)[9]->[3]; |
39 |
my @header = $result->header; |
40 |
|
41 |
#my $types=($result->header)[9]->[5]; |
42 |
#print STDERR "\n## @$types\n"; |
43 |
|
44 |
my $short = ($result->header)[0]->[6]; |
45 |
|
46 |
my $result_text = $result->text; |
47 |
print $#header >= 14 ? |
48 |
"ok 1\n" : |
49 |
"#\$\#header[$#header]result_text[$result_text]\nnot ok 1\n"; |
50 |
|
51 |
print "# Testing local retrieve\n"; |
52 |
$result = WAIT::Wais::Retrieve( |
53 |
'database' => $db, |
54 |
'docid' => $id, |
55 |
'query' => 'pfeifer', |
56 |
'type' => 'HTML', |
57 |
); |
58 |
$result_text = $result->text; |
59 |
$result_text =~ s/^/# /gm; |
60 |
print $result_text =~ m!Pfeifer/Fuhr:93! ? |
61 |
"ok 2\n" : |
62 |
"# result_text[$result_text]\nnot ok 2\n"; |
63 |
|
64 |
my @x = $short->split; |
65 |
print $x[2] =~ /test.ste 3585 393$/ || $x[2] == 1 ? |
66 |
"ok 3\n" : |
67 |
"# \@x:[@x]\nnot ok 3\n"; |
68 |
|
69 |
|
70 |
####################################################################### |
71 |
|
72 |
sub headlines { |
73 |
my $result = shift; |
74 |
my ($tag, $score, $lines, $length, $headline, $types, $id); |
75 |
|
76 |
for ($result->header) { |
77 |
($tag, $score, $lines, $length, $headline, $types, $id) = @{$_}; |
78 |
printf "# %5d %5d %s %s\n", |
79 |
$score*1000, $lines, $headline, join(',', @{$types}); |
80 |
} |
81 |
} |
82 |
|
83 |
sub cleanup |
84 |
{ |
85 |
system 'rm -rf /tmp/sample'; |
86 |
} |
87 |
|
88 |
|
89 |
sub END |
90 |
{ |
91 |
&cleanup; |
92 |
} |