1   /* Copyright 2002-2022 CS GROUP
2    * Licensed to CS GROUP (CS) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * CS 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.orekit.data;
18  
19  
20  import java.util.Arrays;
21  
22  import org.hipparchus.random.RandomGenerator;
23  import org.hipparchus.random.Well1024a;
24  import org.junit.Assert;
25  import org.junit.Test;
26  
27  
28  public class NutationCodecTest {
29  
30      @Test
31      public void testKeySymmetry() {
32  
33          RandomGenerator random = new Well1024a(0x8fef7f6f99ad5d56l);
34          int[] multipliers = new int[15];
35          for (int i = 0; i < 100000; ++i) {
36              Arrays.fill(multipliers, 0);
37              int nb = 1 + random.nextInt(7);
38              for (int k = 0; k < nb; ++k) {
39                  int index = random.nextInt(15);
40                  while (multipliers[index] == 0) {
41                      multipliers[index] = random.nextInt(128) - 64;
42                  }
43              }
44              long key = NutationCodec.encode(multipliers);
45              int[] rebuilt = NutationCodec.decode(key);
46              for (int k = 0; k < multipliers.length; ++k) {
47                  Assert.assertEquals(multipliers[k], rebuilt[k]);
48              }
49          }
50  
51      }
52  
53  }