1 # $Id: 24-sorting.t,v 1.1 2005-11-04 17:08:20 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 24-sorting.t'
6 # ### At present, this test fails: see comment to "14-sorting.t"
10 use Test::More tests => 27;
13 BEGIN { use_ok('ZOOM') };
15 my $host = "indexdata.com/gils";
17 eval { $conn = new ZOOM::Connection($host, 0) };
18 ok(!$@, "connection to '$host'");
20 my $qstr = '@attr 1=4 map';
21 my $query = new ZOOM::Query::PQF($qstr);
22 eval { $query->sortby("1=4 <i") };
23 ok(!$@, "sort specification accepted");
25 eval { $rs = $conn->search($query) };
26 ok(!$@, "search for '$qstr'");
28 ok($n == 5, "found $n records (expected 5)");
30 $rs->option(preferredRecordSyntax => "usmarc");
31 my $previous = ""; # Sorts before all legitimate titles
32 foreach my $i (1 .. $n) {
33 my $rec = $rs->record($i-1);
34 ok(defined $rec, "got record $i of $n");
35 my $raw = $rec->raw();
36 my $marc = new_from_usmarc MARC::Record($raw);
37 my $title = $marc->title();
38 ok($title ge $previous, "title '$title' ge previous '$previous'");
42 # Now reverse the order of sorting
43 $rs->sort("dummy", "1=4 >i");
44 ### There's no way to check for success, as this is a void function
46 $previous = "z"; # Sorts after all legitimate titles
47 foreach my $i (1 .. $n) {
48 my $rec = $rs->record($i-1);
49 ok(defined $rec, "got record $i of $n");
50 my $raw = $rec->raw();
51 my $marc = new_from_usmarc MARC::Record($raw);
52 my $title = $marc->title();
53 ok($title le $previous, "title '$title' le previous '$previous'");
58 ok(1, "destroyed result-set");
60 ok(1, "destroyed connection");