From: mike Date: Tue, 8 Nov 2005 16:40:06 +0000 (+0000) Subject: Two new tests: resultset_sort1() rejects a syntactically invalid sort X-Git-Tag: cpan_1_22~373 X-Git-Url: http://lists.indexdata.com/cgi-bin?a=commitdiff_plain;h=24e8535c8420bfaaa519caf2e7fa3b95c6258faf;p=ZOOM-Perl-moved-to-github.git Two new tests: resultset_sort1() rejects a syntactically invalid sort specification, and accepts a good one. --- diff --git a/t/14-sorting.t b/t/14-sorting.t index 3a8e3e1..d135554 100644 --- a/t/14-sorting.t +++ b/t/14-sorting.t @@ -1,11 +1,11 @@ -# $Id: 14-sorting.t,v 1.4 2005-11-07 16:30:41 mike Exp $ +# $Id: 14-sorting.t,v 1.5 2005-11-08 16:40:06 mike Exp $ # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl 14-sorting.t' use strict; use warnings; -use Test::More tests => 27; +use Test::More tests => 29; use MARC::Record; BEGIN { use_ok('Net::Z3950::ZOOM') }; @@ -41,9 +41,12 @@ foreach my $i (1 .. $n) { $previous = $title; } -# Now reverse the order of sorting -Net::Z3950::ZOOM::resultset_sort($rs, "dummy", "1=4 >i"); -### There's no way to check for success, as this is a void function +# Now reverse the order of sorting. We never use resultset_sort(), +# which is identical to sort1() except that it returns nothing. +my $status = Net::Z3950::ZOOM::resultset_sort1($rs, "dummy", "1=4>i"); +ok($status < 0, "malformed sort criterion rejected"); +$status = Net::Z3950::ZOOM::resultset_sort1($rs, "dummy", "1=4 >i"); +ok($status == 0, "sort criterion accepted"); $previous = "z"; # Sorts after all legitimate titles foreach my $i (1 .. $n) { diff --git a/t/24-sorting.t b/t/24-sorting.t index 687ec65..5c49a7b 100644 --- a/t/24-sorting.t +++ b/t/24-sorting.t @@ -1,4 +1,4 @@ -# $Id: 24-sorting.t,v 1.2 2005-11-07 16:30:50 mike Exp $ +# $Id: 24-sorting.t,v 1.3 2005-11-08 16:41:25 mike Exp $ # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl 24-sorting.t' @@ -38,8 +38,10 @@ foreach my $i (1 .. $n) { } # Now reverse the order of sorting -$rs->sort("dummy", "1=4 >i"); -### There's no way to check for success, as this is a void function +my $status = $rs->sort("dummy", "1=4>i"); +ok($status < 0, "malformed sort criterion rejected"); +$status = $rs->sort("dummy", "1=4 >i"); +ok($status == 0, "sort criterion accepted"); $previous = "z"; # Sorts after all legitimate titles foreach my $i (1 .. $n) {