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.Point3;
      5 import org.opencv.test.OpenCVTestCase;
      6 
      7 public class Point3Test extends OpenCVTestCase {
      8 
      9     private Point3 p1;
     10     private Point3 p2;
     11 
     12     @Override
     13     protected void setUp() throws Exception {
     14         super.setUp();
     15 
     16         p1 = new Point3(2, 2, 2);
     17         p2 = new Point3(1, 1, 1);
     18     }
     19 
     20     public void testClone() {
     21         Point3 truth = new Point3(1, 1, 1);
     22         p1 = truth.clone();
     23         assertEquals(truth, p1);
     24     }
     25 
     26     public void testCross() {
     27         Point3 dstPoint = p1.cross(p2);
     28         Point3 truth = new Point3(0, 0, 0);
     29         assertEquals(truth, dstPoint);
     30     }
     31 
     32     public void testDot() {
     33         double result = p1.dot(p2);
     34         assertEquals(6.0, result);
     35     }
     36 
     37     public void testEqualsObject() {
     38         boolean flag = p1.equals(p1);
     39         assertTrue(flag);
     40 
     41         flag = p1.equals(p2);
     42         assertFalse(flag);
     43     }
     44 
     45     public void testHashCode() {
     46         assertEquals(p1.hashCode(), p1.hashCode());
     47     }
     48 
     49     public void testPoint3() {
     50         p1 = new Point3();
     51 
     52         assertNotNull(p1);
     53         assertTrue(0 == p1.x);
     54         assertTrue(0 == p1.y);
     55         assertTrue(0 == p1.z);
     56     }
     57 
     58     public void testPoint3DoubleArray() {
     59         double[] vals = { 1, 2, 3 };
     60         p1 = new Point3(vals);
     61 
     62         assertTrue(1 == p1.x);
     63         assertTrue(2 == p1.y);
     64         assertTrue(3 == p1.z);
     65     }
     66 
     67     public void testPoint3DoubleDoubleDouble() {
     68         p1 = new Point3(1, 2, 3);
     69 
     70         assertEquals(1., p1.x);
     71         assertEquals(2., p1.y);
     72         assertEquals(3., p1.z);
     73     }
     74 
     75     public void testPoint3Point() {
     76         Point p = new Point(2, 3);
     77         p1 = new Point3(p);
     78 
     79         assertEquals(2., p1.x);
     80         assertEquals(3., p1.y);
     81         assertEquals(0., p1.z);
     82     }
     83 
     84     public void testSet() {
     85         double[] vals1 = {};
     86         p1.set(vals1);
     87 
     88         assertEquals(0., p1.x);
     89         assertEquals(0., p1.y);
     90         assertEquals(0., p1.z);
     91 
     92         double[] vals2 = { 3, 6, 10 };
     93         p1.set(vals2);
     94 
     95         assertEquals(3., p1.x);
     96         assertEquals(6., p1.y);
     97         assertEquals(10., p1.z);
     98     }
     99 
    100     public void testToString() {
    101         String actual = p1.toString();
    102         String expected = "{2.0, 2.0, 2.0}";
    103         assertEquals(expected, actual);
    104     }
    105 
    106 
    107 }
    108