Changeset 15196 in josm for trunk/test/unit/org/openstreetmap
- Timestamp:
- 2019-06-29T23:07:03+02:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.java
r14796 r15196 14 14 import org.junit.Rule; 15 15 import org.junit.Test; 16 import org.openstreetmap.josm.TestUtils; 16 17 import org.openstreetmap.josm.data.coor.LatLon; 17 18 import org.openstreetmap.josm.data.osm.DataSet; 18 19 import org.openstreetmap.josm.data.osm.Node; 19 20 import org.openstreetmap.josm.data.osm.OsmUtils; 21 import org.openstreetmap.josm.data.osm.Relation; 22 import org.openstreetmap.josm.data.osm.RelationMember; 20 23 import org.openstreetmap.josm.data.osm.Way; 21 24 import org.openstreetmap.josm.gui.mappaint.Environment; … … 405 408 406 409 @Test 410 public void testCountRoles() throws Exception { 411 DataSet ds = new DataSet(); 412 Way way1 = TestUtils.newWay("highway=residential name=1", 413 new Node(new LatLon(0, 0)), new Node((new LatLon(0.001, 0.001)))); 414 for (Node node : way1.getNodes()) { 415 ds.addPrimitive(node); 416 } 417 ds.addPrimitive(way1); 418 419 Relation rel1 = TestUtils.newRelation("type=destination_sign", new RelationMember("", way1)); 420 ds.addPrimitive(rel1); 421 422 /* Check with empty role and one object */ 423 Environment e = new Environment(rel1, new MultiCascade(), Environment.DEFAULT_LAYER, null); 424 assertEquals(1, ExpressionFactory.Functions.count_roles(e, "")); 425 426 /* Check with non-empty role and one object */ 427 e = new Environment(rel1, new MultiCascade(), Environment.DEFAULT_LAYER, null); 428 assertEquals(0, ExpressionFactory.Functions.count_roles(e, "from")); 429 430 /* Check with empty role and two objects */ 431 Way way2 = TestUtils.newWay("highway=residential name=2", way1.firstNode(), way1.lastNode()); 432 ds.addPrimitive(way2); 433 rel1.addMember(new RelationMember("", way2)); 434 e = new Environment(rel1, new MultiCascade(), Environment.DEFAULT_LAYER, null); 435 assertEquals(2, ExpressionFactory.Functions.count_roles(e, "")); 436 437 /* Check with non-empty role and two objects */ 438 rel1.setMember(0, new RelationMember("from", way1)); 439 e = new Environment(rel1, new MultiCascade(), Environment.DEFAULT_LAYER, null); 440 assertEquals(1, ExpressionFactory.Functions.count_roles(e, "from")); 441 442 /* Check with multiple roles */ 443 assertEquals(1, ExpressionFactory.Functions.count_roles(e, "from", "to")); 444 445 /* Check with non-relation */ 446 e = new Environment(way1, new MultiCascade(), Environment.DEFAULT_LAYER, null); 447 assertEquals(0, ExpressionFactory.Functions.count_roles(e, "from", "to")); 448 } 449 450 @Test 407 451 public void testSiblingSelectorInterpolation() throws Exception { 408 452 ChildOrParentSelector s1 = (Selector.ChildOrParentSelector) getParser(
Note:
See TracChangeset
for help on using the changeset viewer.