Changed comp2bin.t to use Test::More

This commit is contained in:
Stephen Nelson 2013-08-25 09:03:32 -07:00
parent ac2e35340e
commit d4d08034ec
2 changed files with 10 additions and 51 deletions

View File

@ -1,34 +0,0 @@
package Checker;
use Exporter 'import';
@EXPORT = qw($CHECK okay_if note check filter_warnings);
$Checker::OUTPUT = 1;
$Checker::CHECK = 0;
# Only lets through warnings that originate outside our toolkit:
sub filter_warnings {
$SIG{'__WARN__'} = sub {
print STDERR $_[0] if ($_[0] !~ /^MIME:/);
};
}
sub okay_if {
print( ($_[0] ? "ok\n" : "not ok\n"))
}
sub note {
print STDOUT " ## ", @_, "\n" if $OUTPUT;
}
sub check {
++$CHECK;
my ($ok, $note) = @_;
$note = ($note ? ": $note" : '');
my $stat = ($ok ? 'OK ' : 'ERR');
printf STDOUT " Test %2d$note\n", $CHECK if $OUTPUT;
print(($ok ? "ok $CHECK\n" : "not ok $CHECK\n"));
}
1;

View File

@ -1,9 +1,11 @@
use lib "./blib/lib", "./lib", "./t";
use strict;
use warnings;
use Test::More;
use Checker;
use Convert::BinHex;
%TEST = (
my %TEST = (
PIVOT_3 => {
COMP => ["90 00 01 02 03 04 00",
"90 00 03"],
@ -59,27 +61,18 @@ sub str2hex {
#------------------------------------------------------------
# BEGIN
#------------------------------------------------------------
print "1..9\n";
my $TESTKEY;
foreach $TESTKEY (sort keys %TEST) {
foreach my $TESTKEY (sort keys %TEST) {
my $test = $TEST{$TESTKEY};
my @comps = map { str2hex($_) } @{$test->{COMP}};
my $bin = str2hex($test->{BIN});
my $comp;
my $rbin = '';
my $H2B = Convert::BinHex->hex2bin;
foreach $comp (@comps) {
$rbin .= $H2B->comp2bin_next($comp);
foreach my $comp (@comps) {
$rbin .= $H2B->comp2bin_next($comp);
}
check(($rbin eq $bin), "test $TESTKEY");
is($rbin, $bin, "test $TESTKEY");
}
1;
done_testing();