summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjluehrs2 <jluehrs2@uiuc.edu>2008-02-01 23:15:03 -0500
committerjluehrs2 <jluehrs2@uiuc.edu>2008-02-01 23:15:03 -0500
commit175ab26ce039a5ac0a99f50d5f1a63130307b5d8 (patch)
tree6167c7d5f1ca908f8d72387600a050f5ac3d90a5
parenteb43d2e2d8c874fe71a3b0bae6bd3f5e64638bfd (diff)
downloadgames-word-175ab26ce039a5ac0a99f50d5f1a63130307b5d8.tar.gz
games-word-175ab26ce039a5ac0a99f50d5f1a63130307b5d8.zip
test random_string_from
-rw-r--r--t/013-random-string-from.t22
1 files changed, 22 insertions, 0 deletions
diff --git a/t/013-random-string-from.t b/t/013-random-string-from.t
new file mode 100644
index 0000000..190f1a5
--- /dev/null
+++ b/t/013-random-string-from.t
@@ -0,0 +1,22 @@
+#!perl -T
+use strict;
+use warnings;
+use Test::More tests => 23;
+use Test::Deep;
+use Games::Word qw/random_string_from/;
+
+is(random_string_from("", 0), "",
+ "0 length random_string_from an empty string");
+eval { random_string_from("", 5) };
+like($@, qr/invalid letter list/,
+ "random_string_from an empty string");
+is(random_string_from("abcde", 0), "",
+ "0 length random_string_from");
+my @letters = qw/a b c d e/;
+for my $i (1..10) {
+ my $str = random_string_from join('', @letters), $i;
+ is(length $str, $i, "random_string_from returns the correct length");
+ my $bag = subbagof();
+ $bag->add(@letters) for 1..$i;
+ cmp_deeply([split(//, $str)], $bag, "random test of random_string_from");
+}