testing and fixes
[migration-tools.git] / Equinox-Migration / t / 01-SimpleTagList.t
diff --git a/Equinox-Migration/t/01-SimpleTagList.t b/Equinox-Migration/t/01-SimpleTagList.t
new file mode 100644 (file)
index 0000000..0e8c2d9
--- /dev/null
@@ -0,0 +1,44 @@
+#!perl -T
+
+use Test::More tests => 25;
+use Equinox::Migration::SimpleTagList;
+
+# baseline object creation
+my $stl = Equinox::Migration::SimpleTagList->new();
+is(ref $stl, "Equinox::Migration::SimpleTagList", "self is self");
+
+# manual adds and removes
+$stl->add_tag(89);
+is ($stl->has(89), 1, 'can has tag');
+is ($stl->has(904), 0, 'can not has tag');
+$stl->add_tag(904);
+is ($stl->has(904), 1, 'can has tag');
+$stl->remove_tag(904);
+is ($stl->has(904), 0, 'can not has tag');
+
+# range addition, as_hashref, as_listref
+$stl->add_range("198..201");
+is_deeply ($stl->as_hashref, { 89 => 1, 198 => 1, 199 => 1, 200 => 1, 201 => 1 });
+is_deeply ($stl->as_listref, [ 89, 198, 199, 200, 201 ]);
+$stl->add_range("008..011");
+is_deeply ($stl->as_listref, [ 8, 9, 10, 11, 89, 198, 199, 200, 201 ]);
+
+# creation with file
+$stl = Equinox::Migration::SimpleTagList->new( file => "./t/corpus/stl-0.txt");
+is ($stl->has(11), 1);
+is ($stl->has('011'), 1);
+is ($stl->has(12), 1);
+is ($stl->has('012'), 1);
+is ($stl->has(241), 1);
+is ($stl->has(359), 1);
+is ($stl->has(652), 1);
+is ($stl->has(654), 1);
+is ($stl->has(656), 1);
+is ($stl->has(658), 1);
+is ($stl->has(872), 1);
+is ($stl->has(900), 1);
+is ($stl->has(999), 1);
+is ($stl->has(988), 1);
+is ($stl->has(655), 0, 'exception');
+is ($stl->has(987), 0, 'exception');
+is ($stl->has(400), 0, 'not in input set');