View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  
18  package org.apache.commons.rng.core.source32;
19  
20  import org.apache.commons.rng.core.RandomAssert;
21  import org.junit.jupiter.api.Test;
22  
23  class PcgMcgXshRr32Test {
24      @Test
25      void testReferenceCode() {
26          /*
27           * Tested with respect to pcg_engines::mcg_xsh_rr_64_32 of the C++ implementation.
28           * See : http://www.pcg-random.org/download.html#cpp-implementation
29           */
30          final int[] expectedSequence = {
31              0x25bc3e38, 0xb0693d58, 0x155b98f0, 0x047e13d7,
32              0xcfb227b3, 0x66601632, 0x71c6e68b, 0x16e2d4a7,
33              0x65412358, 0x6d39102c, 0x545cebed, 0x577695ef,
34              0xc851c202, 0x743d50b6, 0xe1876a24, 0x274ae9e1,
35              0x4087af7b, 0xd4738e89, 0x6ae6e6cf, 0xf8716a43,
36              0x933ed380, 0x3edb0d15, 0xa3716e23, 0x2d5f81f2,
37              0x5a921ac5, 0x795ec1cf, 0x42595831, 0x55a39a40,
38              0x9a21afda, 0xc03fa331, 0x9192fd98, 0x87eb7041,
39              0x2d9e338e, 0xf924d873, 0xf8c6a7a7, 0x2dfe78bf,
40              0xd443c0a9, 0xe567f8ed, 0xa4e09491, 0x3c91d8fd,
41          };
42          RandomAssert.assertEquals(expectedSequence, new PcgMcgXshRr32(0x012de1babb3c4104L));
43      }
44  }