diff options
author | jluehrs2 <jluehrs2@uiuc.edu> | 2008-12-18 05:00:41 -0500 |
---|---|---|
committer | jluehrs2 <jluehrs2@uiuc.edu> | 2008-12-18 05:00:41 -0500 |
commit | 9e4f671a0d6a2cee0eace11c10f52197e951de35 (patch) | |
tree | 30f0747ba337bd7b6791efb195a19eb2b15cef54 /t | |
parent | ad46f3ced6cabd0f8496d03825b2aa2135c40d9b (diff) | |
download | games-word-9e4f671a0d6a2cee0eace11c10f52197e951de35.tar.gz games-word-9e4f671a0d6a2cee0eace11c10f52197e951de35.zip |
add some more tests for is_substring
Diffstat (limited to 't')
-rw-r--r-- | t/014-substrings.t | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/t/014-substrings.t b/t/014-substrings.t index 4069be2..542ad64 100644 --- a/t/014-substrings.t +++ b/t/014-substrings.t @@ -12,6 +12,11 @@ my %is_substring_tests = ( "aaba" => ["a", "aa", "aaa", "aab", "aba"], "abcba" => ["aa", "bb", "c", "abc", "cba", "abba"], ); +my %isnt_substring_tests = ( + "" => ["a"], + "abc" => ["z", "ba", "baz", "abz"], + "aaba" => ["c", "abaa"], +); my %all_substrings_tests = ( "" => [''], "a" => ['', "a"], @@ -19,13 +24,18 @@ my %all_substrings_tests = ( "aab" => ['', "a", "a", "b", "aa", "ab", "ab", "aab"], "abc" => ['', "a", "b", "c", "ab", "ac", "bc", "abc"], ); -plan tests => (sum map { scalar @$_ } values %is_substring_tests) + +plan tests => (sum map { scalar @$_ } values %is_substring_tests, + values %isnt_substring_tests) + keys %all_substrings_tests; while (my ($word, $substrings) = each %is_substring_tests) { ok(is_substring($_, $word), "is '$_' a substring of '$word'?") for @$substrings; } +while (my ($word, $substrings) = each %isnt_substring_tests) { + ok(!is_substring($_, $word), "is '$_' not a substring of '$word'?") + for @$substrings; +} while (my ($word, $substrings) = each %all_substrings_tests) { cmp_deeply([all_substrings($word)], bag(@$substrings), "do we get all of the substrings of '$word'?"); |