From 0241fe26efe8116eb4635ac088acbb1e8e3159a4 Mon Sep 17 00:00:00 2001 From: mike Date: Mon, 31 Oct 2005 15:04:04 +0000 Subject: [PATCH] Check size of result-set arising from search on created query, check returned record, destroy all objects. --- t/12-query.t | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/t/12-query.t b/t/12-query.t index 824ae69..4e5764b 100644 --- a/t/12-query.t +++ b/t/12-query.t @@ -1,11 +1,11 @@ -# $Id: 12-query.t,v 1.2 2005-10-26 16:31:39 mike Exp $ +# $Id: 12-query.t,v 1.3 2005-10-31 15:04:04 mike Exp $ # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl 12-query.t' use strict; use warnings; -use Test::More tests => 15; +use Test::More tests => 20; BEGIN { use_ok('Net::Z3950::ZOOM') }; my $q = Net::Z3950::ZOOM::query_create(); @@ -50,11 +50,31 @@ my($errcode, $errmsg, $addinfo) = (undef, "dummy", "dummy"); $errcode = Net::Z3950::ZOOM::connection_error($conn, $errmsg, $addinfo); ok($errcode == 0, "connection to '$host'"); +Net::Z3950::ZOOM::connection_option_set($conn, + preferredRecordSyntax => "usmarc"); + $q = Net::Z3950::ZOOM::query_create(); ok(defined $q, "create empty query"); -$res = Net::Z3950::ZOOM::query_prefix($q, '@attr 1=21 mineral'); +$res = Net::Z3950::ZOOM::query_prefix($q, + '@and @attr 1=4 utah @attr 1=62 epicenter'); ok($res == 0, "set PQF into query"); my $rs = Net::Z3950::ZOOM::connection_search($conn, $q); $errcode = Net::Z3950::ZOOM::connection_error($conn, $errmsg, $addinfo); ok($errcode == 0, "search"); + +my $n = Net::Z3950::ZOOM::resultset_size($rs); +ok($n == 1, "found 1 record as expected"); + +my $rec = Net::Z3950::ZOOM::resultset_record($rs, 0); +ok(1, "got record idenfified by query"); + +my $len = 0; +my $data = Net::Z3950::ZOOM::record_get($rec, "render", $len); +ok(1, "rendered record"); +ok($data =~ /^035 \$a ESDD0006$/m, "record is the expected one"); + +Net::Z3950::ZOOM::resultset_destroy($rs); +Net::Z3950::ZOOM::query_destroy($q); +Net::Z3950::ZOOM::connection_destroy($conn); +ok(1, "destroyed all objects"); -- 1.7.10.4