Initial commit
[text-levenshtein-edlib.git] / t / Text-Levenshtein-Edlib.t
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4
5 use Test::More tests => 9;
6 BEGIN { use_ok('Text::Levenshtein::Edlib', ':all') };
7
8
9 my $fail = 0;
10 foreach my $constname (qw(
11 EDLIB_CIGAR_EXTENDED EDLIB_CIGAR_STANDARD EDLIB_EDOP_DELETE
12 EDLIB_EDOP_INSERT EDLIB_EDOP_MATCH EDLIB_EDOP_MISMATCH EDLIB_MODE_HW
13 EDLIB_MODE_NW EDLIB_MODE_SHW EDLIB_STATUS_ERROR EDLIB_STATUS_OK
14 EDLIB_TASK_DISTANCE EDLIB_TASK_LOC EDLIB_TASK_PATH)) {
15 next if (eval "my \$a = $constname; 1");
16 if ($@ =~ /^Your vendor has not defined Text::Levenshtein::Edlib macro $constname/) {
17 print "# pass: $@";
18 } else {
19 print "# fail: $@";
20 $fail = 1;
21 }
22
23 }
24
25 ok( $fail == 0 , 'Constants' );
26
27 my $r = distance 'kitten', 'sitting';
28 is $r, 3, 'distance';
29 $r = distance 'kitten', 'sitting', 2;
30 ok !defined $r, 'distance w/ max_distance';
31
32 $r = align 'kitten', 'sitting';
33 is $r->{editDistance}, 3, 'align->{editDistance}';
34 is $r->{alphabetLength}, 7, 'align->{alphabetLength}';
35
36 is_deeply $r->{endLocations}, [6], 'align->{endLocations}';
37 is_deeply $r->{startLocations}, [0], 'align->{startLocations}';
38 is_deeply $r->{alignment}, [3, 0, 0, 0, 3, 0, 2], 'align->{alignment}';
This page took 0.024463 seconds and 4 git commands to generate.