1 | // License: GPL. For details, see LICENSE file. |
---|
2 | package org.openstreetmap.josm.data.validation.tests |
---|
3 | |
---|
4 | import org.openstreetmap.josm.JOSMFixture |
---|
5 | import org.openstreetmap.josm.gui.tagging.TaggingPresets |
---|
6 | |
---|
7 | class ConditionalKeysTest extends GroovyTestCase { |
---|
8 | |
---|
9 | ConditionalKeys test = new ConditionalKeys() |
---|
10 | |
---|
11 | @Override |
---|
12 | void setUp() { |
---|
13 | JOSMFixture.createUnitTestFixture().init(); |
---|
14 | TaggingPresets.readFromPreferences() |
---|
15 | test.initialize() |
---|
16 | } |
---|
17 | |
---|
18 | void testKeyValid() { |
---|
19 | assert test.isKeyValid("maxspeed:conditional") |
---|
20 | assert test.isKeyValid("motor_vehicle:conditional") |
---|
21 | assert test.isKeyValid("bicycle:conditional") |
---|
22 | assert test.isKeyValid("overtaking:hgv:conditional") |
---|
23 | assert test.isKeyValid("maxspeed:hgv:backward:conditional") |
---|
24 | assert test.isKeyValid("oneway:backward:conditional") |
---|
25 | assert test.isKeyValid("fee:conditional") |
---|
26 | assert !test.isKeyValid("maxspeed:hgv:conditional:backward") |
---|
27 | } |
---|
28 | |
---|
29 | void testValueValid() { |
---|
30 | assert test.isValueValid("maxspeed:conditional", "120 @ (06:00-19:00)") |
---|
31 | assert !test.isValueValid("maxspeed:conditional", " @ (06:00-19:00)") |
---|
32 | assert !test.isValueValid("maxspeed:conditional", "120 (06:00-19:00)") |
---|
33 | assert !test.isValueValid("maxspeed:conditional", "120 @ ()") |
---|
34 | assert !test.isValueValid("maxspeed:conditional", "120 @ ") |
---|
35 | assert !test.isValueValid("maxspeed:conditional", "120 @ (06:00/19:00)") |
---|
36 | assert test.isValueValid("maxspeed:conditional", "120 @ (06:00-20:00); 100 @ (22:00-06:00)") |
---|
37 | assert test.isValueValid("motor_vehicle:conditional", "delivery @ (Mo-Fr 06:00-11:00,17:00-19:00;Sa 03:30-19:00)") |
---|
38 | assert test.isValueValid("motor_vehicle:conditional", "no @ (10:00-18:00 AND length>5)") |
---|
39 | assert !test.isValueValid("motor_vehicle:conditional", "foo @ (10:00-18:00 AND length>5)") |
---|
40 | assert !test.isValueValid("motor_vehicle:conditional", "no @ (10:00until18:00 AND length>5)") |
---|
41 | assert test.isValueValid("maxspeed:hgv:conditional", "60 @ (weight>7.5)") |
---|
42 | } |
---|
43 | } |
---|