Changeset 6376 in josm for trunk/test/unit


Ignore:
Timestamp:
2013-11-07T21:28:12+01:00 (11 years ago)
Author:
simon04
Message:

see #9157 - check collection_times and service_times as well

And fix/add unit tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/validation/tests/OpeningHourTestTest.java

    r6370 r6376  
    6161        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("badtext").size(), is(1));
    6262        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("badtext").get(0).getMessage(),
    63                 is("ba <--- (Unexpected token: \"b\" This means that the syntax is not valid at that point or it is currently not supported.)"));
     63                is("opening_hours - ba <--- (Unexpected token: \"b\" This means that the syntax is not valid at that point or it is currently not supported.)"));
     64    }
     65
     66    @Test
     67    public void testCheckOpeningHourSyntax6() throws Exception {
     68        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("PH open \"always open on public holidays\"").isEmpty(), is(true));
     69    }
     70
     71    @Test
     72    public void testCheckServiceTimeSyntax1() throws Exception {
     73        // frequently used tags according to http://taginfo.openstreetmap.org/keys/service_times#values
     74        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("Su 10:00", OpeningHourTest.CheckMode.BOTH).isEmpty(), is(true));
     75        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("automatic", OpeningHourTest.CheckMode.BOTH).isEmpty(), is(false));
     76        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("Mo-Sa 09:00-18:00", OpeningHourTest.CheckMode.BOTH).isEmpty(), is(true));
     77        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("Su 09:30; We 19:30", OpeningHourTest.CheckMode.BOTH).isEmpty(), is(true));
     78        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("Mo-Fr 0:00-0:30,4:00-00:30; Sa,Su,PH 0:00-24:00", OpeningHourTest.CheckMode.BOTH).isEmpty(), is(true));
     79    }
     80
     81    @Test
     82    public void testCheckCollectionTimeSyntax1() throws Exception {
     83        // frequently used tags according to http://taginfo.openstreetmap.org/keys/collection_times#values
     84        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("Mo-Sa 09:00", OpeningHourTest.CheckMode.BOTH).isEmpty(), is(true));
     85        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("fixme", OpeningHourTest.CheckMode.BOTH).isEmpty(), is(false));
     86        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("daily", OpeningHourTest.CheckMode.BOTH).isEmpty(), is(false));
     87        assertThat(OPENING_HOUR_TEST.checkOpeningHourSyntax("Mo-Fr 13:30, 17:45, 19:00; Sa 15:00; Su 11:00", OpeningHourTest.CheckMode.BOTH).isEmpty(), is(true));
    6488    }
    6589}
Note: See TracChangeset for help on using the changeset viewer.