1 | package org.openstreetmap.josm.data.osm
|
---|
2 |
|
---|
3 | class SimplePrimitiveIdTest extends GroovyTestCase {
|
---|
4 |
|
---|
5 | void testNode() {
|
---|
6 | assert SimplePrimitiveId.fromString("node/123") == new SimplePrimitiveId(123, OsmPrimitiveType.NODE)
|
---|
7 | assert SimplePrimitiveId.fromString("n123") == new SimplePrimitiveId(123, OsmPrimitiveType.NODE)
|
---|
8 | assert SimplePrimitiveId.fromString("node123") == new SimplePrimitiveId(123, OsmPrimitiveType.NODE)
|
---|
9 | assert SimplePrimitiveId.fromString("n123456789123456789") == new SimplePrimitiveId(123456789123456789, OsmPrimitiveType.NODE)
|
---|
10 | }
|
---|
11 |
|
---|
12 | void testWay() {
|
---|
13 | assert SimplePrimitiveId.fromString("way/123") == new SimplePrimitiveId(123, OsmPrimitiveType.WAY)
|
---|
14 | assert SimplePrimitiveId.fromString("w123") == new SimplePrimitiveId(123, OsmPrimitiveType.WAY)
|
---|
15 | assert SimplePrimitiveId.fromString("way123") == new SimplePrimitiveId(123, OsmPrimitiveType.WAY)
|
---|
16 | assert SimplePrimitiveId.fromString("w123456789123456789") == new SimplePrimitiveId(123456789123456789, OsmPrimitiveType.WAY)
|
---|
17 | }
|
---|
18 |
|
---|
19 | void testRelation() {
|
---|
20 | assert SimplePrimitiveId.fromString("relation/123") == new SimplePrimitiveId(123, OsmPrimitiveType.RELATION)
|
---|
21 | assert SimplePrimitiveId.fromString("r123") == new SimplePrimitiveId(123, OsmPrimitiveType.RELATION)
|
---|
22 | assert SimplePrimitiveId.fromString("rel123") == new SimplePrimitiveId(123, OsmPrimitiveType.RELATION)
|
---|
23 | assert SimplePrimitiveId.fromString("relation123") == new SimplePrimitiveId(123, OsmPrimitiveType.RELATION)
|
---|
24 | }
|
---|
25 |
|
---|
26 | void testFuzzy() {
|
---|
27 | assert SimplePrimitiveId.fuzzyParse("foo relation/123 bar").toString() == "[relation 123]"
|
---|
28 | assert SimplePrimitiveId.fuzzyParse("foo relation/123 and way/345 but also node/789").toString() == "[relation 123, way 345, node 789]"
|
---|
29 | }
|
---|
30 | }
|
---|