package com.github.davidmoten.rtree.geometry;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import com.github.davidmoten.util.TestingUtil;

public class GeometriesTest {

    private static final double PRECISION = 0.000001;

    @Test
    public void testPrivateConstructorForCoverageOnly() {
        TestingUtil.callConstructorAndCheckIsPrivate(Geometries.class);
    }

    @Test
    public void testNormalizeLongitude() {
        assertEquals(0, Geometries.normalizeLongitude(0), PRECISION);
    }

    @Test
    public void testNormalizeLongitude2() {
        assertEquals(89, Geometries.normalizeLongitude(89), PRECISION);
    }

    @Test
    public void testNormalizeLongitude3() {
        assertEquals(179, Geometries.normalizeLongitude(179), PRECISION);
    }

    @Test
    public void testNormalizeLongitude4() {
        assertEquals(-179, Geometries.normalizeLongitude(181), PRECISION);
    }

    @Test
    public void testNormalizeLongitude5() {
        assertEquals(-179, Geometries.normalizeLongitude(541), PRECISION);
    }

    @Test
    public void testNormalizeLongitude2Neg() {
        assertEquals(-89, Geometries.normalizeLongitude(-89), PRECISION);
    }

    @Test
    public void testNormalizeLongitude3Neg() {
        assertEquals(-179, Geometries.normalizeLongitude(-179), PRECISION);
    }

    @Test
    public void testNormalizeLongitude4Neg() {
        assertEquals(179, Geometries.normalizeLongitude(-181), PRECISION);
    }

    @Test
    public void testNormalizeLongitude5Neg() {
        assertEquals(179, Geometries.normalizeLongitude(-541), PRECISION);
    }

    @Test
    public void testRectangleLatLong() {
        Rectangle r = Geometries.rectangleLatLong(10, -10, 5, 10);
        assertEquals(10, r.x1(), PRECISION);
        assertEquals(365, r.x2(), PRECISION);
    }

    @Test
    public void testRectangleLatLong2() {
        Rectangle r = Geometries.rectangleLatLong(5, -10, 10, 10);
        assertEquals(5, r.x1(), PRECISION);
        assertEquals(10, r.x2(), PRECISION);
    }
}

@@ -781,32 +781,170 @@
 CISION);%0A    %7D%0A%0A
+    @Test%0A    public void testNormalizeLongitude3_1() %7B%0A        assertEquals(-180, Geometries.normalizeLongitude(180), PRECISION);%0A    %7D%0A%0A
     @Test%0A    pu
@@ -2184,11 +2184,219 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void testPointLatLong() %7B%0A        Point point = Geometries.pointLatLong(181, 25);%0A        assertEquals(-179, point.x(), PRECISION);%0A        assertEquals(25, point.y(), PRECISION);%0A    %7D
 %0A%7D%0A

add unit test of Geometries.pointLatLon()