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

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

add more subversion property svn:eol=native

  • Property svn:eol-style set to native
File size: 2.3 KB
Line 
1// License: GPL. See LICENSE file for details.
2package org.openstreetmap.josm.data.validation.tests
3
4import org.openstreetmap.josm.JOSMFixture
5import org.openstreetmap.josm.data.coor.LatLon
6import org.openstreetmap.josm.data.osm.DataSet
7import org.openstreetmap.josm.data.osm.Way
8
9class HighwaysTest extends GroovyTestCase {
10
11 @Override
12 void setUp() {
13 JOSMFixture.createUnitTestFixture().init();
14 }
15
16 public static Way createTestSetting(String highway, String highwayLink) {
17 def ds = new DataSet()
18
19 def n00 = new org.openstreetmap.josm.data.osm.Node(new LatLon(0, 0))
20 def n10 = new org.openstreetmap.josm.data.osm.Node(new LatLon(1, 0))
21 def n20 = new org.openstreetmap.josm.data.osm.Node(new LatLon(2, 0))
22 def n01 = new org.openstreetmap.josm.data.osm.Node(new LatLon(0, 1))
23 def n11 = new org.openstreetmap.josm.data.osm.Node(new LatLon(1, 1))
24 def n21 = new org.openstreetmap.josm.data.osm.Node(new LatLon(2, 1))
25
26 ds.addPrimitive(n00)
27 ds.addPrimitive(n10)
28 ds.addPrimitive(n20)
29 ds.addPrimitive(n01)
30 ds.addPrimitive(n11)
31 ds.addPrimitive(n21)
32
33 def major = new Way()
34 major.addNode(n00)
35 major.addNode(n10)
36 major.addNode(n20)
37 major.put("highway", highway)
38 def link = new Way()
39 link.addNode(n10)
40 link.addNode(n11)
41 link.put("highway", highwayLink)
42 def unclassified = new Way()
43 unclassified.addNode(n01)
44 unclassified.addNode(n11)
45 unclassified.addNode(n21)
46 unclassified.put("highway", "unclassified")
47
48 ds.addPrimitive(major)
49 ds.addPrimitive(link)
50 ds.addPrimitive(unclassified)
51
52 return link
53 }
54
55 void testCombinations() {
56 assert Highways.isHighwayLinkOkay(createTestSetting("primary", "primary_link"))
57 assert Highways.isHighwayLinkOkay(createTestSetting("primary", "primary"))
58 assert !Highways.isHighwayLinkOkay(createTestSetting("primary", "secondary_link"))
59 assert !Highways.isHighwayLinkOkay(createTestSetting("secondary", "primary_link"))
60 assert !Highways.isHighwayLinkOkay(createTestSetting("secondary", "tertiary_link"))
61 assert Highways.isHighwayLinkOkay(createTestSetting("residential", "residential"))
62 }
63}
Note: See TracBrowser for help on using the repository browser.