1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.coor;
|
---|
3 |
|
---|
4 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
---|
5 | import static org.junit.jupiter.api.Assertions.assertTrue;
|
---|
6 |
|
---|
7 | import java.text.DecimalFormat;
|
---|
8 |
|
---|
9 | import org.junit.jupiter.api.extension.RegisterExtension;
|
---|
10 | import org.junit.jupiter.api.Test;
|
---|
11 | import org.openstreetmap.josm.TestUtils;
|
---|
12 | import org.openstreetmap.josm.testutils.JOSMTestRules;
|
---|
13 |
|
---|
14 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
---|
15 | import nl.jqno.equalsverifier.EqualsVerifier;
|
---|
16 |
|
---|
17 | /**
|
---|
18 | * Test the {@link PolarCoor} class.
|
---|
19 | */
|
---|
20 | class PolarCoorTest {
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * Setup test.
|
---|
24 | */
|
---|
25 | @RegisterExtension
|
---|
26 | @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
|
---|
27 | public JOSMTestRules test = new JOSMTestRules().projection();
|
---|
28 |
|
---|
29 | /**
|
---|
30 | * Test {@link PolarCoor#PolarCoor}
|
---|
31 | */
|
---|
32 | @Test
|
---|
33 | void testPolarCoor() {
|
---|
34 | EastNorth en = new EastNorth(1000, 500);
|
---|
35 | PolarCoor pc = new PolarCoor(en);
|
---|
36 | assertEquals(1118.033988749, pc.radius, 1e-7);
|
---|
37 | assertEquals(0.463647609, pc.angle, 1e-7);
|
---|
38 | assertEquals(new EastNorth(0, 0), pc.pole);
|
---|
39 | assertTrue(en.equalsEpsilon(pc.toEastNorth(), 1e-7));
|
---|
40 |
|
---|
41 | pc = new PolarCoor(1118.033988749, 0.463647609);
|
---|
42 | assertEquals(1118.033988749, pc.radius, 1e-7);
|
---|
43 | assertEquals(0.463647609, pc.angle, 1e-7);
|
---|
44 | assertEquals(new EastNorth(0, 0), pc.pole);
|
---|
45 | assertTrue(en.equalsEpsilon(pc.toEastNorth(), 1e-7));
|
---|
46 | }
|
---|
47 |
|
---|
48 | /**
|
---|
49 | * Unit test of methods {@link PolarCoor#equals} and {@link PolarCoor#hashCode}.
|
---|
50 | */
|
---|
51 | @Test
|
---|
52 | void testEqualsContract() {
|
---|
53 | TestUtils.assumeWorkingEqualsVerifier();
|
---|
54 | EqualsVerifier.forClass(PolarCoor.class).usingGetClass()
|
---|
55 | .withPrefabValues(DecimalFormat.class, new DecimalFormat("00.0"), new DecimalFormat("00.000"))
|
---|
56 | .verify();
|
---|
57 | }
|
---|
58 |
|
---|
59 | /**
|
---|
60 | * Unit test of method {@link PolarCoor#toString}.
|
---|
61 | */
|
---|
62 | @Test
|
---|
63 | void testToString() {
|
---|
64 | assertEquals("PolarCoor [radius=1118.033988749, angle=0.463647609, pole=EastNorth[e=0.0, n=0.0]]",
|
---|
65 | new PolarCoor(1118.033988749, 0.463647609).toString());
|
---|
66 | }
|
---|
67 | }
|
---|