source: josm/trunk/test/unit/org/openstreetmap/josm/data/coor/PolarCoorTest.java@ 17442

Last change on this file since 17442 was 17275, checked in by Don-vip, 3 years ago

see #16567 - upgrade almost all tests to JUnit 5, except those depending on WiremockRule

See https://github.com/tomakehurst/wiremock/issues/684

  • Property svn:eol-style set to native
File size: 2.1 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.coor;
3
4import static org.junit.jupiter.api.Assertions.assertEquals;
5import static org.junit.jupiter.api.Assertions.assertTrue;
6
7import java.text.DecimalFormat;
8
9import org.junit.jupiter.api.extension.RegisterExtension;
10import org.junit.jupiter.api.Test;
11import org.openstreetmap.josm.TestUtils;
12import org.openstreetmap.josm.testutils.JOSMTestRules;
13
14import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
15import nl.jqno.equalsverifier.EqualsVerifier;
16
17/**
18 * Test the {@link PolarCoor} class.
19 */
20class 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}
Note: See TracBrowser for help on using the repository browser.