1 # $Id: 15-scan.t,v 1.3 2005-11-08 11:45:29 mike Exp $
3 # Before `make install' is performed this script should be runnable with
4 # `make test'. After `make install' it should work as `perl 15-scan.t'
8 use Test::More tests => 47;
10 BEGIN { use_ok('Net::Z3950::ZOOM') };
12 my($errcode, $errmsg, $addinfo) = (undef, "dummy", "dummy");
14 my $host = "indexdata.com/gils";
15 my $conn = Net::Z3950::ZOOM::connection_new($host, 0);
16 $errcode = Net::Z3950::ZOOM::connection_error($conn, $errmsg, $addinfo);
17 ok($errcode == 0, "connection to '$host'");
19 my $startterm = "coelophysis";
20 my $ss = Net::Z3950::ZOOM::connection_scan($conn, $startterm);
21 $errcode = Net::Z3950::ZOOM::connection_error($conn, $errmsg, $addinfo);
22 ok($errcode == 0, "scan for '$startterm'");
24 my $n = Net::Z3950::ZOOM::scanset_size($ss);
25 ok(defined $n, "got size");
26 ok($n == 10, "got 10 terms");
28 my $previous = ""; # Sorts before all legitimate terms
29 my($occ, $len) = (0, 0);
30 foreach my $i (1 .. $n) {
31 my $term = Net::Z3950::ZOOM::scanset_term($ss, $i-1, $occ, $len);
32 ok(defined $term && $len eq length($term),
33 "got term $i of $n: '$term' ($occ occurences)");
34 ok($term ge $previous, "term '$term' ge previous '$previous'");
36 my $disp = Net::Z3950::ZOOM::scanset_display_term($ss, $i-1, $occ, $len);
37 ok(defined $disp && $len eq length($disp),
38 "display term $i of $n: '$disp' ($occ occurences)");
39 ok($disp eq $term, "display term $i identical to term");
42 Net::Z3950::ZOOM::scanset_destroy($ss);
43 ok(1, "destroyed scanset");
44 ok(1, "(can't re-destroy scanset)"); # Only meaningful in OO API.
46 # ### There remains much testing still to do with scan, but I can't
47 # do it until Adam better explains ZOOM-C's scan functionality.
48 # Specifically, there is no obvious way to scan more than ten
49 # terms, nor any obvious use for scanset_option_set() and
50 # scanset_option_get(); nor can I find a server that returns
51 # display terms different from its terms.