source: josm/trunk/test/unit/org/openstreetmap/josm/data/osm/WaySegmentTest.java@ 18853

Last change on this file since 18853 was 18853, checked in by taylor.smock, 8 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.

File size: 1.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.osm;
3
4import static org.junit.jupiter.api.Assertions.assertEquals;
5import static org.junit.jupiter.api.Assertions.assertThrows;
6
7import java.util.Arrays;
8
9import org.junit.jupiter.api.Test;
10import org.openstreetmap.josm.data.coor.LatLon;
11
12/**
13 * Unit tests of the {@code WaySegment} class.
14 */
15class WaySegmentTest {
16 @Test
17 void testForNodePair() {
18 final DataSet ds = new DataSet();
19 final Node n1 = new Node(LatLon.ZERO);
20 final Node n2 = new Node(new LatLon(1, 0));
21 final Node n3 = new Node(new LatLon(2, 0));
22 final Node n4 = new Node(new LatLon(3, 0));
23 final Way w = new Way();
24 for (OsmPrimitive p : Arrays.asList(n1, n2, n3, n4, w)) {
25 ds.addPrimitive(p);
26 }
27 w.addNode(n1);
28 w.addNode(n2);
29 w.addNode(n1);
30 w.addNode(n3);
31 w.addNode(n1);
32 w.addNode(n4);
33 w.addNode(n1);
34 assertEquals(WaySegment.forNodePair(w, n1, n2).getLowerIndex(), 0);
35 assertEquals(WaySegment.forNodePair(w, n1, n3).getLowerIndex(), 2);
36 assertEquals(WaySegment.forNodePair(w, n1, n4).getLowerIndex(), 4);
37 assertEquals(WaySegment.forNodePair(w, n4, n1).getLowerIndex(), 5);
38 IllegalArgumentException iae = assertThrows(IllegalArgumentException.class, () -> WaySegment.forNodePair(w, n3, n4));
39 assertEquals("Node pair is not part of way!", iae.getMessage());
40 }
41}
Note: See TracBrowser for help on using the repository browser.