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  package org.apache.commons.rng.core;
18  
19  import org.junit.Test;
20  import org.junit.runner.RunWith;
21  import org.junit.runners.Parameterized;
22  import org.junit.runners.Parameterized.Parameters;
23  
24  import org.apache.commons.rng.RestorableUniformRandomProvider;
25  
26  /**
27   * Tests which all 64-bits based generators must pass.
28   */
29  @RunWith(value=Parameterized.class)
30  public class Providers64ParametricTest {
31      /** RNG under test. */
32      private final RestorableUniformRandomProvider generator;
33  
34      /**
35       * Initializes generator instance.
36       *
37       * @param rng RNG to be tested.
38       */
39      public Providers64ParametricTest(RestorableUniformRandomProvider rng) {
40          generator = rng;
41      }
42  
43      @Parameters(name = "{index}: data={0}")
44      public static Iterable<RestorableUniformRandomProvider[]> getList() {
45          return ProvidersList.list64();
46      }
47  
48      @Test
49      public void testNextBytesChunks() {
50          final int[] chunkSizes = { 8, 16, 24 };
51          final int[] chunks = { 1, 2, 3, 4, 5 };
52          for (int chunkSize : chunkSizes) {
53              for (int numChunks : chunks) {
54                  ProvidersCommonParametricTest.checkNextBytesChunks(generator,
55                                                                     chunkSize,
56                                                                     numChunks);
57              }
58          }
59      }
60  }