-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathunit_test
executable file
·65 lines (55 loc) · 2.4 KB
/
unit_test
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
64
65
#!/usr/bin/perl
#
# An unit test for the geni-automerge script.
#
# Usage: ./unit_test - for listing all the tests with results.
# prove unit_test - for a shorter output.
#
use strict;
use Test::Builder;
our $CALLED_BY_TEST_SCRIPT = 1;
require "geni-automerge.pl";
my $Test = Test::Builder->new;
init();
$Test->ok(numbersInRange("1200", "1200"), "identical years");
$Test->ok(!numbersInRange("1200", "1201"), "Adjacent no circa");
$Test->ok(numbersInRange("1200", "1201", 1, 2), "Adjacent with circa");
$Test->ok(!numbersInRange("1200", "1203", 1, 2), "Adjacent too far apart");
# Name cleanup tests
$Test->ok(cleanupName("Robert James Robert Smith") eq "robert james smith",
"Remove double name");
$Test->ok(cleanupName("Robert Robert Smith") eq "robert smith",
"Remove double first name");
$Test->ok(cleanupName("tiberius claudius nero claudius tiberius claudius nero")
eq "tiberius claudius nero", "Remove multiple repeated names");
# Name matching tests
$Test->ok(!compareNames("female", "Jane Smith ()", "Jane Doe ()"),
"No maiden name");
$Test->ok(compareNames("female", "Jane Smith (Doe)", "Jane Doe ()"),
"Maiden name matches full name");
$Test->ok(!compareNames("female", "Jane Doe (Smith)", "Jane Smith (Doe)"),
"Swap names at marriage does not match");
$Test->ok(compareNames("male", "John Doe (foo)", "John Doe (bar)"),
"Male maiden names do not matter");
$Test->ok(!compareNames("male", "John Smith (Doe)", "John Doe ()"),
"Male maiden names do not cause match");
$Test->ok(compareNames("female", "margaret neville (pole)", "margaret ()"),
"Given name only matches");
# Date tests
$Test->ok(dateMatches("1/1/1900", "Jan 1900"));
$Test->ok(dateMatches("1/1/1900", "1900"));
$Test->ok(dateMatches("c. 1901", "1900"));
$Test->ok(dateMatches("c. 1905", "1900"));
$Test->ok(!dateMatches("c. 1906", "1900"));
$Test->ok(!dateMatches("171/1900", "1901"));
$Test->ok(dateMatches("c. 1/15/1785", "1787"));
# Metaphone comparisions
$Test->ok(doubleMetaphoneCompare("williams", "williams"), "Identical strings");
$Test->ok(doubleMetaphoneCompare("williams", "willams"));
$Test->ok(!doubleMetaphoneCompare("williams", "willliams"),
"Tripled consonant - no match");
$Test->ok(doubleMetaphoneCompare("byron", "bryon"));
$Test->ok(doubleMetaphoneCompare("booth", "boothe"));
$Test->ok(doubleMetaphoneCompare("margaret", "margery"));
$Test->ok(doubleMetaphoneCompare("hepsibah", "hepzibah"));
$Test->done_testing();