Changeset 15869 in josm for trunk/test/unit
- Timestamp:
- 2020-02-16T23:42:59+01:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/tools/date/DateUtilsTest.java
r15045 r15869 3 3 4 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertFalse; 5 6 import static org.junit.Assert.assertNotEquals; 6 7 import static org.junit.Assert.assertNotNull; 8 import static org.junit.Assert.assertNotSame; 9 import static org.junit.Assert.assertNull; 7 10 8 11 import java.text.DateFormat; … … 164 167 public void testTsFromString() { 165 168 // UTC times 169 assertEquals(1459641600000L, DateUtils.tsFromString("2016-04-03")); 166 170 assertEquals(1459695600000L, DateUtils.tsFromString("2016-04-03T15:00:00Z")); 167 171 assertEquals(1459695600000L, DateUtils.tsFromString("2016-04-03T15:00:00")); … … 177 181 assertEquals(1459695600000L, DateUtils.tsFromString("2016-04-03T15:00:00.000+00:00")); 178 182 assertEquals(1459695600000L, DateUtils.tsFromString("2016-04-03T15:00:00.000-00:00")); 183 assertEquals(1459695600123L, DateUtils.tsFromString("2016-04-03T15:00:00.123+00:00")); 184 assertEquals(1459695600123L, DateUtils.tsFromString("2016-04-03T15:00:00.123-00:00")); 185 186 // Offset times 187 assertEquals(1459695600000L - 3 * 3600 * 1000, DateUtils.tsFromString("2016-04-03T15:00:00+03")); 188 assertEquals(1459695600000L + 5 * 3600 * 1000, DateUtils.tsFromString("2016-04-03T15:00:00-05")); 189 assertEquals(1459695600000L - 3 * 3600 * 1000, DateUtils.tsFromString("2016-04-03T15:00:00+03:00")); 190 assertEquals(1459695600000L + 5 * 3600 * 1000, DateUtils.tsFromString("2016-04-03T15:00:00-05:00")); 191 assertEquals(1459695600123L - 3 * 3600 * 1000, DateUtils.tsFromString("2016-04-03T15:00:00.123+03:00")); 192 assertEquals(1459695600123L + 5 * 3600 * 1000, DateUtils.tsFromString("2016-04-03T15:00:00.123-05:00")); 179 193 180 194 // Local time 181 195 TimeZone.setDefault(TimeZone.getTimeZone("Europe/Berlin")); 182 196 assertEquals(1459688400000L, DateUtils.tsFromString("03-APR-16 15:00:00")); 197 } 198 199 /** 200 * Unit test of {@link DateUtils#tsFromString} method. 201 */ 202 @Test(expected = UncheckedParseException.class) 203 public void testTsFromStringInvalid1() { 204 DateUtils.tsFromString("foobar"); 205 } 206 207 /** 208 * Unit test of {@link DateUtils#tsFromString} method. 209 */ 210 @Test(expected = UncheckedParseException.class) 211 public void testTsFromStringInvalid2() { 212 DateUtils.tsFromString("2016/04/03"); 183 213 } 184 214 … … 218 248 } 219 249 } 250 251 @Test 252 public void testCloneDate() { 253 assertNull(DateUtils.cloneDate(null)); 254 final Date date = new Date(1453694709000L); 255 assertEquals(date, DateUtils.cloneDate(date)); 256 assertNotSame(date, DateUtils.cloneDate(date)); 257 } 220 258 }
Note:
See TracChangeset
for help on using the changeset viewer.