File: PointTest.java

package info (click to toggle)
opencv 3.2.0%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 238,480 kB
  • sloc: xml: 901,650; cpp: 703,419; lisp: 20,142; java: 17,843; python: 17,641; ansic: 603; cs: 601; sh: 516; perl: 494; makefile: 117
file content (93 lines) | stat: -rw-r--r-- 2,041 bytes parent folder | download | duplicates (8)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package org.opencv.test.core;

import org.opencv.core.Point;
import org.opencv.core.Rect;
import org.opencv.test.OpenCVTestCase;

public class PointTest extends OpenCVTestCase {

    private Point p1;
    private Point p2;

    @Override
    protected void setUp() throws Exception {
        super.setUp();

        p1 = new Point(2, 2);
        p2 = new Point(1, 1);
    }

    public void testClone() {
        Point truth = new Point(1, 1);
        Point dstPoint = truth.clone();
        assertEquals(truth, dstPoint);
    }

    public void testDot() {
        double result = p1.dot(p2);
        assertEquals(4.0, result);
    }

    public void testEqualsObject() {
        boolean flag = p1.equals(p1);
        assertTrue(flag);

        flag = p1.equals(p2);
        assertFalse(flag);
    }

    public void testHashCode() {
        assertEquals(p1.hashCode(), p1.hashCode());
    }

    public void testInside() {
        Rect rect = new Rect(0, 0, 5, 3);
        assertTrue(p1.inside(rect));

        Point p2 = new Point(3, 3);
        assertFalse(p2.inside(rect));
    }

    public void testPoint() {
        Point p = new Point();

        assertNotNull(p);
        assertEquals(0.0, p.x);
        assertEquals(0.0, p.y);
    }

    public void testPointDoubleArray() {
        double[] vals = { 2, 4 };
        Point p = new Point(vals);

        assertEquals(2.0, p.x);
        assertEquals(4.0, p.y);
    }

    public void testPointDoubleDouble() {
        p1 = new Point(7, 5);

        assertNotNull(p1);
        assertEquals(7.0, p1.x);
        assertEquals(5.0, p1.y);
    }

    public void testSet() {
        double[] vals1 = {};
        p1.set(vals1);
        assertEquals(0.0, p1.x);
        assertEquals(0.0, p1.y);

        double[] vals2 = { 6, 10 };
        p2.set(vals2);
        assertEquals(6.0, p2.x);
        assertEquals(10.0, p2.y);
    }

    public void testToString() {
        String actual = p1.toString();
        String expected = "{2.0, 2.0}";
        assertEquals(expected, actual);
    }

}