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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
use strict;
use warnings;
use Test::More 'no_plan';
use Munin::Node::Utils;
### _set_complement
### _set_intersection
{
my @tests = (
[
[ [qw/a b c/], [qw/a b c/] ], [ [], [qw/a b c/] ],
'Equal sets',
],
[
[ [qw/a b c/], [qw/d e f/] ], [ [qw/a b c/], [] ],
'Disjoint sets',
],
[
[ [qw/a b c/], [qw/c d e/] ], [ [qw/a b/], [qw/c/] ],
'Intersecting sets',
],
[
[ [], [qw/a b c/] ], [ [], [] ],
'First set is empty',
],
[
[ [qw/a b c/], [] ], [ [qw/a b c/], [] ],
'Second set is empty',
],
[
[ [], [] ], [ [], [] ],
'Both sets are empty',
],
);
foreach (@tests) {
my ($sets, $expected, $msg) = @$_;
is_deeply(
[ Munin::Node::Utils::set_difference(@$sets) ],
$expected->[0],
"$msg - complement"
);
is_deeply(
[ Munin::Node::Utils::set_intersection(@$sets) ],
$expected->[1],
"$msg - intersection"
);
}
}
|