1 /* Copyright 2002-2025 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 import org.hipparchus.random.RandomGenerator;
20 import org.hipparchus.random.Well1024a;
21 import org.junit.jupiter.api.Assertions;
22 import org.junit.jupiter.api.Test;
23
24 import java.util.Arrays;
25
26 public class NutationCodecTest {
27
28 @Test
29 public void testKeySymmetry() {
30
31 RandomGenerator random = new Well1024a(0x8fef7f6f99ad5d56l);
32 int[] multipliers = new int[15];
33 for (int i = 0; i < 100000; ++i) {
34 Arrays.fill(multipliers, 0);
35 int nb = 1 + random.nextInt(7);
36 for (int k = 0; k < nb; ++k) {
37 int index = random.nextInt(15);
38 while (multipliers[index] == 0) {
39 multipliers[index] = random.nextInt(128) - 64;
40 }
41 }
42 long key = NutationCodec.encode(multipliers);
43 int[] rebuilt = NutationCodec.decode(key);
44 for (int k = 0; k < multipliers.length; ++k) {
45 Assertions.assertEquals(multipliers[k], rebuilt[k]);
46 }
47 }
48
49 }
50
51 }