1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.tools;
|
---|
3 |
|
---|
4 | import static org.junit.Assert.assertEquals;
|
---|
5 |
|
---|
6 | import java.util.Arrays;
|
---|
7 | import java.util.Collections;
|
---|
8 | import java.util.List;
|
---|
9 |
|
---|
10 | import org.junit.Test;
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * Unit tests of {@link AlphanumComparator}.
|
---|
14 | */
|
---|
15 | public class AlphanumComparatorTest {
|
---|
16 |
|
---|
17 | /**
|
---|
18 | * Test numeric strings.
|
---|
19 | */
|
---|
20 | @Test
|
---|
21 | public void testNumeric() {
|
---|
22 | List<String> lst = Arrays.asList("1", "20", "-1", "00999", "100");
|
---|
23 | Collections.sort(lst, AlphanumComparator.getInstance());
|
---|
24 | assertEquals(Arrays.asList("-1", "1", "20", "100", "00999"), lst);
|
---|
25 | }
|
---|
26 |
|
---|
27 | /**
|
---|
28 | * Test mixed character strings.
|
---|
29 | */
|
---|
30 | @Test
|
---|
31 | public void testMixed() {
|
---|
32 | List<String> lst = Arrays.asList("b1", "b20", "a5", "a00999", "a100");
|
---|
33 | Collections.sort(lst, AlphanumComparator.getInstance());
|
---|
34 | assertEquals(Arrays.asList("a5", "a100", "a00999", "b1", "b20"), lst);
|
---|
35 | }
|
---|
36 | }
|
---|