File: rand_flt.t

package info (click to toggle)
libdata-entropy-perl 0.008-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 280 kB
  • sloc: perl: 890; makefile: 2
file content (32 lines) | stat: -rw-r--r-- 635 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use warnings;
use strict;

use Test::More tests => 11001;

use IO::File 1.03;

BEGIN { use_ok "Data::Entropy::Algorithms", qw(rand_flt); }

sub test_rand_flt($$) {
	my($min, $max) = @_;
	for(my $i = 500; $i--; ) {
		my $v = rand_flt($min, $max);
		ok $v >= $min && $v <= $max;
		$v = rand_flt($max, $min);
		ok $v >= $min && $v <= $max;
	}
}

test_rand_flt(1.0, 2.0);
test_rand_flt(1.0, 2.75);
test_rand_flt(1.25, 2.0);
test_rand_flt(1.25, 2.75);
test_rand_flt(-2.75, -1.25);
test_rand_flt(0.0, 1.0);
test_rand_flt(-1.0, 1.0);
test_rand_flt(-2.0, 1.0);
test_rand_flt(-1.0, 2.0);
test_rand_flt(2.5, 2.5);
test_rand_flt(-0.0, +0.0);

1;