source: josm/trunk/test/unit/org/openstreetmap/josm/data/validation/tests/LanesTest.groovy @ 7357

Last change on this file since 7357 was 7357, checked in by Don-vip, 6 years ago

see #10206 - update Groovy tests

File size: 2.3 KB
Line 
1package org.openstreetmap.josm.data.validation.tests
2
3import org.openstreetmap.josm.data.osm.OsmUtils
4
5class LanesTest extends GroovyTestCase {
6
7    Lanes lanes = new Lanes()
8
9    @Override
10    void setUp() {
11        lanes.initialize()
12        lanes.startTest(null)
13    }
14
15    void testLanesCount() {
16        assert lanes.getLanesCount("") == 0
17        assert lanes.getLanesCount("left") == 1
18        assert lanes.getLanesCount("left|right") == 2
19        assert lanes.getLanesCount("yes|no|yes") == 3
20        assert lanes.getLanesCount("yes||") == 3
21    }
22
23    void test1() {
24        lanes.check(OsmUtils.createPrimitive("way turn:lanes=left|right change:lanes=only_left|not_right|yes"))
25        assert lanes.errors.get(0).getMessage() == "Number of lane dependent values inconsistent"
26    }
27
28    void test2() {
29        lanes.check(OsmUtils.createPrimitive("way width:lanes:forward=1|2|3 psv:lanes:forward=no|designated"))
30        assert lanes.errors.get(0).getMessage() == "Number of lane dependent values inconsistent in forward direction"
31    }
32
33    void test3() {
34        lanes.check(OsmUtils.createPrimitive("way change:lanes:forward=yes|no turn:lanes:backward=left|right|left"))
35        assert lanes.errors.isEmpty()
36    }
37
38    void test4() {
39        lanes.check(OsmUtils.createPrimitive("way turn:lanes:forward=left|right change:lanes:forward=yes|no|yes width:backward=1|2|3"))
40        assert lanes.errors.get(0).getMessage() == "Number of lane dependent values inconsistent in forward direction"
41    }
42
43    void test5() {
44        lanes.check(OsmUtils.createPrimitive("way lanes:forward=5 turn:lanes:forward=left|right"))
45        assert lanes.errors.get(0).getMessage() == "Number of lanes:forward greater than *:lanes:forward"
46    }
47
48    void test6() {
49        lanes.check(OsmUtils.createPrimitive("way lanes:forward=foo|bar turn:lanes:forward=foo+bar"))
50        assert lanes.errors.isEmpty()
51    }
52
53    void test7() {
54        lanes.check(OsmUtils.createPrimitive("way lanes=3 lanes:forward=3 lanes:backward=7"))
55        assert lanes.errors.get(0).getMessage() == "Number of lanes:forward+lanes:backward greater than lanes"
56    }
57
58    void test8() {
59        lanes.check(OsmUtils.createPrimitive("way destination:country:lanes=X|Y;Z|none destination:ref:lanes=xyz|| destination:sign:lanes=none|airport|none"))
60        assert lanes.errors.isEmpty()
61    }
62}
Note: See TracBrowser for help on using the repository browser.