Changeset 17114 in josm for trunk/test


Ignore:
Timestamp:
2020-10-08T19:48:57+02:00 (4 years ago)
Author:
simon04
Message:

see #19704 - Enhance DateUtils.tsFromString to fix unit tests

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/osm/search/SearchCompilerTest.java

    r16618 r17114  
    432432    @Test
    433433    public void testTimestamp() throws SearchParseError {
    434         final Match search = SearchCompiler.compile("timestamp:2010/2011");
    435434        final Node n1 = new Node();
    436435        n1.setTimestamp(DateUtils.fromString("2010-01-22"));
    437         assertTrue(search.match(n1));
     436        assertTrue(SearchCompiler.compile("timestamp:2010/2011").match(n1));
     437        assertTrue(SearchCompiler.compile("timestamp:2010-01/2011").match(n1));
     438        assertTrue(SearchCompiler.compile("timestamp:2010-01-22/2011").match(n1));
     439        assertFalse(SearchCompiler.compile("timestamp:2010-01-23/2011").match(n1));
     440        assertFalse(SearchCompiler.compile("timestamp:2010/2010-01-21").match(n1));
    438441        n1.setTimestamp(DateUtils.fromString("2016-01-22"));
    439         assertFalse(search.match(n1));
     442        assertFalse(SearchCompiler.compile("timestamp:2010/2011").match(n1));
    440443    }
    441444
  • trunk/test/unit/org/openstreetmap/josm/tools/date/DateUtilsTest.java

    r17104 r17114  
    9696        assertEquals(851042397000L, DateUtils.fromString("1996-12-19T16:39:57-08:00").getTime());
    9797        assertEquals(-1041337172130L, DateUtils.fromString("1937-01-01T12:00:27.87+00:20").getTime());
     98        // (partial) dates
     99        assertEquals(482112000000L, DateUtils.fromString("1985-04-12").getTime());
     100        assertEquals(481161600000L, DateUtils.fromString("1985-04").getTime());
     101        assertEquals(473385600000L, DateUtils.fromString("1985").getTime());
    98102    }
    99103
Note: See TracChangeset for help on using the changeset viewer.