1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.tools;
|
---|
3 |
|
---|
4 | import static org.hamcrest.CoreMatchers.nullValue;
|
---|
5 | import static org.hamcrest.core.Is.is;
|
---|
6 | import static org.junit.Assert.assertThat;
|
---|
7 |
|
---|
8 | import org.junit.Test;
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * Unit tests of {@link GeoUrlToBoundsTest} class.
|
---|
12 | */
|
---|
13 | public class GeoUrlToBoundsTest {
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * Tests parsing Geo URLs with the zoom specified.
|
---|
17 | */
|
---|
18 | @Test
|
---|
19 | public void testParse() {
|
---|
20 | assertThat(
|
---|
21 | GeoUrlToBounds.parse("geo:12.34,56.78?z=9"),
|
---|
22 | is(OsmUrlToBounds.positionToBounds(12.34, 56.78, 9))
|
---|
23 | );
|
---|
24 | }
|
---|
25 |
|
---|
26 | /**
|
---|
27 | * Tests parsing Geo URLs without the zoom parameter.
|
---|
28 | */
|
---|
29 | @Test
|
---|
30 | public void testParseWithoutZoom() {
|
---|
31 | assertThat(
|
---|
32 | GeoUrlToBounds.parse("geo:12.34,56.78"),
|
---|
33 | is(OsmUrlToBounds.positionToBounds(12.34, 56.78, 18))
|
---|
34 | );
|
---|
35 | assertThat(
|
---|
36 | GeoUrlToBounds.parse("geo:-37.786971,-122.399677"),
|
---|
37 | is(OsmUrlToBounds.positionToBounds(-37.786971, -122.399677, 18))
|
---|
38 | );
|
---|
39 | }
|
---|
40 |
|
---|
41 | /**
|
---|
42 | * Tests parsing invalid Geo URL.
|
---|
43 | */
|
---|
44 | @Test
|
---|
45 | public void testInvalid() {
|
---|
46 | assertThat(GeoUrlToBounds.parse("geo:foo"), nullValue());
|
---|
47 | assertThat(GeoUrlToBounds.parse("geo:foo,bar"), nullValue());
|
---|
48 | }
|
---|
49 |
|
---|
50 | /**
|
---|
51 | * Tests parsing null.
|
---|
52 | */
|
---|
53 | @Test(expected = IllegalArgumentException.class)
|
---|
54 | public void testNull() {
|
---|
55 | GeoUrlToBounds.parse(null);
|
---|
56 | }
|
---|
57 | }
|
---|