]> git.vpit.fr Git - perl/modules/Scalar-Vec-Util.git/blobdiff - t/31-vcopy-copy.t
Improve argument checking
[perl/modules/Scalar-Vec-Util.git] / t / 31-vcopy-copy.t
index 2d1132d4a5e3843525a3313990830973f4d49f76..af127f8c65c11c976f23f08cc894e3c40e528d76 100644 (file)
@@ -7,16 +7,12 @@ use Test::More 'no_plan';
 
 use Scalar::Vec::Util qw/vcopy SVU_SIZE/;
 
-eval { vcopy undef, 0, my $y, 0, 0 };
-like($@, qr/Invalid\s+argument/, 'first argument undef croaks');
-eval { vcopy my $x, undef, my $y, 0, 0 };
-like($@, qr/Invalid\s+argument/, 'second argument undef croaks');
-eval { vcopy my $x, 0, undef, 0, 0 };
-like($@, qr/Invalid\s+argument/, 'third argument undef croaks');
-eval { vcopy my $x, 0, my $y, undef, 0 };
-like($@, qr/Invalid\s+argument/, 'fourth argument undef croaks');
-eval { vcopy my $x, 0, my $y, 0, undef };
-like($@, qr/Invalid\s+argument/, 'fifth argument undef croaks');
+for ([ 1, 'offset', -1 ], [ 3, 'offset', '-1' ], [ 4, 'length', -1 ]) {
+ my @args  = (~0) x 5;
+ $args[$_->[0]] = $_->[2];
+ eval { &vcopy(@args) }; my $line = __LINE__;
+ like $@, qr/^Invalid\s+negative\s+$_->[1]\s+at\s+\Q$0\E\s+line\s+$line/;
+}
 
 my $p = SVU_SIZE;
 $p = 8 if $p < 8;