This repository was archived by the owner on Nov 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path10-grid.t
63 lines (48 loc) · 1.54 KB
/
10-grid.t
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
55
56
57
58
59
60
61
62
63
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More 'no_plan';
use Test::Exception;
use_ok 'Algorithm::MyersDiff::EditGrid';
subtest 'Reachability' => sub {
# Prepare dummy grid
my $grid = Algorithm::MyersDiff::EditGrid->new(
before => 'foobar',
after => 'bazquux',
);
subtest 'Illegal lengths' => sub {
# Prepare illegal index pairs
my @illegal_pairs = (
[[-1,3], [2,5]],
[[1,13], [2,5]],
[[1,3], [-2,5]],
[[1,3], [2,8]],
);
# Check exceptions for reachability
for my $pair (@illegal_pairs) {
throws_ok { $grid->reachable(@$pair) }
qr/Illegal length/, 'Died of an illegal length';
}
};
subtest 'Direction not monotone' => sub {
throws_ok { $grid->reachable([1,3], [0,5]) }
qr/Direction not monotone: \(1,3\) -> \(0,5\)/, 'Died correctly';
throws_ok { $grid->reachable([1,3], [2,2]) }
qr/Direction not monotone: \(1,3\) -> \(2,2\)/, 'Died correctly';
};
subtest 'Rectangular neighbour' => sub {
ok $grid->reachable([2,5], [3,5]), 'Reachable';
ok $grid->reachable([2,5], [2,6]), 'Reachable';
};
subtest 'Diagonal neighbour' => sub {
ok not($grid->reachable([2,3], [3,4])), 'Not reachable';
ok $grid->reachable([3,0], [4,1]), 'Reachable';
ok $grid->reachable([4,1], [5,2]), 'Reachable';
};
};
subtest 'Edit Paths' => sub {
subtest 'Trivial' => sub {
ok 1;
};
};
done_testing;