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

Last change on this file since 7938 was 7938, checked in by bastiK, 5 years ago

add more subversion property svn:eol=native

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