1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data;
|
---|
3 |
|
---|
4 | import static org.junit.Assert.assertEquals;
|
---|
5 | import static org.junit.Assert.assertFalse;
|
---|
6 | import static org.junit.Assert.assertTrue;
|
---|
7 |
|
---|
8 | import org.junit.Test;
|
---|
9 | import org.openstreetmap.josm.data.coor.LatLon;
|
---|
10 |
|
---|
11 | /**
|
---|
12 | * Unit tests for class {@link Bounds}.
|
---|
13 | */
|
---|
14 | public class BoundsTest {
|
---|
15 |
|
---|
16 | @Test
|
---|
17 | public void crossingTests() {
|
---|
18 | Bounds b1 = new Bounds(0, 170, 50, -170);
|
---|
19 | assertTrue(b1.crosses180thMeridian());
|
---|
20 | assertFalse(b1.contains(new LatLon(-10, -180)));
|
---|
21 | assertTrue(b1.contains(new LatLon(0, -180)));
|
---|
22 | assertTrue(b1.contains(new LatLon(50, -180)));
|
---|
23 | assertFalse(b1.contains(new LatLon(60, -180)));
|
---|
24 | assertFalse(b1.contains(new LatLon(-10, 180)));
|
---|
25 | assertTrue(b1.contains(new LatLon(0, 180)));
|
---|
26 | assertTrue(b1.contains(new LatLon(50, 180)));
|
---|
27 | assertFalse(b1.contains(new LatLon(60, 180)));
|
---|
28 |
|
---|
29 | Bounds b2 = new Bounds(60, 170, 90, -170);
|
---|
30 | assertFalse(b1.intersects(b2));
|
---|
31 | assertFalse(b2.intersects(b1));
|
---|
32 |
|
---|
33 | Bounds b3 = new Bounds(25, 170, 90, -170);
|
---|
34 | assertTrue(b1.intersects(b3));
|
---|
35 | assertTrue(b3.intersects(b1));
|
---|
36 | assertTrue(b2.intersects(b3));
|
---|
37 | assertTrue(b3.intersects(b2));
|
---|
38 |
|
---|
39 | b3.extend(b1);
|
---|
40 | assertEquals(b3, new Bounds(0, 170, 90, -170));
|
---|
41 | assertTrue(b1.intersects(b3));
|
---|
42 | assertTrue(b3.intersects(b1));
|
---|
43 | assertTrue(b2.intersects(b3));
|
---|
44 | assertTrue(b3.intersects(b2));
|
---|
45 |
|
---|
46 | b3.extend(LatLon.ZERO);
|
---|
47 | assertEquals(b3, new Bounds(0, 0, 90, -170));
|
---|
48 | }
|
---|
49 | }
|
---|