Ignore:
Timestamp:
2016-04-03T15:42:30+02:00 (3 years ago)
Author:
Don-vip
Message:

add more unit tests

File:
1 edited

Legend:

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

    r9739 r10103  
    44import static org.junit.Assert.assertEquals;
    55
     6import java.text.DateFormat;
    67import java.util.Date;
    78import java.util.TimeZone;
    89
     10import org.junit.BeforeClass;
    911import org.junit.Test;
     12import org.openstreetmap.josm.JOSMFixture;
    1013import org.openstreetmap.josm.tools.UncheckedParseException;
    1114
     
    1417 */
    1518public class DateUtilsTest {
     19
     20    /**
     21     * Setup test.
     22     */
     23    @BeforeClass
     24    public static void setUp() {
     25        JOSMFixture.createUnitTestFixture().init();
     26    }
    1627
    1728    /**
     
    8697        assertEquals(1453694709400L, DateUtils.fromString("2016-01-25T04:05:09.400Z").getTime());
    8798    }
     99
     100    /**
     101     * Unit test of {@link DateUtils#fromTimestamp} method.
     102     */
     103    @Test
     104    public void testFromTimestamp() {
     105        assertEquals("1970-01-01T00:00:00Z", DateUtils.fromTimestamp(0));
     106        assertEquals("2001-09-09T01:46:40Z", DateUtils.fromTimestamp(1000000000));
     107        assertEquals("2038-01-19T03:14:07Z", DateUtils.fromTimestamp(Integer.MAX_VALUE));
     108    }
     109
     110    /**
     111     * Unit test of {@link DateUtils#formatTime} method.
     112     */
     113    @Test
     114    public void testFormatTime() {
     115        assertEquals("1:00 AM", DateUtils.formatTime(new Date(123), DateFormat.SHORT));
     116        assertEquals("1:00:00 AM CET", DateUtils.formatTime(new Date(123), DateFormat.LONG));
     117    }
    88118}
Note: See TracChangeset for help on using the changeset viewer.