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.Test;
22  
23  public class PcgXshRr32Test {
24      @Test
25      public void testReferenceCode() {
26          /*
27           * Tested with respect to pcg_engines::setseq_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              0xe860dd24, 0x15d339c0, 0xd9f75c46, 0x00efabb7,
32              0xa625e97f, 0xcdeae599, 0x6304e667, 0xbc81be11,
33              0x2b8ea285, 0x8e186699, 0xac552be9, 0xd1ae72e5,
34              0x5b953ad4, 0xa061dc1b, 0x526006e7, 0xf5a6c623,
35              0xfcefea93, 0x3a1964d2, 0xd6f03237, 0xf3e493f7,
36              0x0c733750, 0x34a73582, 0xc4f8807b, 0x92b741ca,
37              0x0d38bf9c, 0xc39ee6ad, 0xdc24857b, 0x7ba8f7d8,
38              0x377a2618, 0x92d83d3f, 0xd22a957a, 0xb6724af4,
39              0xe116141a, 0xf465fe45, 0xa95f35bb, 0xf0398d4d,
40              0xe880af3e, 0xc2951dfd, 0x984ec575, 0x8679addb,
41          };
42          RandomAssert.assertEquals(expectedSequence, new PcgXshRr32(new long[] {
43              0x012de1babb3c4104L, 0xc8161b4202294965L
44          }));
45      }
46  }