CIGAR format
[text-levenshtein-edlib.git] / t / Text-Levenshtein-Edlib.t
CommitLineData
a99d15a3
MG
1#!/usr/bin/perl
2use strict;
3use warnings;
4
329961ff 5use Test::More tests => 11;
a99d15a3
MG
6BEGIN { use_ok('Text::Levenshtein::Edlib', ':all') };
7
8
9my $fail = 0;
10foreach 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
25ok( $fail == 0 , 'Constants' );
26
27my $r = distance 'kitten', 'sitting';
28is $r, 3, 'distance';
29$r = distance 'kitten', 'sitting', 2;
30ok !defined $r, 'distance w/ max_distance';
31
32$r = align 'kitten', 'sitting';
33is $r->{editDistance}, 3, 'align->{editDistance}';
34is $r->{alphabetLength}, 7, 'align->{alphabetLength}';
35
36is_deeply $r->{endLocations}, [6], 'align->{endLocations}';
37is_deeply $r->{startLocations}, [0], 'align->{startLocations}';
38is_deeply $r->{alignment}, [3, 0, 0, 0, 3, 0, 2], 'align->{alignment}';
329961ff
MG
39
40my $cigar;
41$cigar = to_cigar $r->{alignment};
42is $cigar, '6M1D', 'to_cigar';
43$cigar = to_cigar $r->{alignment}, EDLIB_CIGAR_EXTENDED;
44is $cigar, '1X3=1X1=1D', 'to_cigar (extended)';
This page took 0.011724 seconds and 4 git commands to generate.