New
[ZOOM-Perl-moved-to-github.git] / t / 2-ZOOM.t
1 # $Id: 2-ZOOM.t,v 1.1 2005-10-12 09:48:21 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 ZOOM.t'
5
6 #########################
7
8 # change 'tests => 1' to 'tests => last_test_to_print';
9
10 use strict;
11 use Test::More tests => 1;
12 BEGIN { use_ok('ZOOM') };
13
14 #########################
15
16 # Insert your test code below, the Test::More module is use()ed here so read
17 # its man page ( perldoc Test::More ) for help writing this test script.
18
19 my $host = "indexdata.com/gils";
20 $host = "localhost:3950";
21 my $port = 0;
22
23 my $conn = new ZOOM::Connection($host, $port);
24
25 my $syntax = "usmarc";
26 $conn->option(preferredRecordSyntax => $syntax);
27 my $val = $conn->option("preferredRecordSyntax");
28 die "set preferredRecordSyntax to '$syntax' but got '$val'"
29     if $val ne $syntax;
30
31 my $query = '@attr 1=4 minerals';
32 my $rs = $conn->search_pqf($query);
33
34 my $n = $rs->size($rs);
35 print STDERR "Result count: $n\n";
36
37 for (my $i = 0; $i < $n; $i++) {
38     my $rec = $rs->record($i);
39     my $data = $rec->render();
40     print STDERR "=== record ", $i+1, " of $n ===\n", $data;
41     my $raw = $rec->raw();
42     print STDERR "--- raw version ---\n", $raw;
43 }
44
45 $rs->destroy();
46 $conn->destroy();