| 1 |
root |
1.1 |
BEGIN { $| = 1; print "1..10\n"; } |
| 2 |
|
|
END {print "not ok 1\n" unless $loaded;} |
| 3 |
|
|
use String::Similarity; |
| 4 |
|
|
$loaded = 1; |
| 5 |
|
|
print "ok 1\n"; |
| 6 |
|
|
|
| 7 |
|
|
print similarity("this should be the same", "this should be the same") == 1 ? "" : "not ", "ok 2\n"; |
| 8 |
|
|
my $s = similarity("this should be same the", "this should be the same"); |
| 9 |
|
|
print $s > 0.825 && $s < 0.827 ? "" : "not ", "ok 3\n"; |
| 10 |
|
|
print similarity("A", "B") == 0 ? "" : "not ", "ok 4\n"; |
| 11 |
|
|
print similarity("\x{456}", "\x{455}") == 0 ? "" : "not ", "ok 5\n"; |
| 12 |
|
|
|
| 13 |
|
|
require utf8; |
| 14 |
|
|
|
| 15 |
|
|
$a = chr(169); |
| 16 |
|
|
utf8::upgrade($b = $a); |
| 17 |
|
|
print similarity($a, $b) == 1 ? "" : "not ", "ok 6\n"; |
| 18 |
|
|
|
| 19 |
|
|
$b = "\x{0040}"; |
| 20 |
|
|
utf8::downgrade($a = $b); |
| 21 |
|
|
print similarity($a, $b) == 1 ? "" : "not ", "ok 7\n"; |
| 22 |
|
|
|
| 23 |
|
|
utf8::upgrade($a = chr(169)); |
| 24 |
|
|
use Encode qw( encode ); |
| 25 |
|
|
$b = encode "utf-8", $a; |
| 26 |
|
|
print similarity($a, $b) < 1 ? "" : "not ", "ok 8\n"; |
| 27 |
|
|
|
| 28 |
|
|
$a = []; $b = []; |
| 29 |
|
|
$s1 = similarity($a, $b); |
| 30 |
|
|
$s2 = similarity($a, "$b"); |
| 31 |
|
|
print "not " unless abs($s1-$s2) < 0.001; |
| 32 |
|
|
print "ok 9\n"; |
| 33 |
|
|
|
| 34 |
|
|
$s = similarity("", undef); |
| 35 |
|
|
print "not " unless $s == 1; |
| 36 |
|
|
print "ok 10\n"; |