New
[ZOOM-Perl-moved-to-github.git] / t / 25-scan.t
1 # $Id: 25-scan.t,v 1.1 2005-11-08 11:45:51 mike Exp $
2
3 # Before `make install' is performed this script should be runnable with
4 # `make test'. After `make install' it should work as `perl 25-scan.t'
5
6 use strict;
7 use warnings;
8 use Test::More tests => 47;
9
10 BEGIN { use_ok('ZOOM') };
11
12 my $host = "indexdata.com/gils";
13 my $conn;
14 eval { $conn = new ZOOM::Connection($host, 0) };
15 ok(!$@, "connection to '$host'");
16
17 my $startterm = "coelophysis";
18 my $ss;
19 { $ss = $conn->scan($startterm) };
20 ok(!$@, "scan for '$startterm'");
21
22 my $n = $ss->size();
23 ok(defined $n, "got size");
24 ok($n == 10, "got 10 terms");
25
26 my $previous = "";              # Sorts before all legitimate terms
27 foreach my $i (1 .. $n) {
28     my($term, $occ) = $ss->term($i-1);
29     ok(defined $term,
30        "got term $i of $n: '$term' ($occ occurences)");
31     ok($term ge $previous, "term '$term' ge previous '$previous'");
32     $previous = $term;
33     (my $disp, $occ) = $ss->display_term($i-1);
34     ok(defined $disp,
35        "display term $i of $n: '$disp' ($occ occurences)");
36     ok($disp eq $term, "display term $i identical to term");
37 }
38
39 $ss->destroy();
40 ok(1, "destroyed scanset");
41 eval { $ss->destroy() };
42 ok(defined $@ && $@ =~ /been destroy\(\)ed/,
43    "can't re-destroy scanset");
44
45 #   ### Much still to do: see comment in "15-scan.t"