1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.rng.core.source32;
18
19 import org.apache.commons.rng.core.RandomAssert;
20 import org.junit.jupiter.api.Test;
21
22 class XoRoShiRo64StarStarTest {
23
24 private static final int SEED_SIZE = 2;
25
26 @Test
27 void testReferenceCode() {
28
29
30
31
32 final int[] seed = {
33 0x012de1ba, 0xa5a818b8,
34 };
35
36 final int[] expectedSequence = {
37 0x7ac00b42, 0x1f638399, 0x09e4aea4, 0x05cbbd64,
38 0x1c967b7b, 0x1cf852fd, 0xc666f4e8, 0xeea9f1ae,
39 0xca0fa6bc, 0xa65d0905, 0xa69afc95, 0x34965e62,
40 0xdd4f04a9, 0xff1c9342, 0x638ff769, 0x03419ca0,
41 0xb46e6dfd, 0xf7555b22, 0x8cab4e68, 0x5a44b6ee,
42 0x4e5e1eed, 0xd03c5963, 0x782d05ed, 0x41bda3e3,
43 0xd1d65005, 0x88f43a8a, 0xfffe02ea, 0xb326624a,
44 0x1ec0034c, 0xb903d8df, 0x78454bd7, 0xaec630f8,
45 0x2a0c9a3a, 0xc2594988, 0xe71e767e, 0x4e0e1ddc,
46 0xae945004, 0xf178c293, 0xa04081d6, 0xdd9c062f,
47 };
48
49 RandomAssert.assertEquals(expectedSequence, new XoRoShiRo64StarStar(seed));
50 }
51
52 @Test
53 void testConstructorWithZeroSeedIsNonFunctional() {
54 RandomAssert.assertNextIntZeroOutput(new XoRoShiRo64StarStar(new int[SEED_SIZE]), 2 * SEED_SIZE);
55 }
56
57 @Test
58 void testConstructorWithSingleBitSeedIsFunctional() {
59 RandomAssert.assertIntArrayConstructorWithSingleBitSeedIsFunctional(XoRoShiRo64StarStar.class, SEED_SIZE);
60 }
61
62 @Test
63 void testConstructorWithoutFullLengthSeed() {
64
65 RandomAssert.assertNextLongNonZeroOutput(new XoRoShiRo64StarStar(new int[] {0x012de1ba}),
66 SEED_SIZE, SEED_SIZE);
67 }
68
69 @Test
70 void testElementConstructor() {
71 final int[] seed = {
72 0x012de1ba, 0xa5a818b8,
73 };
74 final XoRoShiRo64StarStar rng1 = new XoRoShiRo64StarStar(seed);
75 final XoRoShiRo64StarStar rng2 = new XoRoShiRo64StarStar(seed[0], seed[1]);
76 RandomAssert.assertNextIntEquals(seed.length * 2, rng1, rng2);
77 }
78 }