Ignore:
Timestamp:
2016-01-03T12:13:44+01:00 (4 years ago)
Author:
simon04
Message:

Uniform display of sizes (B, kB, MB, ...)

File:
1 edited

Legend:

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

    r9174 r9274  
    88import java.net.URL;
    99import java.util.Arrays;
     10import java.util.Locale;
    1011
    1112import org.junit.Assert;
     
    163164        assertEquals("1\n2\n3", Utils.restrictStringLines("1\n2\n3", 4));
    164165    }
     166
     167    /**
     168     * Test of {@link Utils#getSizeString} method.
     169     */
     170    @Test
     171    public void testSizeString() throws Exception {
     172        assertEquals("0 B", Utils.getSizeString(0, Locale.ENGLISH));
     173        assertEquals("123 B", Utils.getSizeString(123, Locale.ENGLISH));
     174        assertEquals("1023 B", Utils.getSizeString(1023, Locale.ENGLISH));
     175        assertEquals("1.00 kB", Utils.getSizeString(1024, Locale.ENGLISH));
     176        assertEquals("11.7 kB", Utils.getSizeString(12024, Locale.ENGLISH));
     177        assertEquals("8.00 EB", Utils.getSizeString(Long.MAX_VALUE, Locale.ENGLISH));
     178    }
     179
     180    /**
     181     * Test of {@link Utils#getSizeString} method.
     182     */
     183    @Test(expected = IllegalArgumentException.class)
     184    public void testSizeStringNegative() throws Exception {
     185        Utils.getSizeString(-1, Locale.ENGLISH);
     186    }
     187
    165188}
Note: See TracChangeset for help on using the changeset viewer.