From: mike Date: Tue, 11 Oct 2005 15:48:15 +0000 (+0000) Subject: Add ZOOM_ prefixes removed from function calls. X-Git-Tag: cpan_1_22~478 X-Git-Url: http://lists.indexdata.com/cgi-bin?a=commitdiff_plain;h=4aae29d3cced64580cf1d0cfe323b225dce54d1a;p=ZOOM-Perl-moved-to-github.git Add ZOOM_ prefixes removed from function calls. Use a query that gets a hit on the testing database. connection_option_set() now used to request USMARC records. Each record is now fetched and displayed in two forms: "render" (human-readable) and "raw" (not). --- diff --git a/t/Net-Z3950-ZOOM.t b/t/Net-Z3950-ZOOM.t index e919949..f629a15 100644 --- a/t/Net-Z3950-ZOOM.t +++ b/t/Net-Z3950-ZOOM.t @@ -1,4 +1,4 @@ -# $Id: Net-Z3950-ZOOM.t,v 1.3 2005-10-11 11:44:48 mike Exp $ +# $Id: Net-Z3950-ZOOM.t,v 1.4 2005-10-11 15:48:15 mike Exp $ # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl Net-Z3950-ZOOM.t' @@ -20,21 +20,35 @@ my $port = 0; my $errcode; my($errmsg, $addinfo) = ("dummy", "dummy"); -my $conn = Net::Z3950::ZOOM::ZOOM_connection_new($host, $port); -$errcode = Net::Z3950::ZOOM::ZOOM_connection_error($conn, $errmsg, $addinfo); +my $conn = Net::Z3950::ZOOM::connection_new($host, $port); +$errcode = Net::Z3950::ZOOM::connection_error($conn, $errmsg, $addinfo); if ($errcode != 0) { die("Can't connect to host '$host', port '$port': ", "errcode='$errcode', errmsg='$errmsg', addinfo='$addinfo'"); } -my $query = '@attr 1=4 taylor'; -my $rs = Net::Z3950::ZOOM::ZOOM_connection_search_pqf($conn, $query); -$errcode = Net::Z3950::ZOOM::ZOOM_connection_error($conn, $errmsg, $addinfo); +Net::Z3950::ZOOM::connection_option_set($conn, + preferredRecordSyntax => "usmarc"); + +my $query = '@attr 1=4 minerals'; +my $rs = Net::Z3950::ZOOM::connection_search_pqf($conn, $query); +$errcode = Net::Z3950::ZOOM::connection_error($conn, $errmsg, $addinfo); if ($errcode != 0) { die("Can't search for '$query': ", "errcode='$errcode', errmsg='$errmsg', addinfo='$addinfo'"); } -print STDERR "Result count: ", Net::Z3950::ZOOM::ZOOM_resultset_size($rs), "\n"; -Net::Z3950::ZOOM::ZOOM_resultset_destroy($rs); -Net::Z3950::ZOOM::ZOOM_connection_destroy($conn); +my $n = Net::Z3950::ZOOM::resultset_size($rs); +print STDERR "Result count: $n\n"; + +for (my $i = 0; $i < $n; $i++) { + my $rec = Net::Z3950::ZOOM::resultset_record($rs, $i); + my $len = 0; + my $data = Net::Z3950::ZOOM::record_get($rec, "render", $len); + print STDERR "=== record ", $i+1, " of $n ===\n", $data; + my $raw = Net::Z3950::ZOOM::record_get($rec, "raw", $len); + print STDERR "--- raw version ---\n", $raw; +} + +Net::Z3950::ZOOM::resultset_destroy($rs); +Net::Z3950::ZOOM::connection_destroy($conn);