12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- use strict;
- use Text::WagnerFischer qw(distance);
- my $ko=0;
- my $test=1;
- my $first_distance=distance("foo","four");
- if ($first_distance == 2) {
- print $test.". ok\n"
- } else {
- print $test.". NO <--\n";
- $ko=1;
- }
- my $second_distance=distance("foo","foo");
- $test++;
- if ($second_distance == 0) {
- print $test.". ok\n"
- } else {
- print $test.". NO <--\n";
- $ko=1;
- }
- my $third_distance=distance([0,1,2],"foo","four");
- $test++;
- if ($third_distance == 3) {
- print $test.". ok\n"
- } else {
- print $test.". NO <--\n";
- $ko=1;
- }
- my @words=("four","foo","bar");
- my @distances=distance("foo",@words);
- $test++;
- if (($distances[0] == 2) and ($distances[1] == 0) and ($distances[2] == 3)) {
- print $test.". ok\n"
- } else {
- print $test.". NO <--\n";
- $ko=1;
- }
- @distances=distance([0,5,3],"foo",@words);
- $test++;
- if (($distances[0] == 8) and ($distances[1] == 0) and ($distances[2] == 9)) {
- print $test.". ok\n"
- } else {
- print $test.". NO <--\n";
- $ko=1;
- }
- if ($ko) {print "\nTest suite failed\n"} else {print "\nTest suite ok\n"}
|