Changeset 17593 in josm for trunk/test/unit/org
- Timestamp:
- 2021-03-20T11:50:06+01:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/KeyConditionTest.java
r17275 r17593 2 2 package org.openstreetmap.josm.gui.mappaint.mapcss; 3 3 4 import static org.junit.jupiter.api.Assertions.assertEquals; 4 5 import static org.junit.jupiter.api.Assertions.assertFalse; 5 6 import static org.junit.jupiter.api.Assertions.assertTrue; … … 12 13 import org.openstreetmap.josm.data.osm.DataSet; 13 14 import org.openstreetmap.josm.data.osm.Node; 15 import org.openstreetmap.josm.data.osm.OsmUtils; 14 16 import org.openstreetmap.josm.data.osm.Relation; 15 17 import org.openstreetmap.josm.data.osm.RelationMember; … … 82 84 ConditionFactory.createKeyCondition("a key", true, KeyMatchType.TRUE, Context.PRIMITIVE); 83 85 86 // [/regex/] 87 Condition c = ConditionFactory.createKeyCondition("foo|bar", false, KeyMatchType.REGEX, Context.PRIMITIVE); 88 assertTrue(c.applies(new Environment(OsmUtils.createPrimitive("node BARfooBAZ=true")))); 89 assertFalse(c.applies(new Environment(OsmUtils.createPrimitive("node BARBAZ=true")))); 90 c = ConditionFactory.createKeyCondition("colour:", false, KeyMatchType.REGEX, Context.PRIMITIVE); 91 assertEquals(KeyMatchType.ANY_CONTAINS, ((KeyCondition) c).matchType); 92 assertEquals("colour:", ((KeyCondition) c).label); 93 assertTrue(c.applies(new Environment(OsmUtils.createPrimitive("node colour:roof=ref")))); 94 assertFalse(c.applies(new Environment(OsmUtils.createPrimitive("node foo=bar")))); 95 c = ConditionFactory.createKeyCondition("^wikipedia:", false, KeyMatchType.REGEX, Context.PRIMITIVE); 96 assertEquals(KeyMatchType.ANY_STARTS_WITH, ((KeyCondition) c).matchType); 97 assertEquals("wikipedia:", ((KeyCondition) c).label); 98 assertTrue(c.applies(new Environment(OsmUtils.createPrimitive("node wikipedia:en=a")))); 99 assertFalse(c.applies(new Environment(OsmUtils.createPrimitive("node wikipedia=a")))); 100 c = ConditionFactory.createKeyCondition("_name$", false, KeyMatchType.REGEX, Context.PRIMITIVE); 101 assertEquals(KeyMatchType.ANY_ENDS_WITH, ((KeyCondition) c).matchType); 102 assertEquals("_name", ((KeyCondition) c).label); 103 assertTrue(c.applies(new Environment(OsmUtils.createPrimitive("node alt_name=a")))); 104 assertFalse(c.applies(new Environment(OsmUtils.createPrimitive("node name=a")))); 105 84 106 // ["a label"] 85 107 ConditionFactory.createKeyCondition("a key", false, null, Context.LINK);
Note:
See TracChangeset
for help on using the changeset viewer.