1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.io;
|
---|
3 |
|
---|
4 | import static org.junit.Assert.assertEquals;
|
---|
5 |
|
---|
6 | import java.util.ArrayList;
|
---|
7 | import java.util.Arrays;
|
---|
8 | import java.util.Collections;
|
---|
9 | import java.util.List;
|
---|
10 |
|
---|
11 | import org.junit.Test;
|
---|
12 | import org.openstreetmap.josm.data.osm.NodeData;
|
---|
13 | import org.openstreetmap.josm.tools.Utils;
|
---|
14 |
|
---|
15 | public 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 | }
|
---|