summaryrefslogtreecommitdiff
path: root/t/prng.t
diff options
context:
space:
mode:
authorKarel Miko <miko@dcit.cz>2013-09-11 11:16:53 +0200
committerKarel Miko <miko@dcit.cz>2013-09-11 11:16:53 +0200
commitf8aad67837f21be8d40a4b45068aa32a056048a4 (patch)
tree8710bb0a463d406c0d41aea4104005ea56d6304d /t/prng.t
parent808344dc8385127fb4e6c696936e737ad766cd7c (diff)
Crypt::PRNG random_bytes_b64u/bytes_b64u
Diffstat (limited to 't/prng.t')
-rwxr-xr-xt/prng.t12
1 files changed, 7 insertions, 5 deletions
diff --git a/t/prng.t b/t/prng.t
index c9492bc4..8607ef49 100755
--- a/t/prng.t
+++ b/t/prng.t
@@ -2,7 +2,7 @@ use strict;
use warnings;
use Test::More;
-use Crypt::PRNG qw(random_bytes random_bytes_hex random_bytes_b64 random_string random_string_from rand irand);
+use Crypt::PRNG qw(random_bytes random_bytes_hex random_bytes_b64 random_bytes_b64u random_string random_string_from rand irand);
my $r = Crypt::PRNG->new();
ok($r, 'new');
@@ -53,14 +53,16 @@ ok($r, 'new');
like($r->string(45), qr/^[A-Z-a-z0-9]+$/, 'string');
like($r->string_from("ABC,.-", 45), qr/^[ABC,\,\.\-]+$/, 'string');
is(length $r->bytes(55), 55, "bytes");
- is(length $r->bytes_hex(55), 110, "bytes_hex");
- is(length $r->bytes_b64(60), 80, "bytes_b64");
+ like($r->bytes_hex(55), qr/^[0-9A-Fa-f]{110}$/, "bytes_hex");
+ like($r->bytes_b64(60), qr/^[A-Za-z0-9+\/=]{80}$/, "bytes_b64");
+ like($r->bytes_b64u(60), qr/^[A-Za-z0-9_-]{80}$/, "bytes_b64u");
like(random_string(45), qr/^[A-Z-a-z0-9]+$/, 'string');
like(random_string_from("ABC,.-", 45), qr/^[ABC,\,\.\-]+$/, 'string');
is(length random_bytes(55), 55, "bytes");
- is(length random_bytes_hex(55), 110, "bytes_hex");
- is(length random_bytes_b64(60), 80, "bytes_b64");
+ like(random_bytes_hex(55), qr/^[0-9A-Fa-f]{110}$/, "bytes_hex");
+ like(random_bytes_b64(60), qr/^[A-Za-z0-9+\/=]{80}$/, "bytes_b64");
+ like(random_bytes_b64u(60), qr/^[A-Za-z0-9_-]{80}$/, "bytes_b64u");
}
done_testing; \ No newline at end of file