From f694f18bcdf9ab24fc1df2e4b7b663f827f32c14 Mon Sep 17 00:00:00 2001 From: mike Date: Thu, 22 Dec 2005 09:23:52 +0000 Subject: [PATCH] Inline the check_failure() subroutine, which was only used once. --- t/12-query.t | 22 +++++++--------------- t/22-query.t | 19 ++++++------------- 2 files changed, 13 insertions(+), 28 deletions(-) diff --git a/t/12-query.t b/t/12-query.t index 683f665..fac08b3 100644 --- a/t/12-query.t +++ b/t/12-query.t @@ -1,4 +1,4 @@ -# $Id: 12-query.t,v 1.4 2005-12-22 09:16:43 mike Exp $ +# $Id: 12-query.t,v 1.5 2005-12-22 09:23:52 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' @@ -68,7 +68,12 @@ $q = Net::Z3950::ZOOM::query_create(); ok(defined $q, "create empty query"); $res = Net::Z3950::ZOOM::query_cql($q, 'title=utah and description=epicenter'); ok($res == 0, "valid CQL accepted"); -check_failure($conn, $q, 107, "Bib-1"); +my $rs = Net::Z3950::ZOOM::connection_search($conn, $q); +my $diagset = "dummy"; +$errcode = Net::Z3950::ZOOM::connection_error_x($conn, $errmsg, $addinfo, + $diagset); +ok($errcode == 107 && $diagset eq "Bib-1", + "query rejected: error " . $errcode); Net::Z3950::ZOOM::query_destroy($q); # Client-side compiled CQL: this will fail due to lack of config-file @@ -77,7 +82,6 @@ ok(defined $q, "create empty query"); $res = Net::Z3950::ZOOM::query_cql2rpn($q, 'title=utah and description=epicenter', $conn); -my $diagset = ""; $errcode = Net::Z3950::ZOOM::connection_error_x($conn, $errmsg, $addinfo, $diagset); ok($res < 0 && @@ -123,15 +127,3 @@ sub check_record { Net::Z3950::ZOOM::resultset_destroy($rs); } - - -sub check_failure { - my($conn, $q, $expected_error, $expected_dset) = @_; - - my $rs = Net::Z3950::ZOOM::connection_search($conn, $q); - my($errcode, $errmsg, $addinfo, $diagset) = (undef, "dummy", "dummy", ""); - $errcode = Net::Z3950::ZOOM::connection_error_x($conn, $errmsg, $addinfo, - $diagset); - ok($errcode == $expected_error && $diagset eq $expected_dset, - "query rejected: error " . $errcode); -} diff --git a/t/22-query.t b/t/22-query.t index 290145d..e0b049f 100644 --- a/t/22-query.t +++ b/t/22-query.t @@ -1,4 +1,4 @@ -# $Id: 22-query.t,v 1.5 2005-12-22 09:11:30 mike Exp $ +# $Id: 22-query.t,v 1.6 2005-12-22 09:25:14 mike Exp $ # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl 22-query.t' @@ -67,7 +67,11 @@ $q->destroy(); ok(1, "[no need to create empty query]"); eval { $q = new ZOOM::Query::CQL('title=utah and description=epicenter') }; ok(!$@, "created CQL query"); -check_failure($conn, $q, 107, "Bib-1"); +my $rs; +eval { $rs = $conn->search($q) }; +ok($@ && $@->isa("ZOOM::Exception") && + $@->code() == 107 && $@->diagset() eq "Bib-1", + "query rejected: error " . $@->code()); $q->destroy(); # Client-side compiled CQL: this will fail due to lack of config-file @@ -111,14 +115,3 @@ sub check_record { $rs->destroy(); } - - -sub check_failure { - my($conn, $q, $expected_error, $expected_dset) = @_; - - my $rs; - eval { $rs = $conn->search($q) }; - ok($@ && $@->isa("ZOOM::Exception") && - $@->code() == $expected_error && $@->diagset() eq $expected_dset, - "query rejected: error " . $@->code()); -} -- 1.7.10.4