X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=t%2F13-resultset.t;h=b3e622590d8aa9cfe5a9c86bb1a03267d150b5f8;hb=HEAD;hp=6a5cda7ee5bc99a7dd5258ed69da0145dc17037a;hpb=e35858ff97a290c30acae73387060b0be320a7b1;p=ZOOM-Perl-moved-to-github.git diff --git a/t/13-resultset.t b/t/13-resultset.t index 6a5cda7..b3e6225 100644 --- a/t/13-resultset.t +++ b/t/13-resultset.t @@ -1,16 +1,14 @@ -# $Id: 13-resultset.t,v 1.6 2005-11-07 15:48:21 mike Exp $ - # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl 13-resultset.t' use strict; use warnings; -use Test::More tests => 23; +use Test::More tests => 24; BEGIN { use_ok('Net::Z3950::ZOOM') }; my($errcode, $errmsg, $addinfo) = (undef, "dummy", "dummy"); -my $host = "indexdata.com/gils"; +my $host = "z3950.indexdata.com/gils"; my $conn = Net::Z3950::ZOOM::connection_new($host, 0); $errcode = Net::Z3950::ZOOM::connection_error($conn, $errmsg, $addinfo); ok($errcode == 0, "connection to '$host'"); @@ -21,27 +19,32 @@ $errcode = Net::Z3950::ZOOM::connection_error($conn, $errmsg, $addinfo); ok($errcode == 0, "search for '$query'"); ok(Net::Z3950::ZOOM::resultset_size($rs) == 2, "found 2 records"); -my $syntax = "usmarc"; +my $syntax = "canmarc"; Net::Z3950::ZOOM::resultset_option_set($rs, preferredRecordSyntax => $syntax); my $val = Net::Z3950::ZOOM::resultset_option_get($rs, "preferredRecordSyntax"); ok($val eq $syntax, "preferred record syntax set to '$val'"); my $rec = Net::Z3950::ZOOM::resultset_record($rs, 0); -my $len = 0; -my $data1 = Net::Z3950::ZOOM::record_get($rec, "render", $len); +my $diagset = ""; +$errcode = Net::Z3950::ZOOM::record_error($rec, $errmsg, $addinfo, $diagset); +ok($errcode == 238, "can't fetch CANMARC ($errmsg)"); + +Net::Z3950::ZOOM::resultset_option_set($rs, preferredRecordSyntax => "usmarc"); +$rec = Net::Z3950::ZOOM::resultset_record($rs, 0); +my $data1 = Net::Z3950::ZOOM::record_get($rec, "render"); Net::Z3950::ZOOM::resultset_option_set($rs, elementSetName => "b"); -my $data2 = Net::Z3950::ZOOM::record_get($rec, "render", $len); +my $data2 = Net::Z3950::ZOOM::record_get($rec, "render"); ok($data2 eq $data1, "record doesn't know about RS options"); # Now re-fetch record from result-set with new option $rec = Net::Z3950::ZOOM::resultset_record($rs, 0); -$data2 = Net::Z3950::ZOOM::record_get($rec, "render", $len); +$data2 = Net::Z3950::ZOOM::record_get($rec, "render"); ok(length($data2) < length($data1), "re-fetched record is brief, old was full"); Net::Z3950::ZOOM::resultset_option_set($rs, preferredRecordSyntax => "xml"); $rec = Net::Z3950::ZOOM::resultset_record($rs, 0); my $cloned = Net::Z3950::ZOOM::record_clone($rec); ok(defined $cloned, "cloned record"); -$data2 = Net::Z3950::ZOOM::record_get($rec, "render", $len); +$data2 = Net::Z3950::ZOOM::record_get($rec, "render"); ok($data2 =~ /