From 5e98e05cf739535901b4c7af69371a0bec6a0a39 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Thu, 05 Jan 2017 17:51:18 -0500 Subject: t/13_drhtz-drhfz.t: Test invalid precision drhtz() and drhfz() are now at 100% test coverage. --- diff --git a/t/13_drhtz-drhfz.t b/t/13_drhtz-drhfz.t index fc8ee01..284f97e 100644 --- a/t/13_drhtz-drhfz.t +++ b/t/13_drhtz-drhfz.t @@ -24,6 +24,7 @@ use Math::Decimal::FastPP; my @std_tests; my @tie_tests; +my @inv_tests; my $i; my $a; my $p; @@ -43,6 +44,7 @@ my $f; [ -2.39, 1, "-2.4", \&drhtz, \&drhfz], ); @tie_tests = ( + # a p r functions [ 23.5 , 0, "23." , \&drhtz ], [ 23.5 , 0, "24." , \&drhfz], [ 2.35, 1, "2.3", \&drhtz ], @@ -52,10 +54,15 @@ my $f; [ -2.35, 1, "-2.3", \&drhtz ], [ -2.35, 1, "-2.4", \&drhfz], ); +@inv_tests = ( + # a p r functions + [ 23 , 1, undef, \&drhtz, \&drhfz], +); $i = 0; map({$i += scalar(@{$_}) - 3} @std_tests); map({$i += scalar(@{$_}) - 3} @tie_tests); +map({$i += scalar(@{$_}) - 3} @inv_tests); plan("tests" => $i); note("Basic tests:"); @@ -74,3 +81,11 @@ foreach (@tie_tests) { svref_2object($f)->GV->NAME, $a, $p, $r)); } } +note("Invalid precision tests:"); +foreach (@inv_tests) { + ($a, $p, $r, @funcs) = @{$_}; + foreach $f (@funcs) { + is(&$f($a, $p), $r, sprintf("%s(%s, %d) = undef", + svref_2object($f)->GV->NAME, $a, $p)); + } +} -- cgit v0.9.1