source: josm/trunk/test/unit/org/openstreetmap/josm/tools/AlphanumComparatorTest.java@ 18690

Last change on this file since 18690 was 18690, checked in by taylor.smock, 14 months ago

See #16567: Convert all assertion calls to JUnit 5 (patch by gaben, modified)

The modifications are as follows:

  • Merge DomainValidatorTest.testIDN and DomainValidatorTest.testIDNJava6OrLater
  • Update some tests to use @ParameterizedTest (DomainValidatorTest)
  • Replace various exception blocks with assertThrows. These typically looked like
        try {
            // Something that should throw an exception here
            fail("An exception should have been thrown");
        } catch (Exception e) {
            // Verify the exception matches expectations here
        }
    
  • Replace assertTrue(val instanceof Clazz) with assertInstanceOf
  • Replace JUnit 4 @Suite with JUnit 5 @Suite

Both the original patch and the modified patch fix various lint issues.

  • Property svn:eol-style set to native
File size: 912 bytes
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.tools;
3
4import static org.junit.jupiter.api.Assertions.assertEquals;
5
6import java.util.Arrays;
7import java.util.List;
8
9import org.junit.jupiter.api.Test;
10
11/**
12 * Unit tests of {@link AlphanumComparator}.
13 */
14class AlphanumComparatorTest {
15
16 /**
17 * Test numeric strings.
18 */
19 @Test
20 void testNumeric() {
21 List<String> lst = Arrays.asList("1", "20", "-1", "00999", "100");
22 lst.sort(AlphanumComparator.getInstance());
23 assertEquals(Arrays.asList("-1", "1", "20", "100", "00999"), lst);
24 }
25
26 /**
27 * Test mixed character strings.
28 */
29 @Test
30 void testMixed() {
31 List<String> lst = Arrays.asList("b1", "b20", "a5", "a00999", "a100");
32 lst.sort(AlphanumComparator.getInstance());
33 assertEquals(Arrays.asList("a5", "a100", "a00999", "b1", "b20"), lst);
34 }
35}
Note: See TracBrowser for help on using the repository browser.