Ignore:
Timestamp:
2014-01-10T16:39:29+01:00 (10 years ago)
Author:
simon04
Message:

fix #9561 - Bug in getDurationString

File:
1 edited

Legend:

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

    r6652 r6661  
    99import java.net.URL;
    1010import java.util.Arrays;
     11import java.util.Locale;
    1112
    1213import static org.hamcrest.CoreMatchers.is;
     
    99100        assertThat(Utils.getPositionListString(Arrays.asList(1, 5, 2, 6, 7)), is("1-2,5-7"));
    100101    }
     102
     103    @Test
     104    public void testDurationString() throws Exception {
     105        Locale.setDefault(Locale.ENGLISH);
     106        assertThat(Utils.getDurationString(123), is("123 ms"));
     107        assertThat(Utils.getDurationString(1234), is("1.2 s"));
     108        assertThat(Utils.getDurationString(57 * 1000), is("57.0 s"));
     109        assertThat(Utils.getDurationString(507 * 1000), is("8 min 27 s"));
     110        assertThat(Utils.getDurationString((long) (8.4 * 60 * 60 * 1000)), is("8 h 24 min"));
     111        assertThat(Utils.getDurationString((long) (1.5 * 24 * 60 * 60 * 1000)), is("1 day 12 h"));
     112        assertThat(Utils.getDurationString((long) (8.5 * 24 * 60 * 60 * 1000)), is("8 days 12 h"));
     113    }
    101114}
Note: See TracChangeset for help on using the changeset viewer.