File: 00_load.t

package info (click to toggle)
libstring-similarity-perl 1.04-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 128 kB
  • sloc: ansic: 392; perl: 10; makefile: 2
file content (36 lines) | stat: -rw-r--r-- 1,037 bytes parent folder | download | duplicates (3)
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
BEGIN { $| = 1; print "1..10\n"; }
END {print "not ok 1\n" unless $loaded;}
use String::Similarity;
$loaded = 1;
print "ok 1\n";

print similarity("this should be the same", "this should be the same") == 1 ? "" : "not ", "ok 2\n";
my $s = similarity("this should be same the", "this should be the same");
print $s > 0.825 && $s < 0.827 ? "" : "not ", "ok 3\n";
print similarity("A", "B") == 0 ? "" : "not ", "ok 4\n";
print similarity("\x{456}", "\x{455}") == 0 ? "" : "not ", "ok 5\n";

require utf8;

$a = chr(169);
utf8::upgrade($b = $a);
print similarity($a, $b) == 1 ? "" : "not ", "ok 6\n";

$b = "\x{0040}";
utf8::downgrade($a = $b);
print similarity($a, $b) == 1 ? "" : "not ", "ok 7\n";

utf8::upgrade($a = chr(169));
use Encode qw( encode );
$b = encode "utf-8", $a;
print similarity($a, $b) < 1 ? "" : "not ", "ok 8\n";

$a = []; $b = [];
$s1 = similarity($a, $b);
$s2 = similarity($a, "$b");
print "not " unless abs($s1-$s2) < 0.001;
print "ok 9\n";

$s = similarity("", undef);
print "not " unless $s == 1;
print "ok 10\n";