]> git.vpit.fr Git - perl/modules/Scalar-Vec-Util.git/blob - t/30-vcopy-pp.t
Restyle tests
[perl/modules/Scalar-Vec-Util.git] / t / 30-vcopy-pp.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use lib 't/lib';
7 use Test::Leaner 'no_plan';
8
9 use Scalar::Vec::Util qw<SVU_SIZE>;
10
11 BEGIN {
12  *myfill = *Scalar::Vec::Util::vfill_pp;
13 }
14
15 for ([ 1, 'offset', -1 ], [ 3, 'offset', '-1' ], [ 4, 'length', -1 ]) {
16  my @args  = ('1') x 5;
17  $args[$_->[0]] = $_->[2];
18  local $@;
19  eval { &Scalar::Vec::Util::vcopy_pp(@args) };
20  my $err  = $@;
21  my $line = __LINE__-2;
22  like $err, qr/^Invalid\s+negative\s+$_->[1]\s+at\s+\Q$0\E\s+line\s+$line/,
23       "vcopy_pp(@args) failed";
24 }
25
26 my $p = SVU_SIZE;
27 $p    = 8 if $p < 8;
28 my $n = 3 * $p;
29 my $q = 1;
30
31 sub rst {
32  myfill $_[0], 0, $n, 0;
33 }
34
35 sub pat {
36  my (undef, $a, $b, $x) = @_;
37  myfill $_[0], 0,       $a,             $x;
38  myfill $_[0], $a,      $b,             1 - $x;
39  myfill $_[0], $a + $b, $n - ($a + $b), $x;
40 }
41
42 my ($f, $t, $c) = ('') x 3;
43
44 my @s = ($p - $q) .. ($p + $q);
45 for my $s1 (@s) {
46  for my $s2 (@s) {
47   for my $l (0 .. $n - 1) {
48    last if $s1 + $l > $n or $s2 + $l > $n;
49    my $desc = "vcopy_pp $s1, $s2, $l";
50    pat $f, $s1, $l, 0;
51    rst $t;
52    pat $c, $s2, $l, 0;
53    Scalar::Vec::Util::vcopy_pp($f => $s1, $t => $s2, $l);
54    is $t, $c, $desc;
55   }
56  }
57 }