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

Last change on this file since 9816 was 9749, checked in by Don-vip, 8 years ago

upgrade to checkstyle 6.15

File size: 1.2 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
15/**
16 * Unit tests of {@link OsmWriter} class.
17 */
18public class OsmWriterTest {
19
20 /**
21 * Unit test of {@link OsmWriter#byIdComparator}.
22 */
23 @Test
24 public void testByIdComparator() {
25
26 final List<NodeData> ids = new ArrayList<>();
27 for (Long id : Arrays.asList(12L, Long.MIN_VALUE, 65L, -12L, 2L, 0L, -3L, -20L, Long.MAX_VALUE)) {
28 final NodeData n = new NodeData();
29 n.setId(id);
30 ids.add(n);
31 }
32
33 Collections.sort(ids, OsmWriter.byIdComparator);
34
35 final String idsAsString = Utils.transform(ids, new Utils.Function<NodeData, Object>() {
36 @Override
37 public Object apply(NodeData x) {
38 return x.getUniqueId();
39 }
40 }).toString();
41
42 assertEquals("[-3, -12, -20, -9223372036854775808, 0, 2, 12, 65, 9223372036854775807]", idsAsString);
43 }
44}
Note: See TracBrowser for help on using the repository browser.