source: josm/trunk/test/unit/org/openstreetmap/josm/io/OsmWriterTest.java@ 9310

Last change on this file since 9310 was 9310, checked in by simon04, 8 years ago

fix #11773 - Saving osm files in JOSM will save the nodes in one of two orders

File size: 1.1 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.io;
3
4import static org.junit.Assert.assertEquals;
5
6import java.util.ArrayList;
7import java.util.Arrays;
8import java.util.Collections;
9import java.util.List;
10
11import org.junit.Test;
12import org.openstreetmap.josm.data.osm.NodeData;
13import org.openstreetmap.josm.tools.Utils;
14
15public class OsmWriterTest {
16
17 @Test
18 public void testByIdComparator() throws Exception {
19
20 final List<NodeData> ids = new ArrayList<>();
21 for (Long id : Arrays.asList(12L, Long.MIN_VALUE, 65L, -12L, 2L, 0L, -3L, -20L, Long.MAX_VALUE)) {
22 final NodeData n = new NodeData();
23 n.setId(id);
24 ids.add(n);
25 }
26
27 Collections.sort(ids, OsmWriter.byIdComparator);
28
29 final String idsAsString = Utils.transform(ids, new Utils.Function<NodeData, Object>() {
30 @Override
31 public Object apply(NodeData x) {
32 return x.getUniqueId();
33 }
34 }).toString();
35
36 assertEquals("[-3, -12, -20, -9223372036854775808, 0, 2, 12, 65, 9223372036854775807]", idsAsString);
37 }
38}
Note: See TracBrowser for help on using the repository browser.