testing and fixes
[migration-tools.git] / Equinox-Migration / t / 01-SimpleTagList.t
1 #!perl -T
2
3 use Test::More tests => 25;
4 use Equinox::Migration::SimpleTagList;
5
6 # baseline object creation
7 my $stl = Equinox::Migration::SimpleTagList->new();
8 is(ref $stl, "Equinox::Migration::SimpleTagList", "self is self");
9
10 # manual adds and removes
11 $stl->add_tag(89);
12 is ($stl->has(89), 1, 'can has tag');
13 is ($stl->has(904), 0, 'can not has tag');
14 $stl->add_tag(904);
15 is ($stl->has(904), 1, 'can has tag');
16 $stl->remove_tag(904);
17 is ($stl->has(904), 0, 'can not has tag');
18
19 # range addition, as_hashref, as_listref
20 $stl->add_range("198..201");
21 is_deeply ($stl->as_hashref, { 89 => 1, 198 => 1, 199 => 1, 200 => 1, 201 => 1 });
22 is_deeply ($stl->as_listref, [ 89, 198, 199, 200, 201 ]);
23 $stl->add_range("008..011");
24 is_deeply ($stl->as_listref, [ 8, 9, 10, 11, 89, 198, 199, 200, 201 ]);
25
26 # creation with file
27 $stl = Equinox::Migration::SimpleTagList->new( file => "./t/corpus/stl-0.txt");
28 is ($stl->has(11), 1);
29 is ($stl->has('011'), 1);
30 is ($stl->has(12), 1);
31 is ($stl->has('012'), 1);
32 is ($stl->has(241), 1);
33 is ($stl->has(359), 1);
34 is ($stl->has(652), 1);
35 is ($stl->has(654), 1);
36 is ($stl->has(656), 1);
37 is ($stl->has(658), 1);
38 is ($stl->has(872), 1);
39 is ($stl->has(900), 1);
40 is ($stl->has(999), 1);
41 is ($stl->has(988), 1);
42 is ($stl->has(655), 0, 'exception');
43 is ($stl->has(987), 0, 'exception');
44 is ($stl->has(400), 0, 'not in input set');