source: josm/trunk/test/unit/org/openstreetmap/josm/data/gpx/WayPointTest.java

Last change on this file was 18853, checked in by taylor.smock, 7 months ago

See #16567: Update to JUnit 5

This removes new JOSMTestRules() with no additional setup and most
JOSMFixture calls.

Removing the bare JOSMTestRules speeds up the test suite since there are two
fewer System.gc() calls per test.

  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.gpx;
3
4import static org.junit.jupiter.api.Assertions.assertEquals;
5import static org.junit.jupiter.api.Assertions.assertNotEquals;
6
7import java.time.Instant;
8
9import org.junit.jupiter.api.Test;
10import org.openstreetmap.josm.TestUtils;
11import org.openstreetmap.josm.data.coor.LatLon;
12
13import nl.jqno.equalsverifier.EqualsVerifier;
14import nl.jqno.equalsverifier.Warning;
15
16/**
17 * Unit tests for class {@link WayPoint}.
18 */
19class WayPointTest {
20 /**
21 * Unit test of methods {@link WayPoint#equals} and {@link WayPoint#hashCode}.
22 */
23 @Test
24 void testEqualsContract() {
25 TestUtils.assumeWorkingEqualsVerifier();
26 GpxExtensionCollection col = new GpxExtensionCollection();
27 col.add("josm", "from-server", "true");
28 EqualsVerifier.forClass(WayPoint.class).usingGetClass()
29 .suppress(Warning.NONFINAL_FIELDS)
30 .withIgnoredFields("customColoring", "dir", "drawLine", "east", "north", "eastNorthCacheKey")
31 .withPrefabValues(GpxExtensionCollection.class, new GpxExtensionCollection(), col)
32 .verify();
33 }
34
35 /**
36 * Unit test of copy constructor {@link WayPoint#WayPoint(WayPoint)}
37 */
38 @Test
39 void testConstructor() {
40 WayPoint wp1 = new WayPoint(new LatLon(12., 34.));
41 wp1.setInstant(Instant.ofEpochMilli(123_456_789));
42 WayPoint wp2 = new WayPoint(wp1);
43 assertEquals(wp1, wp2);
44 assertEquals(wp1.getInstant(), wp2.getInstant());
45 wp2.setInstant(Instant.ofEpochMilli(234_456_789));
46 assertNotEquals(wp1, wp2);
47 assertNotEquals(wp1.getInstant(), wp2.getInstant());
48 }
49}
Note: See TracBrowser for help on using the repository browser.