Home | History | Annotate | Download | only in test
      1 package org.opencv.test.core;
      2 
      3 import org.opencv.core.Point;
      4 import org.opencv.core.Rect;
      5 import org.opencv.test.OpenCVTestCase;
      6 
      7 public class PointTest extends OpenCVTestCase {
      8 
      9     private Point p1;
     10     private Point p2;
     11 
     12     @Override
     13     protected void setUp() throws Exception {
     14         super.setUp();
     15 
     16         p1 = new Point(2, 2);
     17         p2 = new Point(1, 1);
     18     }
     19 
     20     public void testClone() {
     21         Point truth = new Point(1, 1);
     22         Point dstPoint = truth.clone();
     23         assertEquals(truth, dstPoint);
     24     }
     25 
     26     public void testDot() {
     27         double result = p1.dot(p2);
     28         assertEquals(4.0, result);
     29     }
     30 
     31     public void testEqualsObject() {
     32         boolean flag = p1.equals(p1);
     33         assertTrue(flag);
     34 
     35         flag = p1.equals(p2);
     36         assertFalse(flag);
     37     }
     38 
     39     public void testHashCode() {
     40         assertEquals(p1.hashCode(), p1.hashCode());
     41     }
     42 
     43     public void testInside() {
     44         Rect rect = new Rect(0, 0, 5, 3);
     45         assertTrue(p1.inside(rect));
     46 
     47         Point p2 = new Point(3, 3);
     48         assertFalse(p2.inside(rect));
     49     }
     50 
     51     public void testPoint() {
     52         Point p = new Point();
     53 
     54         assertNotNull(p);
     55         assertEquals(0.0, p.x);
     56         assertEquals(0.0, p.y);
     57     }
     58 
     59     public void testPointDoubleArray() {
     60         double[] vals = { 2, 4 };
     61         Point p = new Point(vals);
     62 
     63         assertEquals(2.0, p.x);
     64         assertEquals(4.0, p.y);
     65     }
     66 
     67     public void testPointDoubleDouble() {
     68         p1 = new Point(7, 5);
     69 
     70         assertNotNull(p1);
     71         assertEquals(7.0, p1.x);
     72         assertEquals(5.0, p1.y);
     73     }
     74 
     75     public void testSet() {
     76         double[] vals1 = {};
     77         p1.set(vals1);
     78         assertEquals(0.0, p1.x);
     79         assertEquals(0.0, p1.y);
     80 
     81         double[] vals2 = { 6, 10 };
     82         p2.set(vals2);
     83         assertEquals(6.0, p2.x);
     84         assertEquals(10.0, p2.y);
     85     }
     86 
     87     public void testToString() {
     88         String actual = p1.toString();
     89         String expected = "{2.0, 2.0}";
     90         assertEquals(expected, actual);
     91     }
     92 
     93 }
     94