Bytes-Random-Secure-Tiny

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

xt/05-kwalitee.t
xt/06-meta-yaml.t
xt/07-meta-json.t
xt/08-versions.t
xt/09-changes.t
t/10-prereqs.t
t/11-load.t
t/20-functions.t
t/21-bytes_random_tests.t
t/22-random_string_from.t
t/23-string_from_unicode.t
t/24-oo_construct.t
t/26-oo_public.t
t/27-fips140-1.t
t/28-sequence.t
t/29-memory.t
t/30-uniform.t
t/31-crse_load.t
t/32-crse_random_values.t
t/33-crse_coverage.t
t/34-brst-coverage.t

t/23-string_from_unicode.t  view on Meta::CPAN

    'Cannot reliably test Unicode support on Perl\'s older than 5.8.9.';
}

binmode STDOUT, ':encoding(UTF-8)';

my $num_octets = 80;
my $random     = Bytes::Random::Secure::Tiny->new(bits=>64);
my $string     = $random->string_from( 'Ѧѧ', $num_octets );

is( length $string, $num_octets,
    'string_from(unicode): Returned proper length string.' );

like( $string, qr/^[Ѧѧ]+$/,
      'string_from(unicode): String contained only Ѧѧ characters.' );

# There's only an 8.27e-23% chance of NOT having both Ѧ and ѧ in the output.
# It would be incredibly poor luck for these tests to fail randomly.
# So we'll take failure to mean there's a bug.

like( $string, qr/Ѧ/,
      'string_from(unicode): Ѧ found in output.' );

like( $string, qr/ѧ/,
      'string_from(unicode): ѧ found in output.' );

done_testing();



( run in 0.411 second using v1.01-cache-2.11-cpan-88abd93f124 )