BsDiPa

 view release on metacpan or  search on metacpan

test.pl  view on Meta::CPAN

#@ Automated test for S-bsdipa (make test).

#use Test::Simple tests => 1;
use Test2::API qw/context/;
our @EXPORT = qw/ok done_testing/;
sub ok($;$){
	my ($bool, $name) = @_;
	my $ctx = context();
	$ctx->ok($bool, $name);
	$ctx->release;
	return $bool
}
sub done_testing{
	my $ctx = context();
	$ctx->done_testing;
	$ctx->release
}

BEGIN {require BsDiPa}

use strict;
use diagnostics;
use Compress::Zlib;

## Core:

use BsDiPa;

#print BsDiPa::VERSION, "\n";
#print BsDiPa::CONTACT, "\n";
#print BsDiPa::COPYRIGHT;

# io_cookie's
our ($cJ,$cj,$cR,$cZ,$cz,$mag) = (undef,undef,undef,undef,undef,undef);

sub doit{
	my ($t, $b, $a, $eq) = @_;

	$eq = (defined $eq && $eq != 0);
	my $iseq = 0;

	my ($pJ,$pj,$pR,$pZ,$pz, $rJ,$rj,$rR,$rZ,$rz) = (0,0,0,0,0, 0,0,0,0,0);

	ok(BsDiPa::core_diff_zlib(undef, $a, \$pz, $mag) eq BsDiPa::INVAL);
	ok(!defined $pz);
	ok(BsDiPa::core_diff_zlib($b, undef, \$pz, $mag) eq BsDiPa::INVAL);
	ok(!defined $pz);
	ok(BsDiPa::core_diff_zlib($b, $a, undef, $mag) eq BsDiPa::INVAL);
	ok(BsDiPa::core_diff_zlib($b, $a, $pz, $mag) eq BsDiPa::INVAL);
	BsDiPa::core_diff_level_set(3);
	ok(BsDiPa::core_diff_zlib($b, $a, \$pz, $mag, undef, $cz) eq BsDiPa::OK);
	ok(defined $pz);
	BsDiPa::core_diff_level_set(0);
	ok(BsDiPa::core_diff_zlib($b, $a, \$pz, $mag, $iseq, $cz) eq BsDiPa::INVAL);
	ok(!defined $pz);
	ok(BsDiPa::core_diff_zlib($b, $a, \$pz, $mag, \$iseq, $cz) eq BsDiPa::OK);
	ok(defined $pz);
	ok($eq == $iseq);

	if(BsDiPa::HAVE_BZ2()){
		ok(BsDiPa::core_diff_bz2(undef, $a, \$pj, $mag) eq BsDiPa::INVAL);
		ok(!defined $pj);
		ok(BsDiPa::core_diff_bz2($b, undef, \$pj, $mag) eq BsDiPa::INVAL);
		ok(!defined $pj);
		ok(BsDiPa::core_diff_bz2($b, $a, undef, $mag) eq BsDiPa::INVAL);
		ok(BsDiPa::core_diff_bz2($b, $a, $pj, $mag) eq BsDiPa::INVAL);



( run in 0.849 second using v1.01-cache-2.11-cpan-5c0b1e786e0 )