1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, Hardware
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "gtest/gtest.h"
17
18 #include "utils/point3.h"
19 #include "utils/scalar.h"
20
21 using namespace testing;
22 using namespace testing::ext;
23
24 namespace OHOS {
25 namespace Rosen {
26 namespace Drawing {
27 class Point3Test : public testing::Test {
28 public:
29 static void SetUpTestCase();
30 static void TearDownTestCase();
31 void SetUp() override;
32 void TearDown() override;
33 };
34
SetUpTestCase()35 void Point3Test::SetUpTestCase() {}
TearDownTestCase()36 void Point3Test::TearDownTestCase() {}
SetUp()37 void Point3Test::SetUp() {}
TearDown()38 void Point3Test::TearDown() {}
39
40 /**
41 * @tc.name: Point3CreateAndDestroy001
42 * @tc.desc: Point3 Point3 Function SetandGet XYZ Test
43 * @tc.type: FUNC
44 * @tc.require:AR000GGNV3
45 * @tc.author:
46 */
47 HWTEST_F(Point3Test, Point3CreateAndDestroy001, TestSize.Level1)
48 {
49 std::unique_ptr<Point3> point3 = std::make_unique<Point3>();
50 EXPECT_EQ(0.0f, point3->GetX());
51 EXPECT_EQ(0.0f, point3->GetY());
52 EXPECT_EQ(0.0f, point3->GetZ());
53 }
54
55 /**
56 * @tc.name: Point3CreateAndDestroy002
57 * @tc.desc: Point3 Point3 Function Test
58 * @tc.type: FUNC
59 * @tc.require:AR000GGNV3
60 * @tc.author:
61 */
62 HWTEST_F(Point3Test, Point3CreateAndDestroy002, TestSize.Level1)
63 {
64 Point3 point1;
65 point1.SetX(2.0f);
66 Point3 point2(point1);
67 EXPECT_TRUE(point1 == point2);
68 }
69
70 /**
71 * @tc.name: Point3CreateAndDestroy003
72 * @tc.desc: Point3 Point3 Function Test
73 * @tc.type: FUNC
74 * @tc.require:AR000GGNV3
75 * @tc.author:
76 */
77 HWTEST_F(Point3Test, Point3CreateAndDestroy003, TestSize.Level1)
78 {
79 Point3 point1;
80 point1.SetX(3.0f);
81 Point3 point2(point1);
82 EXPECT_TRUE(point1 == point2);
83 }
84
85 /**
86 * @tc.name: Point3CreateAndDestroy004
87 * @tc.desc: Point3 Point3 Function Test
88 * @tc.type: FUNC
89 * @tc.require:AR000GGNV3
90 * @tc.author:
91 */
92 HWTEST_F(Point3Test, Point3CreateAndDestroy004, TestSize.Level1)
93 {
94 std::unique_ptr<Point3> point3 = std::make_unique<Point3>(1.0f, 2.0f, 3.0f);
95 EXPECT_EQ(1.0f, point3->GetX());
96 EXPECT_EQ(2.0f, point3->GetY());
97 EXPECT_EQ(3.0f, point3->GetZ());
98 }
99
100 /**
101 * @tc.name: Point3CreateAndDestroy005
102 * @tc.desc: Point3 Point3 Function Test
103 * @tc.type: FUNC
104 * @tc.require:AR000GGNV3
105 * @tc.author:
106 */
107 HWTEST_F(Point3Test, Point3CreateAndDestroy005, TestSize.Level1)
108 {
109 std::unique_ptr<Point3> point3 = std::make_unique<Point3>(4.0f, 5.0f, 6.0f);
110 EXPECT_EQ(4.0f, point3->GetX());
111 EXPECT_EQ(5.0f, point3->GetY());
112 EXPECT_EQ(6.0f, point3->GetZ());
113 }
114
115 /**
116 * @tc.name: Point3SetAndGetXTest001
117 * @tc.desc: Point3 Point3 Function Test
118 * @tc.type: FUNC
119 * @tc.require:AR000GGNV3
120 * @tc.author:
121 */
122 HWTEST_F(Point3Test, Point3SetAndGetXTest001, TestSize.Level1)
123 {
124 std::unique_ptr<Point3> point3 = std::make_unique<Point3>();
125 point3->SetX(1.0f);
126 EXPECT_EQ(1.0f, point3->GetX());
127 }
128
129 /**
130 * @tc.name: Point3SetAndGetXTest002
131 * @tc.desc: Point3 Point3 Function Test
132 * @tc.type: FUNC
133 * @tc.require:AR000GGNV3
134 * @tc.author:
135 */
136 HWTEST_F(Point3Test, Point3SetAndGetXTest002, TestSize.Level1)
137 {
138 std::unique_ptr<Point3> point3 = std::make_unique<Point3>();
139 point3->SetX(2.0f);
140 EXPECT_EQ(2.0f, point3->GetX());
141 }
142
143 /**
144 * @tc.name: Point3SetAndGetYTest001
145 * @tc.desc: Point3 Point3 Function Test
146 * @tc.type: FUNC
147 * @tc.require:AR000GGNV3
148 * @tc.author:
149 */
150 HWTEST_F(Point3Test, Point3SetAndGetYTest001, TestSize.Level1)
151 {
152 std::unique_ptr<Point3> point3 = std::make_unique<Point3>();
153 point3->SetY(1.0f);
154 EXPECT_EQ(1.0f, point3->GetY());
155 }
156
157 /**
158 * @tc.name: Point3SetAndGetYTest002
159 * @tc.desc: Point3 Point3 Function Test
160 * @tc.type: FUNC
161 * @tc.require:AR000GGNV3
162 * @tc.author:
163 */
164 HWTEST_F(Point3Test, Point3SetAndGetYTest002, TestSize.Level1)
165 {
166 std::unique_ptr<Point3> point3 = std::make_unique<Point3>();
167 point3->SetY(2.0f);
168 EXPECT_EQ(2.0f, point3->GetY());
169 }
170
171 /**
172 * @tc.name: Point3SetAndGetZTest001
173 * @tc.desc: Point3 Point3 Function Test
174 * @tc.type: FUNC
175 * @tc.require:AR000GGNV3
176 * @tc.author:
177 */
178 HWTEST_F(Point3Test, Point3SetAndGetZTest001, TestSize.Level1)
179 {
180 std::unique_ptr<Point3> point3 = std::make_unique<Point3>();
181 point3->SetZ(1.0f);
182 EXPECT_EQ(1.0f, point3->GetZ());
183 }
184
185 /**
186 * @tc.name: Point3SetAndGetZTest002
187 * @tc.desc: Point3 Point3 Function Test
188 * @tc.type: FUNC
189 * @tc.require:AR000GGNV3
190 * @tc.author:
191 */
192 HWTEST_F(Point3Test, Point3SetAndGetZTest002, TestSize.Level1)
193 {
194 std::unique_ptr<Point3> point3 = std::make_unique<Point3>();
195 point3->SetZ(2.0f);
196 EXPECT_EQ(2.0f, point3->GetZ());
197 }
198
199 /**
200 * @tc.name: Point3AddEqualTest001
201 * @tc.desc: Point3 Point3 Function Test
202 * @tc.type: FUNC
203 * @tc.require:AR000GGNV3
204 * @tc.author:
205 */
206 HWTEST_F(Point3Test, Point3AddEqualTest001, TestSize.Level1)
207 {
208 Point3 point1;
209 Point3 point2(1.0f, 2.0f, 3.0f);
210 point1 += point2;
211 EXPECT_EQ(1.0f, point1.GetX());
212 EXPECT_EQ(2.0f, point1.GetY());
213 EXPECT_EQ(3.0f, point1.GetZ());
214 }
215
216 /**
217 * @tc.name: Point3AddEqualTest002
218 * @tc.desc: Point3 Point3 Function Test
219 * @tc.type: FUNC
220 * @tc.require:AR000GGNV3
221 * @tc.author:
222 */
223 HWTEST_F(Point3Test, Point3AddEqualTest002, TestSize.Level1)
224 {
225 Point3 point1;
226 Point3 point2(3.0f, 2.0f, 1.0f);
227 point1 += point2;
228 EXPECT_EQ(3.0f, point1.GetX());
229 EXPECT_EQ(2.0f, point1.GetY());
230 EXPECT_EQ(1.0f, point1.GetZ());
231 }
232
233 /**
234 * @tc.name: Point3MinusEqualTest001
235 * @tc.desc: Point3 Point3 Function Test
236 * @tc.type: FUNC
237 * @tc.require:AR000GGNV3
238 * @tc.author:
239 */
240 HWTEST_F(Point3Test, Point3MinusEqualTest001, TestSize.Level1)
241 {
242 Point3 point1;
243 Point3 point2(1.0f, 2.0f, 3.0f);
244 point1 -= point2;
245 EXPECT_EQ(-1.0f, point1.GetX());
246 EXPECT_EQ(-2.0f, point1.GetY());
247 EXPECT_EQ(-3.0f, point1.GetZ());
248 }
249
250 /**
251 * @tc.name: Point3MinusEqualTest002
252 * @tc.desc: Point3 Point3 Function Test
253 * @tc.type: FUNC
254 * @tc.require:AR000GGNV3
255 * @tc.author:
256 */
257 HWTEST_F(Point3Test, Point3MinusEqualTest002, TestSize.Level1)
258 {
259 Point3 point1;
260 Point3 point2(3.0f, 2.0f, 1.0f);
261 point1 -= point2;
262 EXPECT_EQ(-3.0f, point1.GetX());
263 EXPECT_EQ(-2.0f, point1.GetY());
264 EXPECT_EQ(-1.0f, point1.GetZ());
265 }
266
267 /**
268 * @tc.name: Point3MultiplyEqualTest001
269 * @tc.desc: Point3 Point3 Function Test
270 * @tc.type: FUNC
271 * @tc.require:AR000GGNV3
272 * @tc.author:
273 */
274 HWTEST_F(Point3Test, Point3MultiplyEqualTest001, TestSize.Level1)
275 {
276 Point3 point3(1.0f, 2.0f, 3.0f);
277 point3 *= 2;
278 EXPECT_EQ(2.0f, point3.GetX());
279 EXPECT_EQ(4.0f, point3.GetY());
280 EXPECT_EQ(6.0f, point3.GetZ());
281 }
282
283 /**
284 * @tc.name: Point3MultiplyEqualTest002
285 * @tc.desc: Point3 Point3 Function Test
286 * @tc.type: FUNC
287 * @tc.require:AR000GGNV3
288 * @tc.author:
289 */
290 HWTEST_F(Point3Test, Point3MultiplyEqualTest002, TestSize.Level1)
291 {
292 Point3 point3(3.0f, 2.0f, 1.0f);
293 point3 *= 2;
294 EXPECT_EQ(6.0f, point3.GetX());
295 EXPECT_EQ(4.0f, point3.GetY());
296 EXPECT_EQ(2.0f, point3.GetZ());
297 }
298
299 /**
300 * @tc.name: Point3DivideEqualTest001
301 * @tc.desc: Point3 Point3 Function Test
302 * @tc.type: FUNC
303 * @tc.require:AR000GGNV3
304 * @tc.author:
305 */
306 HWTEST_F(Point3Test, Point3DivideEqualTest001, TestSize.Level1)
307 {
308 Point3 point3(2.0f, 4.0f, 6.0f);
309 point3 /= 2.0f;
310 EXPECT_EQ(1.0f, point3.GetX());
311 EXPECT_EQ(2.0f, point3.GetY());
312 EXPECT_EQ(3.0f, point3.GetZ());
313 }
314
315 /**
316 * @tc.name: Point3DivideEqualTest002
317 * @tc.desc: Point3 Point3 Function Test
318 * @tc.type: FUNC
319 * @tc.require:AR000GGNV3
320 * @tc.author:
321 */
322 HWTEST_F(Point3Test, Point3DivideEqualTest002, TestSize.Level1)
323 {
324 Point3 point3(4.0f, 8.0f, 10.0f);
325 point3 /= 2.0f;
326 EXPECT_EQ(2.0f, point3.GetX());
327 EXPECT_EQ(4.0f, point3.GetY());
328 EXPECT_EQ(5.0f, point3.GetZ());
329 }
330
331 /**
332 * @tc.name: Point3AddTest001
333 * @tc.desc: Point3 Point3 Function Test
334 * @tc.type: FUNC
335 * @tc.require:AR000GGNV3
336 * @tc.author:
337 */
338 HWTEST_F(Point3Test, Point3AddTest001, TestSize.Level1)
339 {
340 Point3 point1(1.0f, 2.0f, 3.0f);
341 Point3 point2(0.0f, 0.0f, 0.0f);
342 Point3 point3 = point1 + point2;
343 EXPECT_EQ(3.0f, point3.GetX());
344 EXPECT_EQ(0.0f, point3.GetY());
345 EXPECT_EQ(3.0f, point3.GetZ());
346 }
347
348 /**
349 * @tc.name: Point3AddTest002
350 * @tc.desc: Point3 Point3 Function Test
351 * @tc.type: FUNC
352 * @tc.require:AR000GGNV3
353 * @tc.author:
354 */
355 HWTEST_F(Point3Test, Point3AddTest002, TestSize.Level1)
356 {
357 Point3 point1(3.0f, 2.0f, 1.0f);
358 Point3 point2(0.0f, 0.0f, 0.0f);
359 Point3 point3 = point1 + point2;
360 EXPECT_EQ(5.0f, point3.GetX());
361 EXPECT_EQ(0.0f, point3.GetY());
362 EXPECT_EQ(1.0f, point3.GetZ());
363 }
364
365 /**
366 * @tc.name: Point3MinusTest001
367 * @tc.desc: Point3 Point3 Function Test
368 * @tc.type: FUNC
369 * @tc.require:AR000GGNV3
370 * @tc.author:
371 */
372 HWTEST_F(Point3Test, Point3MinusTest001, TestSize.Level1)
373 {
374 Point3 point1(1.0f, 2.0f, 3.0f);
375 Point3 point2;
376 Point3 point3 = point1 - point2;
377 EXPECT_EQ(1.0f, point3.GetX());
378 EXPECT_EQ(2.0f, point3.GetY());
379 EXPECT_EQ(3.0f, point3.GetZ());
380 }
381
382 /**
383 * @tc.name: Point3MinusTest002
384 * @tc.desc: Point3 Point3 Function Test
385 * @tc.type: FUNC
386 * @tc.require:AR000GGNV3
387 * @tc.author:
388 */
389 HWTEST_F(Point3Test, Point3MinusTest002, TestSize.Level1)
390 {
391 Point3 point1(3.0f, 2.0f, 1.0f);
392 Point3 point2;
393 Point3 point3 = point1 - point2;
394 EXPECT_EQ(3.0f, point3.GetX());
395 EXPECT_EQ(2.0f, point3.GetY());
396 EXPECT_EQ(1.0f, point3.GetZ());
397 }
398
399 /**
400 * @tc.name: Point3MultiplyTest001
401 * @tc.desc: Point3 Point3 Function Test
402 * @tc.type: FUNC
403 * @tc.require:AR000GGNV3
404 * @tc.author:
405 */
406 HWTEST_F(Point3Test, Point3MultiplyTest001, TestSize.Level1)
407 {
408 Point3 point1(1.0f, 2.0f, 3.0f);
409 Point3 point2 = 2.0f * point1;
410 EXPECT_EQ(2.0f, point2.GetX());
411 EXPECT_EQ(4.0f, point2.GetY());
412 EXPECT_EQ(6.0f, point2.GetZ());
413 }
414
415 /**
416 * @tc.name: Point3MultiplyTest002
417 * @tc.desc: Point3 Point3 Function Test
418 * @tc.type: FUNC
419 * @tc.require:AR000GGNV3
420 * @tc.author:
421 */
422 HWTEST_F(Point3Test, Point3MultiplyTest002, TestSize.Level1)
423 {
424 Point3 point1(1.0f, 2.0f, 3.0f);
425 Point3 point2 = 3.0f * point1;
426 EXPECT_EQ(3.0f, point2.GetX());
427 EXPECT_EQ(6.0f, point2.GetY());
428 EXPECT_EQ(9.0f, point2.GetZ());
429 }
430
431 /**
432 * @tc.name: Point3MultiplyTest003
433 * @tc.desc: Point3 Point3 Function Test
434 * @tc.type: FUNC
435 * @tc.require:AR000GGNV3
436 * @tc.author:
437 */
438 HWTEST_F(Point3Test, Point3MultiplyTest003, TestSize.Level1)
439 {
440 Point3 point1(1.0f, 2.0f, 3.0f);
441 Point3 point2 = point1 * 2.0f;
442 EXPECT_EQ(2.0f, point2.GetX());
443 EXPECT_EQ(4.0f, point2.GetY());
444 EXPECT_EQ(6.0f, point2.GetZ());
445 }
446
447 /**
448 * @tc.name: Point3MultiplyTest004
449 * @tc.desc: Point3 Point3 Function Test
450 * @tc.type: FUNC
451 * @tc.require:AR000GGNV3
452 * @tc.author:
453 */
454 HWTEST_F(Point3Test, Point3MultiplyTest004, TestSize.Level1)
455 {
456 Point3 point1(1.0f, 2.0f, 3.0f);
457 Point3 point2 = point1 * 3.0f;
458 EXPECT_EQ(3.0f, point2.GetX());
459 EXPECT_EQ(6.0f, point2.GetY());
460 EXPECT_EQ(9.0f, point2.GetZ());
461 }
462
463 /**
464 * @tc.name: Point3DivideTest001
465 * @tc.desc: Point3 Point3 Function Test
466 * @tc.type: FUNC
467 * @tc.require:AR000GGNV3
468 * @tc.author:
469 */
470 HWTEST_F(Point3Test, Point3DivideTest001, TestSize.Level1)
471 {
472 Point3 point1(2.0f, 4.0f, 6.0f);
473 Point3 point2 = point1 / 2.0f;
474 EXPECT_EQ(1.0f, point2.GetX());
475 EXPECT_EQ(2.0f, point2.GetY());
476 EXPECT_EQ(3.0f, point2.GetZ());
477 }
478
479 /**
480 * @tc.name: Point3DivideTest002
481 * @tc.desc: Point3 Point3 Function Test
482 * @tc.type: FUNC
483 * @tc.require:AR000GGNV3
484 * @tc.author:
485 */
486 HWTEST_F(Point3Test, Point3DivideTest002, TestSize.Level1)
487 {
488 Point3 point1(3.0f, 6.0f, 9.0f);
489 Point3 point2 = point1 / 3.0f;
490 EXPECT_EQ(1.0f, point2.GetX());
491 EXPECT_EQ(2.0f, point2.GetY());
492 EXPECT_EQ(3.0f, point2.GetZ());
493 }
494
495 /**
496 * @tc.name: Point3AddTest003
497 * @tc.desc: Point3 Point3 Function Test
498 * @tc.type: FUNC
499 * @tc.require:AR000GGNV3
500 * @tc.author:
501 */
502 HWTEST_F(Point3Test, Point3AddTest003, TestSize.Level1)
503 {
504 Point3 point1(1.0f, 2.0f, 3.0f);
505 Point3 point2 = +point1;
506 EXPECT_EQ(1.0f, point2.GetX());
507 EXPECT_EQ(2.0f, point2.GetY());
508 EXPECT_EQ(3.0f, point2.GetZ());
509 }
510
511 /**
512 * @tc.name: Point3AddTest004
513 * @tc.desc: Point3 Point3 Function Test
514 * @tc.type: FUNC
515 * @tc.require:AR000GGNV3
516 * @tc.author:
517 */
518 HWTEST_F(Point3Test, Point3AddTest005, TestSize.Level1)
519 {
520 Point3 point1(3.0f, 2.0f, 1.0f);
521 Point3 point2 = +point1;
522 EXPECT_EQ(3.0f, point2.GetX());
523 EXPECT_EQ(2.0f, point2.GetY());
524 EXPECT_EQ(1.0f, point2.GetZ());
525 }
526
527 /**
528 * @tc.name: Point3MinusTest003
529 * @tc.desc: Point3 Point3 Function Test
530 * @tc.type: FUNC
531 * @tc.require:AR000GGNV3
532 * @tc.author:
533 */
534 HWTEST_F(Point3Test, Point3MinusTest003, TestSize.Level1)
535 {
536 Point3 point1(1.0f, 2.0f, 3.0f);
537 Point3 point2 = -point1;
538 EXPECT_EQ(-1.0f, point2.GetX());
539 EXPECT_EQ(-2.0f, point2.GetY());
540 EXPECT_EQ(-3.0f, point2.GetZ());
541 }
542
543 /**
544 * @tc.name: Point3MinusTest004
545 * @tc.desc: Point3 Point3 Function Test
546 * @tc.type: FUNC
547 * @tc.require:AR000GGNV3
548 * @tc.author:
549 */
550 HWTEST_F(Point3Test, Point3MinusTest004, TestSize.Level1)
551 {
552 Point3 point1(3.0f, 2.0f, 1.0f);
553 Point3 point2 = -point1;
554 EXPECT_EQ(-3.0f, point2.GetX());
555 EXPECT_EQ(-2.0f, point2.GetY());
556 EXPECT_EQ(-1.0f, point2.GetZ());
557 }
558
559 /**
560 * @tc.name: Point3EqualTest001
561 * @tc.desc: Point3 Point3 Function Test
562 * @tc.type: FUNC
563 * @tc.require:AR000GGNV3
564 * @tc.author:
565 */
566 HWTEST_F(Point3Test, Point3EqualTest001, TestSize.Level1)
567 {
568 Point3 point1;
569 Point3 point2;
570 EXPECT_TRUE(point1 == point2);
571 }
572
573 /**
574 * @tc.name: Point3EqualTest002
575 * @tc.desc: Point3 Point3 Function Test
576 * @tc.type: FUNC
577 * @tc.require:AR000GGNV3
578 * @tc.author:
579 */
580 HWTEST_F(Point3Test, Point3EqualTest002, TestSize.Level1)
581 {
582 Point3 point1(1.0f, 2.0f, 3.0f);
583 Point3 point2;
584 EXPECT_FALSE(point1 == point2);
585 }
586
587 /**
588 * @tc.name: Point3NotEqualTest001
589 * @tc.desc: Point3 Point3 Function Test
590 * @tc.type: FUNC
591 * @tc.require:AR000GGNV3
592 * @tc.author:
593 */
594 HWTEST_F(Point3Test, Point3NotEqualTest001, TestSize.Level1)
595 {
596 Point3 point1(1.0f, 2.0f, 3.0f);
597 Point3 point2;
598 EXPECT_TRUE(point1 != point2);
599 }
600
601 /**
602 * @tc.name: Point3NotEqualTest002
603 * @tc.desc: Point3 Point3 Function Test
604 * @tc.type: FUNC
605 * @tc.require:AR000GGNV3
606 * @tc.author:
607 */
608 HWTEST_F(Point3Test, Point3NotEqualTest002, TestSize.Level1)
609 {
610 Point3 point1;
611 Point3 point2;
612 EXPECT_FALSE(point1 != point2);
613 }
614 } // namespace Drawing
615 } // namespace Rosen
616 } // namespace OHOS