]>
Commit | Line | Data |
---|---|---|
a99d15a3 MG |
1 | #!/usr/bin/perl |
2 | use strict; | |
3 | use warnings; | |
4 | ||
329961ff | 5 | use Test::More tests => 11; |
a99d15a3 MG |
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}'; | |
329961ff MG |
39 | |
40 | my $cigar; | |
41 | $cigar = to_cigar $r->{alignment}; | |
42 | is $cigar, '6M1D', 'to_cigar'; | |
43 | $cigar = to_cigar $r->{alignment}, EDLIB_CIGAR_EXTENDED; | |
44 | is $cigar, '1X3=1X1=1D', 'to_cigar (extended)'; |