File: clobbered_items.t

package info (click to toggle)
libarray-intspan-perl 2.004-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 216 kB
  • sloc: perl: 521; makefile: 2
file content (35 lines) | stat: -rw-r--r-- 1,009 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

use warnings FATAL => qw(all);
use ExtUtils::testlib;
use Test::More tests => 18 ;
use Data::Dumper ;

use Array::IntSpan;

my $trace = shift || 0 ;

my @expect= ([1,3,'ab'],[5, 7, 'cd'], [13, 26, 'ef']) ;
my $r = Array::IntSpan->new(@expect) ;

diag(Dumper $r) if $trace ;

ok ( defined($r) , 'Array::IntSpan new() works') ;
is_deeply( $r , \@expect, 'new content ok') ;

foreach my $t (
               [[32,34,'oops'],[]],
               [[4,4,'oops'],[]],
               [[24,26,'oops'],[[24,26,'ef']]],
               [[24,29,'oops'],[[24,26,'ef']]],
               [[10,16,'oops'],[[13,16,'ef']]],
               [[20,24,'oops'],[[20,24,'ef']]],
               [[0,9,'oops'],[[1,3,'ab'],[5,7,'cd']]],
               [[0,6,'oops'],[[1,3,'ab'],[5,6,'cd']]],
              )
  {
    my @clobbered = $r->clobbered_items(@{$t->[0]}) ;
    is(@$r, 3, 'check nb of items in range') || diag(Dumper $r);
    is_deeply(\@clobbered, $t->[1], "clobbered_items @{$t->[0]}") || 
      diag(Dumper \@clobbered) ;
  }