From: mike Date: Wed, 12 Oct 2005 09:48:05 +0000 (+0000) Subject: Rename Net-Z3950-ZOOM.t to 1-Net-Z3950-ZOOM.t X-Git-Tag: cpan_1_22~473 X-Git-Url: http://lists.indexdata.com/cgi-bin?a=commitdiff_plain;h=b7fe2b713a95db1a7e54accfebee5ec3f4533759;p=ZOOM-Perl-moved-to-github.git Rename Net-Z3950-ZOOM.t to 1-Net-Z3950-ZOOM.t --- diff --git a/t/1-Net-Z3950-ZOOM.t b/t/1-Net-Z3950-ZOOM.t new file mode 100644 index 0000000..1aa8348 --- /dev/null +++ b/t/1-Net-Z3950-ZOOM.t @@ -0,0 +1,61 @@ +# $Id: 1-Net-Z3950-ZOOM.t,v 1.1 2005-10-12 09:48:05 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' + +######################### + +# change 'tests => 1' to 'tests => last_test_to_print'; + +use strict; +use Test::More tests => 1; +BEGIN { use_ok('Net::Z3950::ZOOM') }; + +######################### + +# Insert your test code below, the Test::More module is use()ed here so read +# its man page ( perldoc Test::More ) for help writing this test script. + +my $host = "indexdata.com/gils"; +$host = "localhost:3950"; +my $port = 0; +my $errcode; +my($errmsg, $addinfo) = ("dummy", "dummy"); + +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 $syntax = "usmarc"; +Net::Z3950::ZOOM::connection_option_set($conn, + preferredRecordSyntax => $syntax); +my $val = Net::Z3950::ZOOM::connection_option_get($conn, + "preferredRecordSyntax"); +die "set preferredRecordSyntax to '$syntax' but got '$val'" + if $val ne $syntax; + +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'"); +} + +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); diff --git a/t/Net-Z3950-ZOOM.t b/t/Net-Z3950-ZOOM.t deleted file mode 100644 index 1764d64..0000000 --- a/t/Net-Z3950-ZOOM.t +++ /dev/null @@ -1,61 +0,0 @@ -# $Id: Net-Z3950-ZOOM.t,v 1.5 2005-10-12 09:47:11 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' - -######################### - -# change 'tests => 1' to 'tests => last_test_to_print'; - -use strict; -use Test::More tests => 1; -BEGIN { use_ok('Net::Z3950::ZOOM') }; - -######################### - -# Insert your test code below, the Test::More module is use()ed here so read -# its man page ( perldoc Test::More ) for help writing this test script. - -my $host = "indexdata.com/gils"; -$host = "localhost:3950"; -my $port = 0; -my $errcode; -my($errmsg, $addinfo) = ("dummy", "dummy"); - -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 $syntax = "usmarc"; -Net::Z3950::ZOOM::connection_option_set($conn, - preferredRecordSyntax => $syntax); -my $val = Net::Z3950::ZOOM::connection_option_get($conn, - "preferredRecordSyntax"); -die "set preferredRecordSyntax to '$syntax' but got '$val'" - if $val ne $syntax; - -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'"); -} - -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);