Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / fluid / modules / gapi / test / own / gapi_types_tests.cpp
1 // This file is part of OpenCV project.
2 // It is subject to the license terms in the LICENSE file found in the top-level directory
3 // of this distribution and at http://opencv.org/license.html.
4 //
5 // Copyright (C) 2018-2019 Intel Corporation
6
7
8 #include "test_precomp.hpp"
9 #include "opencv2/gapi/own/types.hpp"
10
11 namespace opencv_test
12 {
13
14 TEST(Point, CreateEmpty)
15 {
16     cv::gapi::own::Point p;
17
18     EXPECT_EQ(0, p.x);
19     EXPECT_EQ(0, p.y);
20 }
21
22 TEST(Point, CreateWithParams)
23 {
24     cv::gapi::own::Point p = {1, 2};
25
26     EXPECT_EQ(1, p.x);
27     EXPECT_EQ(2, p.y);
28 }
29
30 TEST(Rect, CreateEmpty)
31 {
32     cv::gapi::own::Rect r;
33
34     EXPECT_EQ(0, r.x);
35     EXPECT_EQ(0, r.y);
36     EXPECT_EQ(0, r.width);
37     EXPECT_EQ(0, r.height);
38 }
39
40 TEST(Rect, CreateWithParams)
41 {
42     cv::gapi::own::Rect r(1, 2, 3, 4);
43
44     EXPECT_EQ(1, r.x);
45     EXPECT_EQ(2, r.y);
46     EXPECT_EQ(3, r.width);
47     EXPECT_EQ(4, r.height);
48 }
49
50 TEST(Rect, CompareEqual)
51 {
52     cv::gapi::own::Rect r1(1, 2, 3, 4);
53
54     cv::gapi::own::Rect r2(1, 2, 3, 4);
55
56     EXPECT_TRUE(r1 == r2);
57 }
58
59 TEST(Rect, CompareDefaultEqual)
60 {
61     cv::gapi::own::Rect r1;
62
63     cv::gapi::own::Rect r2;
64
65     EXPECT_TRUE(r1 == r2);
66 }
67
68 TEST(Rect, CompareNotEqual)
69 {
70     cv::gapi::own::Rect r1(1, 2, 3, 4);
71
72     cv::gapi::own::Rect r2;
73
74     EXPECT_TRUE(r1 != r2);
75 }
76
77 TEST(Rect, Intersection)
78 {
79     cv::gapi::own::Rect r1(2, 2, 3, 3);
80     cv::gapi::own::Rect r2(3, 1, 3, 3);
81
82     cv::gapi::own::Rect intersect = r1 & r2;
83
84     EXPECT_EQ(3, intersect.x);
85     EXPECT_EQ(2, intersect.y);
86     EXPECT_EQ(2, intersect.width);
87     EXPECT_EQ(2, intersect.height);
88 }
89
90 TEST(Rect, AssignIntersection)
91 {
92     cv::gapi::own::Rect r1(2, 2, 3, 3);
93     cv::gapi::own::Rect r2(3, 1, 3, 3);
94
95     r1 &= r2;
96
97     EXPECT_EQ(3, r1.x);
98     EXPECT_EQ(2, r1.y);
99     EXPECT_EQ(2, r1.width);
100     EXPECT_EQ(2, r1.height);
101 }
102
103 TEST(Size, CreateEmpty)
104 {
105     cv::gapi::own::Size s;
106
107     EXPECT_EQ(0, s.width);
108     EXPECT_EQ(0, s.height);
109 }
110
111 TEST(Size, CreateWithParams)
112 {
113     cv::gapi::own::Size s(640, 480);
114
115     EXPECT_EQ(640, s.width);
116     EXPECT_EQ(480, s.height);
117 }
118
119 TEST(Size, AdditionAssignment)
120 {
121     cv::gapi::own::Size s1(1, 2);
122     cv::gapi::own::Size s2(2, 3);
123
124     s1 += s2;
125
126     EXPECT_EQ(3, s1.width);
127     EXPECT_EQ(5, s1.height);
128 }
129
130 TEST(Size, CompareEqual)
131 {
132     cv::gapi::own::Size s1(1, 2);
133
134     cv::gapi::own::Size s2(1, 2);
135
136     EXPECT_TRUE(s1 == s2);
137     EXPECT_FALSE(s1 != s2);
138 }
139
140 TEST(Size, CompareDefaultEqual)
141 {
142     cv::gapi::own::Size s1;
143     cv::gapi::own::Size s2;
144
145     EXPECT_TRUE(s1 == s2);
146     EXPECT_FALSE(s1 != s2);
147 }
148
149 TEST(Size, CompareNotEqual)
150 {
151     cv::gapi::own::Size s1(1, 2);
152
153     cv::gapi::own::Size s2(3, 4);
154
155     EXPECT_FALSE(s1 == s2);
156     EXPECT_TRUE(s1 != s2);
157 }
158
159 } // opencv_test