summaryrefslogtreecommitdiff
path: root/android/java/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateBoundsTest.java
blob: a5d3891305b15e4a3864b406d4475aa80532eb7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import com.mapbox.mapboxsdk.geometry.CoordinateBounds;
import com.mapbox.mapboxsdk.geometry.LatLng;

import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

public class CoordinateBoundsTest {

    @Test
    public void testSanity() {
        CoordinateBounds coordinateBounds = new CoordinateBounds(null, null);
        assertNotNull("coordinateBounds should not be null", coordinateBounds);
    }

    @Test
    public void testSouthWestConstructor() {
        LatLng southWest = new LatLng(12, 12);
        CoordinateBounds coordinateBounds = new CoordinateBounds(southWest, null);
        assertEquals("southWest should match", southWest, coordinateBounds.getSouthWest());
    }

    @Test
    public void testNorthEastConstructor() {
        LatLng northEast = new LatLng(12, 12);
        CoordinateBounds coordinateBounds = new CoordinateBounds(null, northEast);
        assertEquals("northEast should match", northEast, coordinateBounds.getNorthEast());
    }

    @Test
    public void testHashCode() {
        LatLng northEast = new LatLng(60, 60);
        LatLng southWest = new LatLng(43, 26);
        CoordinateBounds coordinateBounds = new CoordinateBounds(northEast, southWest);
        assertEquals("hash code should match", coordinateBounds.hashCode(), -1515487232);
    }

    @Test
    public void testToString() {
        LatLng northEast = new LatLng(60, 60);
        LatLng southWest = new LatLng(43, 26);
        CoordinateBounds coordinateBounds = new CoordinateBounds(northEast, southWest);
        assertEquals("string should match",
                coordinateBounds.toString(),
                "CoordinateBounds [northEast[" + coordinateBounds.getNorthEast() + "], southWest[]" + coordinateBounds.getSouthWest() + "]");
    }

    @Test
    public void testEquals() {
        LatLng northEast = new LatLng(60, 60);
        LatLng southWest = new LatLng(43, 26);
        CoordinateBounds firstBounds = new CoordinateBounds(northEast, southWest);
        CoordinateBounds sameBounds = new CoordinateBounds(northEast, southWest);
        assertTrue(firstBounds.equals(sameBounds));
    }
}