package com.github.davidmoten.rtree.geometry;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;

import org.junit.Test;

public class CircleTest {
    private static final double PRECISION = 0.000001;

    @Test
    public void testCoordinates() {
        Circle circle = Geometries.circle(1, 2, 3);
        assertEquals(1, circle.x(), PRECISION);
        assertEquals(2, circle.y(), PRECISION);
    }

    @Test
    public void testDistance() {
        Circle circle = Geometries.circle(0, 0, 1);
        Rectangle r = Geometries.rectangle(1, 1, 2, 2);
        assertEquals(Math.sqrt(2) - 1, circle.distance(r), PRECISION);
    }

    @Test
    public void testMbr() {
        Circle circle = Geometries.circle(1, 2, 3);
        Rectangle r = Geometries.rectangle(-2, -1, 4, 5);
        assertEquals(r, circle.mbr());
    }

    @Test
    public void testEquality() {
        Circle circle1 = Geometries.circle(1, 2, 3);
        Circle circle2 = Geometries.circle(1, 2, 3);
        assertEquals(circle1, circle2);
    }

    @Test
    public void testInequalityRadius() {
        Circle circle1 = Geometries.circle(1, 2, 3);
        Circle circle2 = Geometries.circle(1, 2, 4);
        assertNotEquals(circle1, circle2);
    }

    @Test
    public void testInequalityX() {
        Circle circle1 = Geometries.circle(1, 2, 3);
        Circle circle2 = Geometries.circle(2, 2, 3);
        assertNotEquals(circle1, circle2);
    }

    @Test
    public void testInequalityY() {
        Circle circle1 = Geometries.circle(1, 2, 3);
        Circle circle2 = Geometries.circle(1, 3, 3);
        assertNotEquals(circle1, circle2);
    }

    @Test
    public void testInequalityWithNull() {
        Circle circle = Geometries.circle(1, 2, 3);
        assertFalse(circle.equals(null));
    }

    @Test
    public void testHashCode() {
        Circle circle = Geometries.circle(1, 2, 3);
        assertEquals(1606448223, circle.hashCode());
    }

}

@@ -40,16 +40,86 @@
 metry;%0A%0A
+import static com.github.davidmoten.rtree.geometry.Geometries.circle;%0A
 import s
@@ -246,16 +246,59 @@
 tEquals;
+%0Aimport static org.junit.Assert.assertTrue;
 %0A%0Aimport
@@ -462,35 +462,24 @@
 le circle = 
-Geometries.
 circle(1, 2,
@@ -649,35 +649,24 @@
 le circle = 
-Geometries.
 circle(0, 0,
@@ -862,35 +862,24 @@
 le circle = 
-Geometries.
 circle(1, 2,
@@ -1051,35 +1051,24 @@
 e circle1 = 
-Geometries.
 circle(1, 2,
@@ -1093,35 +1093,24 @@
 e circle2 = 
-Geometries.
 circle(1, 2,
@@ -1233,35 +1233,24 @@
 e circle1 = 
-Geometries.
 circle(1, 2,
@@ -1275,35 +1275,24 @@
 e circle2 = 
-Geometries.
 circle(1, 2,
@@ -1413,35 +1413,24 @@
 e circle1 = 
-Geometries.
 circle(1, 2,
@@ -1455,35 +1455,24 @@
 e circle2 = 
-Geometries.
 circle(2, 2,
@@ -1597,27 +1597,16 @@
 rcle1 = 
-Geometries.
 circle(1
@@ -1639,27 +1639,16 @@
 rcle2 = 
-Geometries.
 circle(1
@@ -1779,35 +1779,24 @@
 le circle = 
-Geometries.
 circle(1, 2,
@@ -1916,27 +1916,16 @@
 ircle = 
-Geometries.
 circle(1
@@ -1993,10 +1993,515 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void testIntersects() %7B%0A        Circle circle = circle(0, 0, 1);%0A        assertTrue(circle.intersects(Geometries.rectangle(0, 1, 0, 1)));%0A    %7D%0A%0A    @Test%0A    public void testIntersects2() %7B%0A        Circle circle = circle(0, 0, 1);%0A        assertFalse(circle.intersects(Geometries.rectangle(0, 1.1, 0, 1.1)));%0A    %7D%0A%0A    @Test%0A    public void testIntersects3() %7B%0A        Circle circle = circle(0, 0, 1);%0A        assertFalse(circle.intersects(Geometries.rectangle(1, 1, 1, 1)));%0A    %7D%0A
 %7D%0A

add tests