diff options
author | jluehrs2 <jluehrs2@uiuc.edu> | 2008-02-01 19:49:25 -0500 |
---|---|---|
committer | jluehrs2 <jluehrs2@uiuc.edu> | 2008-02-01 19:49:25 -0500 |
commit | f14c1c7b57f779360fb93f5e638bb94869733b02 (patch) | |
tree | 21c89a59d25e6e9630e548837269f4f70cbf6a2d | |
parent | a9192e616b43c223f2f6fc0d39a243fad515a030 (diff) | |
download | games-word-f14c1c7b57f779360fb93f5e638bb94869733b02.tar.gz games-word-f14c1c7b57f779360fb93f5e638bb94869733b02.zip |
add test for shared_letters
-rw-r--r-- | t/012-shared-letters.t | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/t/012-shared-letters.t b/t/012-shared-letters.t new file mode 100644 index 0000000..773f0b5 --- /dev/null +++ b/t/012-shared-letters.t @@ -0,0 +1,26 @@ +#!perl -T +use strict; +use warnings; +use Test::More; +use Games::Word qw/shared_letters shared_letters_by_position/; + +my @tests = ( + {a => "abcde", b => "edcba", sl => 5, slbp => 1}, + {a => "", b => "", sl => 0, slbp => 0}, + {a => "", b => "abcde", sl => 0, slbp => 0}, + {a => "aaa", b => "aa", sl => 2, slbp => 2}, + {a => "abc", b => "abcde", sl => 3, slbp => 3}, + {a => "cde", b => "abcde", sl => 3, slbp => 0}, + {a => "abcba", b => "aabbc", sl => 5, slbp => 2}, + {a => "abcde", b => "cdefg", sl => 3, slbp => 0}, + {a => "bacaa", b => "gabca", sl => 4, slbp => 2}, +); +plan tests => 2 * @tests; + +for (@tests) { + my %test = %$_; + is(shared_letters($test{a}, $test{b}), $test{sl}, + "testing shared_letters"); + is(shared_letters_by_position($test{a}, $test{b}), $test{slbp}, + "testing shared_letters_by_position"); +} |