Changeset 18553 in josm for trunk/test/unit/org/openstreetmap
- Timestamp:
- 2022-09-08T17:19:20+02:00 (2 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/osm/WayTest.java
r17275 r18553 8 8 9 9 import java.util.Arrays; 10 import java.util.Collections; 10 11 import java.util.HashSet; 11 12 … … 49 50 Way way = new Way(1); 50 51 assertFalse(way.getBBox().isValid()); 51 way.setNodes( Arrays.asList(n1));52 way.setNodes(Collections.singletonList(n1)); 52 53 assertFalse(way.getBBox().isValid()); 53 way.setNodes( Arrays.asList(n2));54 way.setNodes(Collections.singletonList(n2)); 54 55 assertTrue(way.getBBox().isValid()); 55 56 way.setNodes(Arrays.asList(n1, n2)); … … 116 117 assertEquals(Arrays.asList(n1, n2, n1), way.getNodes()); 117 118 way.setNodes(Arrays.asList(n1, n2, n3, n4, n1)); 118 way.removeNodes(new HashSet<>( Arrays.asList(n1)));119 way.removeNodes(new HashSet<>(Collections.singletonList(n1))); 119 120 assertEquals(Arrays.asList(n2, n3, n4, n2), way.getNodes()); 120 121 } … … 135 136 assertThrows(IllegalArgumentException.class, () -> new Way().load(new NodeData())); 136 137 } 138 139 @Test 140 void getLongestSegmentLength() { 141 DataSet ds = new DataSet(); 142 Node n1 = new Node(1); 143 Node n2 = new Node(2); 144 Node n3 = new Node(3); 145 Node n4 = new Node(4); 146 n1.setCoor(new LatLon(0.01, 0.01)); 147 n2.setCoor(new LatLon(0.02, 0.02)); 148 n3.setCoor(new LatLon(0.03, 0.03)); 149 n4.setCoor(new LatLon(0.05, 0.05)); 150 ds.addPrimitive(n1); 151 ds.addPrimitive(n2); 152 ds.addPrimitive(n3); 153 ds.addPrimitive(n4); 154 Way way = new Way(1); 155 ds.addPrimitive(way); 156 157 assertEquals(0.0, way.getLongestSegmentLength()); 158 way.setNodes(Arrays.asList(n1, n2, n2, n3, n4)); 159 160 assertEquals(3148.5902810874577, way.getLongestSegmentLength()); 161 } 137 162 } -
trunk/test/unit/org/openstreetmap/josm/tools/UtilsTest.java
r18037 r18553 128 128 @Test 129 129 void testPositionListString() { 130 assertEquals("1", Utils.getPositionListString( Arrays.asList(1)));130 assertEquals("1", Utils.getPositionListString(Collections.singletonList(1))); 131 131 assertEquals("1-2", Utils.getPositionListString(Arrays.asList(1, 2))); 132 132 assertEquals("1-3", Utils.getPositionListString(Arrays.asList(1, 2, 3))); … … 251 251 @Test 252 252 void testJoinAsHtmlUnorderedList() { 253 List<? extends Object> items = Arrays.asList("1", Integer.valueOf(2));253 List<?> items = Arrays.asList("1", 2); 254 254 assertEquals("<ul><li>1</li><li>2</li></ul>", Utils.joinAsHtmlUnorderedList(items)); 255 255 assertEquals("<ul></ul>", Utils.joinAsHtmlUnorderedList(Collections.emptyList())); … … 532 532 assertEquals("Hello World", output); 533 533 } 534 535 /** 536 * Test of {@link Utils#getStandardDeviation(double[])} and {@link Utils#getStandardDeviation(double[], double)} 537 */ 538 @Test 539 void testGetStandardDeviation() { 540 assertEquals(0.0, Utils.getStandardDeviation(new double[]{1, 1, 1, 1})); 541 assertEquals(0.0, Utils.getStandardDeviation(new double[]{1, 1, 1, 1}, 1.0)); 542 assertEquals(0.5, Utils.getStandardDeviation(new double[]{1, 1, 2, 2})); 543 544 assertEquals(-1.0, Utils.getStandardDeviation(new double[]{})); 545 assertEquals(-1.0, Utils.getStandardDeviation(new double[]{0})); 546 } 534 547 }
Note:
See TracChangeset
for help on using the changeset viewer.