1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.hipparchus.complex;
23
24 import java.util.HashMap;
25 import java.util.Map;
26
27 import org.hipparchus.Field;
28 import org.hipparchus.UnitTestUtils;
29 import org.hipparchus.util.Binary64Field;
30 import org.junit.Assert;
31 import org.junit.Test;
32
33 public class ComplexFieldTest {
34
35 @Test
36 public void testZero() {
37 Assert.assertEquals(Complex.ZERO, ComplexField.getInstance().getZero());
38 }
39
40 @Test
41 public void testOne() {
42 Assert.assertEquals(Complex.ONE, ComplexField.getInstance().getOne());
43 }
44
45 @SuppressWarnings("unlikely-arg-type")
46 @Test
47 public void testMap() {
48 Map<Field<?>, Integer> map = new HashMap<>();
49 for (int i = 1; i < 100; ++i) {
50 map.put(new Complex(i).getField(), 0);
51 }
52
53 Assert.assertEquals(1, map.size());
54 Assert.assertTrue(ComplexField.getInstance().equals(map.entrySet().iterator().next().getKey()));
55 Assert.assertFalse(ComplexField.getInstance().equals(Binary64Field.getInstance()));
56 }
57
58 @Test
59 public void testRunTimeClass() {
60 Assert.assertEquals(Complex.class, ComplexField.getInstance().getRuntimeClass());
61 }
62
63 @Test
64 public void testSerial() {
65
66 ComplexField field = ComplexField.getInstance();
67 Assert.assertTrue(field == UnitTestUtils.serializeAndRecover(field));
68 }
69
70 }