aboutsummaryrefslogtreecommitdiff
path: root/tests/test.R
blob: 0937f522fce1e3a002192d88e649a7d7be069762 (plain)
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
33
34
35
36
37
38
39
40
41
42
43
library(SyncRNG)

test.randi <- function()
{
	s <- SyncRNG(seed=123456)
	for (i in 1:5)
		cat(s$randi(), '\n')
}

test.rand <- function()
{
	s <- SyncRNG(seed=123456)
	for (i in 1:5)
		cat(sprintf('%.16f\n', s$rand()))
}

test.randbelow <- function()
{
	s <- SyncRNG(seed=123456)
	for (i in 1:5)
		cat(s$randbelow(i), '\n')
}

test.shuffle <- function()
{
	s <- SyncRNG(seed=123456)
	x <- c(1:5)
	for (i in 1:5) {
		y <- s$shuffle(x)
		x <- y
		cat('[', paste(y, collapse=', '), ']\n', sep='')
	}
}

main <- function()
{
	test.randi()
	test.rand()
	test.randbelow()
	test.shuffle()
}

main()