Changeset 7167 in josm for trunk/test/unit


Ignore:
Timestamp:
2014-05-22T17:13:04+02:00 (11 years ago)
Author:
simon04
Message:

MapCSS: simplify ~= implementation, add unit tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.groovy

    r7166 r7167  
    122122
    123123    @Test
     124    public void testBeginsEndsWithCondition() throws Exception {
     125        def condition = (Condition.KeyValueCondition) getParser('[foo ^= bar]').condition(Condition.Context.PRIMITIVE)
     126        assert Condition.Op.BEGINS_WITH.equals(condition.op)
     127        assert condition.applies(getEnvironment("foo", "bar123"))
     128        assert !condition.applies(getEnvironment("foo", "123bar"))
     129        assert !condition.applies(getEnvironment("foo", "123bar123"))
     130        condition = (Condition.KeyValueCondition) getParser('[foo $= bar]').condition(Condition.Context.PRIMITIVE)
     131        assert Condition.Op.ENDS_WITH.equals(condition.op)
     132        assert !condition.applies(getEnvironment("foo", "bar123"))
     133        assert condition.applies(getEnvironment("foo", "123bar"))
     134        assert !condition.applies(getEnvironment("foo", "123bar123"))
     135    }
     136
     137    @Test
     138    public void testOneOfCondition() throws Exception {
     139        def condition = getParser('[vending~=stamps]').condition(Condition.Context.PRIMITIVE)
     140        assert condition.applies(getEnvironment("vending", "stamps"))
     141        assert condition.applies(getEnvironment("vending", "bar;stamps;foo"))
     142        assert !condition.applies(getEnvironment("vending", "every;thing;else"))
     143        assert !condition.applies(getEnvironment("vending", "or_nothing"))
     144    }
     145
     146    @Test
    124147    public void testStandardKeyCondition() throws Exception {
    125148        def c1 = (Condition.KeyCondition) getParser("[ highway ]").condition(Condition.Context.PRIMITIVE)
Note: See TracChangeset for help on using the changeset viewer.