File: fetch-nearest.t

package info (click to toggle)
libset-intervaltree-perl 0.12-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 364 kB
  • sloc: cpp: 686; perl: 60; makefile: 3
file content (21 lines) | stat: -rw-r--r-- 538 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

use Test::More tests => 9;
BEGIN { use_ok('Set::IntervalTree') };

use strict;
use warnings;

my $tree = Set::IntervalTree->new;
$tree->insert("A",1,2);
$tree->insert("B",2,3);
$tree->insert("C",6,10);
$tree->insert("D",4,12);

is($tree->fetch_nearest_up(2), "D");
is($tree->fetch_nearest_up(5), "C");
is($tree->fetch_nearest_up(1), "B");
is($tree->fetch_nearest_up(7), undef);
is($tree->fetch_nearest_down(7), "B");
is($tree->fetch_nearest_down(3), "B");
is($tree->fetch_nearest_down(11), "C");
is($tree->fetch_nearest_down(1), undef);