Ignore:
Timestamp:
2015-10-11T17:28:19+02:00 (9 years ago)
Author:
Don-vip
Message:

improve/cleanup unit tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/tools/UtilsTest.java

    r8756 r8857  
    22package org.openstreetmap.josm.tools;
    33
    4 import static org.hamcrest.CoreMatchers.is;
    5 import static org.junit.Assert.assertThat;
     4import static org.junit.Assert.assertEquals;
    65
    76import java.io.BufferedReader;
     
    109108    @Test
    110109    public void testPositionListString() {
    111         assertThat(Utils.getPositionListString(Arrays.asList(1)), is("1"));
    112         assertThat(Utils.getPositionListString(Arrays.asList(1, 2, 3)), is("1-3"));
    113         assertThat(Utils.getPositionListString(Arrays.asList(3, 1, 2)), is("1-3"));
    114         assertThat(Utils.getPositionListString(Arrays.asList(1, 2, 3, 6, 7, 8)), is("1-3,6-8"));
    115         assertThat(Utils.getPositionListString(Arrays.asList(1, 5, 2, 6, 7)), is("1-2,5-7"));
     110        assertEquals("1", Utils.getPositionListString(Arrays.asList(1)));
     111        assertEquals("1-3", Utils.getPositionListString(Arrays.asList(1, 2, 3)));
     112        assertEquals("1-3", Utils.getPositionListString(Arrays.asList(3, 1, 2)));
     113        assertEquals("1-3,6-8", Utils.getPositionListString(Arrays.asList(1, 2, 3, 6, 7, 8)));
     114        assertEquals("1-2,5-7", Utils.getPositionListString(Arrays.asList(1, 5, 2, 6, 7)));
    116115    }
    117116
     
    122121    public void testDurationString() {
    123122        I18n.set("en");
    124         assertThat(Utils.getDurationString(123), is("123 ms"));
    125         assertThat(Utils.getDurationString(1234), is("1.2 s"));
    126         assertThat(Utils.getDurationString(57 * 1000), is("57.0 s"));
    127         assertThat(Utils.getDurationString(507 * 1000), is("8 min 27 s"));
    128         assertThat(Utils.getDurationString((long) (8.4 * 60 * 60 * 1000)), is("8 h 24 min"));
    129         assertThat(Utils.getDurationString((long) (1.5 * 24 * 60 * 60 * 1000)), is("1 day 12 h"));
    130         assertThat(Utils.getDurationString((long) (8.5 * 24 * 60 * 60 * 1000)), is("8 days 12 h"));
     123        assertEquals("123 ms", Utils.getDurationString(123));
     124        assertEquals("1.2 s", Utils.getDurationString(1234));
     125        assertEquals("57.0 s", Utils.getDurationString(57 * 1000));
     126        assertEquals("8 min 27 s", Utils.getDurationString(507 * 1000));
     127        assertEquals("8 h 24 min", Utils.getDurationString((long) (8.4 * 60 * 60 * 1000)));
     128        assertEquals("1 day 12 h", Utils.getDurationString((long) (1.5 * 24 * 60 * 60 * 1000)));
     129        assertEquals("8 days 12 h", Utils.getDurationString((long) (8.5 * 24 * 60 * 60 * 1000)));
    131130    }
    132131
     132    /**
     133     * Test of {@link Utils#escapeReservedCharactersHTML} method.
     134     */
    133135    @Test
    134     public void testEscapeReservedCharactersHTML() throws Exception {
    135         assertThat(Utils.escapeReservedCharactersHTML("foo -> bar -> '&'"), is("foo -> bar -> '&'"));
     136    public void testEscapeReservedCharactersHTML() {
     137        assertEquals("foo -> bar -> '&'", Utils.escapeReservedCharactersHTML("foo -> bar -> '&'"));
    136138    }
    137139
     140    /**
     141     * Test of {@link Utils#restrictStringLines} method.
     142     */
    138143    @Test
    139     public void testRestrictStringLines() throws Exception {
    140         assertThat(Utils.restrictStringLines("1\n2\n3", 2), is("1\n..."));
    141         assertThat(Utils.restrictStringLines("1\n2\n3", 3), is("1\n2\n3"));
    142         assertThat(Utils.restrictStringLines("1\n2\n3", 4), is("1\n2\n3"));
     144    public void testRestrictStringLines() {
     145        assertEquals("1\n...", Utils.restrictStringLines("1\n2\n3", 2));
     146        assertEquals("1\n2\n3", Utils.restrictStringLines("1\n2\n3", 3));
     147        assertEquals("1\n2\n3", Utils.restrictStringLines("1\n2\n3", 4));
    143148    }
    144149}
Note: See TracChangeset for help on using the changeset viewer.