1 # $Id: 15-scan.t,v 1.1 2005-11-08 10:20:59 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 => 46;
11 BEGIN { use_ok('Net::Z3950::ZOOM') };
13 my($errcode, $errmsg, $addinfo) = (undef, "dummy", "dummy");
15 my $host = "indexdata.com/gils";
16 my $conn = Net::Z3950::ZOOM::connection_new($host, 0);
17 $errcode = Net::Z3950::ZOOM::connection_error($conn, $errmsg, $addinfo);
18 ok($errcode == 0, "connection to '$host'");
20 my $startterm = "coelophysis";
21 my $ss = Net::Z3950::ZOOM::connection_scan($conn, $startterm);
22 $errcode = Net::Z3950::ZOOM::connection_error($conn, $errmsg, $addinfo);
23 ok($errcode == 0, "scan for '$startterm'");
25 my $n = Net::Z3950::ZOOM::scanset_size($ss);
26 ok(defined $n, "got size");
27 ok($n == 10, "got 10 terms");
29 my $previous = ""; # Sorts before all legitimate terms
30 my($occ, $len) = (0, 0);
31 foreach my $i (1 .. $n) {
32 my $term = Net::Z3950::ZOOM::scanset_term($ss, $i-1, $occ, $len);
33 ok(defined $term && $len eq length($term),
34 "got term $i of $n: '$term' ($occ occurences)");
35 ok($term ge $previous, "term '$term' ge previous '$previous'");
37 my $disp = Net::Z3950::ZOOM::scanset_display_term($ss, $i-1, $occ, $len);
38 ok(defined $disp && $len eq length($disp),
39 "display term $i of $n: '$disp' ($occ occurences)");
40 ok($disp eq $term, "display term $i identical to term");
43 Net::Z3950::ZOOM::scanset_destroy($ss);
44 ok(1, "destroyed scanset");
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.