• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020-2021 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, software
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 "gfx_utils/graphic_math.h"
17 
18 #include <climits>
19 #include <gtest/gtest.h>
20 
21 using namespace testing::ext;
22 
23 namespace OHOS {
24 namespace {
25     const Point POINT1 = { 5, 4 };
26     const Point POINT2 = { 3, 2 };
27     const uint16_t MAX_NUM_8BIT = 256;
28 }
29 class MathTest : public testing::Test {
30 public:
SetUpTestCase(void)31     static void SetUpTestCase(void) {}
TearDownTestCase(void)32     static void TearDownTestCase(void) {}
33 };
34 
35 /**
36  * @tc.name: MathSin_001
37  * @tc.desc: Verify Sin function, equal.
38  * @tc.type: FUNC
39  * @tc.require: AR000EEMQ9
40  */
41 HWTEST_F(MathTest, MathSin_001, TestSize.Level0)
42 {
43     EXPECT_EQ(Sin(0), 0);
44     EXPECT_EQ(Sin(QUARTER_IN_DEGREE), 1);
45     EXPECT_EQ(Sin(THREE_QUARTER_IN_DEGREE), -1);
46 }
47 
48 /**
49  * @tc.name: MathFastAtan2_001
50  * @tc.desc: Verify FastAtan2 function, equal.
51  * @tc.type: FUNC
52  * @tc.require: AR000EEMQ9
53  */
54 HWTEST_F(MathTest, MathFastAtan2_001, TestSize.Level0)
55 {
56     EXPECT_EQ(FastAtan2(0, 1), 0);
57     EXPECT_EQ(FastAtan2(1, 0), QUARTER_IN_DEGREE);
58     EXPECT_EQ(FastAtan2(0, -1), SEMICIRCLE_IN_DEGREE);
59     EXPECT_EQ(FastAtan2(-1, 0), THREE_QUARTER_IN_DEGREE);
60 }
61 
62 
63 /**
64  * @tc.name: MathFloatToInt64_001
65  * @tc.desc: Verify FloatToInt64 function, equal.
66  * @tc.type: FUNC
67  * @tc.require: AR000EEMQ9
68  */
69 HWTEST_F(MathTest, MathFloatToInt64_001, TestSize.Level0)
70 {
71     EXPECT_EQ(FloatToInt64(1), MAX_NUM_8BIT);
72 }
73 
74 /**
75  * @tc.name: MathSqrt_001
76  * @tc.desc: Verify Sqrt function, equal.
77  * @tc.type: FUNC
78  * @tc.require: AR000EEMQ9
79  */
80 HWTEST_F(MathTest, MathSqrt_001, TestSize.Level0)
81 {
82     const float testInteger = 2.0;
83     const float testIntegerSquared = testInteger * testInteger;
84     const float testFloat = 2.121320; // 2.121320: 4.5 squaring results
85     const float testFloatSquared = 4.5;
86     const float accuracy = 0.000001;
87 
88     EXPECT_EQ(Sqrt(0), 0);
89     float ret = Sqrt(testIntegerSquared);
90     if (ret > testInteger - accuracy && ret < testInteger + accuracy) {
91         EXPECT_EQ(0, 0);
92     } else {
93         EXPECT_NE(0, 0);
94     }
95 
96     ret = Sqrt(testFloatSquared);
97     if (ret > testFloat - accuracy && ret < testFloat + accuracy) {
98         EXPECT_EQ(0, 0);
99     } else {
100         EXPECT_NE(0, 0);
101     }
102 }
103 
104 /**
105  * @tc.name: Vector2Dot_001
106  * @tc.desc: Verify Dot function, equal.
107  * @tc.type: FUNC
108  * @tc.require: AR000EEMQ9
109  */
110 HWTEST_F(MathTest, Vector2Dot_001, TestSize.Level0)
111 {
112     Vector2<uint16_t>* vector1 = new Vector2<uint16_t>(POINT1.x, POINT1.y);
113     if (vector1 == nullptr) {
114         EXPECT_EQ(1, 0);
115         return;
116     }
117     Vector2<uint16_t>* vector2 = new Vector2<uint16_t>(POINT2.x, POINT2.y);
118     if (vector2 == nullptr) {
119         delete vector1;
120         EXPECT_EQ(1, 0);
121         return;
122     }
123     uint16_t value = POINT1.x * POINT2.x + POINT1.y * POINT2.y;
124 
125     EXPECT_EQ(vector1->Dot(*vector2), value);
126 
127     delete vector1;
128     delete vector2;
129 }
130 
131 /**
132  * @tc.name: Vector2Cross_001
133  * @tc.desc: Verify Cross function, equal.
134  * @tc.type: FUNC
135  * @tc.require: AR000EEMQ9
136  */
137 HWTEST_F(MathTest, Vector2Cross_001, TestSize.Level0)
138 {
139     Vector2<uint16_t>* vector1 = new Vector2<uint16_t>(POINT1.x, POINT1.y);
140     if (vector1 == nullptr) {
141         EXPECT_EQ(1, 0);
142         return;
143     }
144     Vector2<uint16_t>* vector2 = new Vector2<uint16_t>(POINT2.x, POINT2.y);
145     if (vector2 == nullptr) {
146         delete vector1;
147         EXPECT_EQ(1, 0);
148         return;
149     }
150     uint16_t value = POINT1.x * POINT2.y - POINT1.y * POINT2.x;
151 
152     EXPECT_EQ(vector1->Cross(*vector2), value);
153 
154     delete vector1;
155     delete vector2;
156 }
157 
158 /**
159  * @tc.name: Vector2Operator_001
160  * @tc.desc: Verify negative operator function, equal.
161  * @tc.type: FUNC
162  * @tc.require: AR000EEMQ9
163  */
164 HWTEST_F(MathTest, Vector2Operator_001, TestSize.Level0)
165 {
166     Vector2<uint16_t>* vector1 = new Vector2<uint16_t>(POINT1.x, POINT1.y);
167     if (vector1 == nullptr) {
168         EXPECT_EQ(1, 0);
169         return;
170     }
171     Vector2<uint16_t> vector3 = vector1->operator-();
172 
173     EXPECT_EQ(vector3.x_, 65531); // 65531: -POINT1.x
174     EXPECT_EQ(vector3.y_, 65532); // 65532: -POINT1.y
175     delete vector1;
176 }
177 
178 /**
179  * @tc.name: Vector2Operator_002
180  * @tc.desc: Verify minus operator function, equal.
181  * @tc.type: FUNC
182  * @tc.require: AR000EEMQ9
183  */
184 HWTEST_F(MathTest, Vector2Operator_002, TestSize.Level0)
185 {
186     Vector2<uint16_t>* vector1 = new Vector2<uint16_t>(POINT1.x, POINT1.y);
187     if (vector1 == nullptr) {
188         EXPECT_EQ(1, 0);
189         return;
190     }
191     Vector2<uint16_t>* vector2 = new Vector2<uint16_t>(POINT2.x, POINT2.y);
192     if (vector2 == nullptr) {
193         delete vector1;
194         EXPECT_EQ(1, 0);
195         return;
196     }
197     Vector2<uint16_t> vector3 = vector1->operator-(*vector2);
198 
199     EXPECT_EQ(vector3.x_, POINT1.x - POINT2.x);
200     EXPECT_EQ(vector3.y_, POINT1.y - POINT2.y);
201     delete vector1;
202     delete vector2;
203 }
204 
205 /**
206  * @tc.name: Vector2Operator_003
207  * @tc.desc: Verify addition operator function, equal.
208  * @tc.type: FUNC
209  * @tc.require: AR000EEMQ9
210  */
211 HWTEST_F(MathTest, Vector2Operator_003, TestSize.Level0)
212 {
213     Vector2<uint16_t>* vector1 = new Vector2<uint16_t>(POINT1.x, POINT1.y);
214     if (vector1 == nullptr) {
215         EXPECT_EQ(1, 0);
216         return;
217     }
218     Vector2<uint16_t>* vector2 = new Vector2<uint16_t>(POINT2.x, POINT2.y);
219     if (vector2 == nullptr) {
220         delete vector1;
221         EXPECT_EQ(1, 0);
222         return;
223     }
224     Vector2<uint16_t> vector3 = vector1->operator+(*vector2);
225 
226     EXPECT_EQ(vector3.x_, POINT1.x + POINT2.x);
227     EXPECT_EQ(vector3.y_, POINT1.y + POINT2.y);
228     delete vector1;
229     delete vector2;
230 }
231 
232 /**
233  * @tc.name: Vector2Operator_004
234  * @tc.desc: Verify multiplication operator function, equal.
235  * @tc.type: FUNC
236  * @tc.require: AR000EEMQ9
237  */
238 HWTEST_F(MathTest, Vector2Operator_004, TestSize.Level0)
239 {
240     Vector2<uint16_t>* vector1 = new Vector2<uint16_t>(POINT1.x, POINT1.y);
241     if (vector1 == nullptr) {
242         EXPECT_EQ(1, 0);
243         return;
244     }
245     Vector2<uint16_t> vector3 = vector1->operator*(2);
246     EXPECT_EQ(vector3.x_, POINT1.x * 2);
247     EXPECT_EQ(vector3.y_, POINT1.y * 2);
248     delete vector1;
249 }
250 
251 /**
252  * @tc.name: Vector2Operator_005
253  * @tc.desc: Verify equal operator function, equal.
254  * @tc.type: FUNC
255  * @tc.require: AR000EEMQ9
256  */
257 HWTEST_F(MathTest, Vector2Operator_005, TestSize.Level0)
258 {
259     Vector2<uint16_t>* vector1 = new Vector2<uint16_t>(POINT1.x, POINT1.y);
260     if (vector1 == nullptr) {
261         EXPECT_EQ(1, 0);
262         return;
263     }
264     Vector2<uint16_t>* vector2 = new Vector2<uint16_t>(POINT2.x, POINT2.y);
265     if (vector2 == nullptr) {
266         delete vector1;
267         EXPECT_EQ(1, 0);
268         return;
269     }
270     Vector2<uint16_t>* vector3 = new Vector2<uint16_t>(POINT1.x, POINT1.y);
271     if (vector3 == nullptr) {
272         delete vector1;
273         delete vector2;
274         EXPECT_EQ(1, 0);
275         return;
276     }
277     EXPECT_EQ(vector1->operator==(*vector2), false);
278     EXPECT_EQ(vector1->operator==(*vector3), true);
279 
280     delete vector1;
281     delete vector2;
282     delete vector3;
283 }
284 
285 /**
286  * @tc.name: Vector2Operator_006
287  * @tc.desc: Verify assignment operator function, equal.
288  * @tc.type: FUNC
289  * @tc.require: AR000EEMQ9
290  */
291 HWTEST_F(MathTest, Vector2Operator_006, TestSize.Level0)
292 {
293     Vector2<uint16_t>* vector2 = new Vector2<uint16_t>(POINT2.x, POINT2.y);
294     if (vector2 == nullptr) {
295         EXPECT_EQ(1, 0);
296         return;
297     }
298     Vector2<uint16_t>* vector3 = new Vector2<uint16_t>(POINT1.x, POINT1.y);
299     if (vector3 == nullptr) {
300         delete vector2;
301         EXPECT_EQ(1, 0);
302         return;
303     }
304     vector3->operator=(*vector2);
305     EXPECT_EQ(vector3->x_, POINT2.x);
306     EXPECT_EQ(vector3->y_, POINT2.y);
307 
308     delete vector2;
309     delete vector3;
310 }
311 
312 /**
313  * @tc.name: Vector2Operator_007
314  * @tc.desc: Verify plus equal operator function, equal.
315  * @tc.type: FUNC
316  * @tc.require: AR000EEMQ9
317  */
318 HWTEST_F(MathTest, Vector2Operator_007, TestSize.Level0)
319 {
320     Vector2<uint16_t>* vector2 = new Vector2<uint16_t>(POINT2.x, POINT2.y);
321     if (vector2 == nullptr) {
322         EXPECT_EQ(1, 0);
323         return;
324     }
325     Vector2<uint16_t>* vector3 = new Vector2<uint16_t>(POINT1.x, POINT1.y);
326     if (vector3 == nullptr) {
327         delete vector2;
328         EXPECT_EQ(1, 0);
329         return;
330     }
331 
332     vector3->operator+=(*vector2);
333     EXPECT_EQ(vector3->x_, POINT1.x + POINT2.x);
334     EXPECT_EQ(vector3->y_, POINT1.y + POINT2.y);
335 
336     delete vector2;
337     delete vector3;
338 }
339 
340 /**
341  * @tc.name: Vector2Operator_008
342  * @tc.desc: Verify minus equal operator function, equal.
343  * @tc.type: FUNC
344  * @tc.require: AR000EEMQ9
345  */
346 HWTEST_F(MathTest, Vector2Operator_008, TestSize.Level0)
347 {
348     Vector2<uint16_t>* vector2 = new Vector2<uint16_t>(POINT2.x, POINT2.y);
349     if (vector2 == nullptr) {
350         EXPECT_EQ(1, 0);
351         return;
352     }
353     Vector2<uint16_t>* vector3 = new Vector2<uint16_t>(POINT1.x, POINT1.y);
354     if (vector3 == nullptr) {
355         delete vector2;
356         EXPECT_EQ(1, 0);
357         return;
358     }
359 
360     vector3->operator-=(*vector2);
361     EXPECT_EQ(vector3->x_, POINT1.x - POINT2.x);
362     EXPECT_EQ(vector3->y_, POINT1.y - POINT2.y);
363 
364     delete vector2;
365     delete vector3;
366 }
367 
368 /**
369  * @tc.name: Vector3Operator_001
370  * @tc.desc: Verify index operator function, equal.
371  * @tc.type: FUNC
372  * @tc.require: AR000EEMQ9
373  */
374 HWTEST_F(MathTest, Vector3Operator_001, TestSize.Level0)
375 {
376     const uint16_t posX = 3;
377     const uint16_t posY = 5;
378     const uint16_t posZ = 7;
379     Vector3<uint16_t>* vector1 = new Vector3<uint16_t>(posX, posY, posZ);
380     if (vector1 == nullptr) {
381         EXPECT_EQ(1, 0);
382         return;
383     }
384 
385     uint16_t i = 0;
386     EXPECT_EQ(vector1->operator[](i++), posX);
387     EXPECT_EQ(vector1->operator[](i++), posY);
388     EXPECT_EQ(vector1->operator[](i++), posZ);
389 
390     delete vector1;
391 }
392 
393 /**
394  * @tc.name: Vector3Operator_002
395  * @tc.desc: Verify equal operator function, equal.
396  * @tc.type: FUNC
397  * @tc.require: AR000EEMQ9
398  */
399 HWTEST_F(MathTest, Vector3Operator_002, TestSize.Level0)
400 {
401     const uint16_t posX = 3;
402     const uint16_t posY = 5;
403     const uint16_t posZ = 7;
404     Vector3<uint16_t>* vector1 = new Vector3<uint16_t>(posX, posY, posZ);
405     if (vector1 == nullptr) {
406         EXPECT_EQ(1, 0);
407         return;
408     }
409     Vector3<uint16_t>* vector2 = new Vector3<uint16_t>(posX, posY, posZ);
410     if (vector2 == nullptr) {
411         delete vector1;
412         EXPECT_EQ(1, 0);
413         return;
414     }
415     Vector3<uint16_t>* vector3 = new Vector3<uint16_t>(posX - 1, posY, posZ);
416     if (vector3 == nullptr) {
417         delete vector1;
418         delete vector2;
419         EXPECT_EQ(1, 0);
420         return;
421     }
422     EXPECT_EQ(vector1->operator==(*vector2), true);
423     EXPECT_EQ(vector1->operator==(*vector3), false);
424 
425     delete vector1;
426     delete vector2;
427     delete vector3;
428 }
429 
430 /**
431  * @tc.name: Matrix3GetData_001
432  * @tc.desc: Verify GetData function, equal.
433  * @tc.type: FUNC
434  * @tc.require: AR000EEMQ9
435  */
436 HWTEST_F(MathTest, Matrix3GetData_001, TestSize.Level0)
437 {
438     Matrix3<uint16_t>* matrix = new Matrix3<uint16_t>(1, 1, 1, 1, 1, 1, 1, 1, 1);
439     if (matrix == nullptr) {
440         EXPECT_EQ(1, 0);
441         return;
442     }
443     EXPECT_EQ(matrix->GetData()[0], 1);
444 
445     delete matrix;
446 }
447 
448 /**
449  * @tc.name: Matrix3Operator_001
450  * @tc.desc: Verify multiplication operator function, equal.
451  * @tc.type: FUNC
452  * @tc.require: AR000EEMQ9
453  */
454 HWTEST_F(MathTest, Matrix3Operator_001, TestSize.Level0)
455 {
456     Matrix3<uint16_t> matrix1(1, 1, 1, 1, 1, 1, 1, 1, 1);
457     /*
458      * 1: m00 Indicates the element in row 1 and column 1 of the matrix.
459      * 2: m01 Indicates the element in row 1 and column 2 of the matrix.
460      * 3: m02 Indicates the element in row 1 and column 3 of the matrix.
461      * 4: m10 Indicates the element in row 2 and column 1 of the matrix.
462      * 5: m11 Indicates the element in row 2 and column 2 of the matrix.
463      * 6: m12 Indicates the element in row 2 and column 3 of the matrix.
464      * 7: m20 Indicates the element in row 3 and column 1 of the matrix.
465      * 8: m21 Indicates the element in row 3 and column 2 of the matrix.
466      * 9: m22 Indicates the element in row 3 and column 3 of the matrix.
467      */
468     Matrix3<uint16_t> matrix2(1, 2, 3, 4, 5, 6, 7, 8, 9);
469     Matrix3<uint16_t> matrix3 = matrix1 * matrix2;
470 
471     uint16_t i = 0;
472     // 6: data_[0] * oData[0] + data_[3] * oData[1] + data_[6] * oData[2];
473     EXPECT_EQ(matrix3.GetData()[i++], 6);
474     // 6: data_[1] * oData[0] + data_[4] * oData[1] + data_[7] * oData[2];
475     EXPECT_EQ(matrix3.GetData()[i++], 6);
476     // 6: data_[2] * oData[0] + data_[5] * oData[1] + data_[8] * oData[2];
477     EXPECT_EQ(matrix3.GetData()[i++], 6);
478     // 15: data_[0] * oData[3] + data_[3] * oData[4] + data_[6] * oData[5];
479     EXPECT_EQ(matrix3.GetData()[i++], 15);
480     // 15: data_[1] * oData[3] + data_[4] * oData[4] + data_[7] * oData[5];
481     EXPECT_EQ(matrix3.GetData()[i++], 15);
482     // 15: data_[2] * oData[3] + data_[5] * oData[4] + data_[8] * oData[5];
483     EXPECT_EQ(matrix3.GetData()[i++], 15);
484     // 24: data_[0] * oData[6] + data_[3] * oData[7] + data_[6] * oData[8];
485     EXPECT_EQ(matrix3.GetData()[i++], 24);
486     // 24: data_[1] * oData[6] + data_[4] * oData[7] + data_[7] * oData[8];
487     EXPECT_EQ(matrix3.GetData()[i++], 24);
488     // 24: data_[2] * oData[6] + data_[5] * oData[7] + data_[8] * oData[8];
489     EXPECT_EQ(matrix3.GetData()[i++], 24);
490 }
491 
492 /**
493  * @tc.name: Matrix3Operator_002
494  * @tc.desc: Verify multiplication operator function, equal.
495  * @tc.type: FUNC
496  * @tc.require: AR000EEMQ9
497  */
498 HWTEST_F(MathTest, Matrix3Operator_002, TestSize.Level0)
499 {
500     Matrix3<uint16_t> matrix1(1, 1, 1, 1, 1, 1, 1, 1, 1);
501     /*
502      * 1: Indicates the X coordinate.
503      * 2: Indicates the Y coordinate.
504      * 3: Indicates the Z coordinate.
505      */
506     Vector3<uint16_t> vector1(1, 2, 3);
507     Vector3<uint16_t> vector2 = matrix1 * vector1;
508 
509     // 6: data_[0] * oData[0] + data_[3] * oData[1] + data_[6] * oData[2];
510     EXPECT_EQ(vector2.x_, 6);
511     // 6: data_[1] * oData[0] + data_[4] * oData[1] + data_[7] * oData[2];
512     EXPECT_EQ(vector2.y_, 6);
513     // 6: data_[2] * oData[0] + data_[5] * oData[1] + data_[8] * oData[2];
514     EXPECT_EQ(vector2.z_, 6);
515 }
516 
517 /**
518  * @tc.name: Matrix3Operator_003
519  * @tc.desc: Verify index operator function, equal.
520  * @tc.type: FUNC
521  * @tc.require: AR000EEMQ9
522  */
523 HWTEST_F(MathTest, Matrix3Operator_003, TestSize.Level0)
524 {
525     Matrix3<uint16_t>* matrix = new Matrix3<uint16_t>(1, 0, 0, 1, 0, 0, 1, 0, 0);
526     if (matrix == nullptr) {
527         EXPECT_EQ(1, 0);
528         return;
529     }
530     uint16_t i = 0;
531     EXPECT_EQ(*matrix->operator[](i++), 1);
532     EXPECT_EQ(*matrix->operator[](i++), 1);
533     EXPECT_EQ(*matrix->operator[](i++), 1);
534 
535     delete matrix;
536 }
537 
538 /**
539  * @tc.name: Matrix3Operator_004
540  * @tc.desc: Verify assignment operator function, equal.
541  * @tc.type: FUNC
542  * @tc.require: AR000EEMQ9
543  */
544 HWTEST_F(MathTest, Matrix3Operator_004, TestSize.Level0)
545 {
546     Matrix3<uint16_t>* matrix = new Matrix3<uint16_t>(1, 0, 0, 1, 0, 0, 1, 0, 0);
547     if (matrix == nullptr) {
548         EXPECT_EQ(1, 0);
549         return;
550     }
551     Matrix3<uint16_t>* matrix2 = new Matrix3<uint16_t>(1, 1, 1, 1, 1, 1, 1, 1, 1);
552     if (matrix2 == nullptr) {
553         delete matrix;
554         EXPECT_EQ(1, 0);
555         return;
556     }
557     matrix->operator=(*matrix2);
558     uint16_t i = 0;
559     EXPECT_EQ(matrix->GetData()[i++], 1);
560     EXPECT_EQ(matrix->GetData()[i++], 1);
561     EXPECT_EQ(matrix->GetData()[i++], 1);
562     EXPECT_EQ(matrix->GetData()[i++], 1);
563     EXPECT_EQ(matrix->GetData()[i++], 1);
564     EXPECT_EQ(matrix->GetData()[i++], 1);
565     EXPECT_EQ(matrix->GetData()[i++], 1);
566     EXPECT_EQ(matrix->GetData()[i++], 1);
567     EXPECT_EQ(matrix->GetData()[i++], 1);
568 
569     delete matrix;
570     delete matrix2;
571 }
572 
573 /**
574  * @tc.name: Matrix3Determinant_001
575  * @tc.desc: Verify Determinant operator function, equal.
576  * @tc.type: FUNC
577  * @tc.require: AR000EEMQ9
578  */
579 HWTEST_F(MathTest, Matrix3Determinant_001, TestSize.Level0)
580 {
581     Matrix3<uint16_t>* matrix2 = new Matrix3<uint16_t>(1, 1, 1, 1, 1, 1, 1, 1, 1);
582     if (matrix2 == nullptr) {
583         EXPECT_EQ(1, 0);
584         return;
585     }
586     EXPECT_EQ(matrix2->Determinant(), 0);
587 
588     delete matrix2;
589 }
590 
591 /**
592  * @tc.name: Matrix3Inverse_001
593  * @tc.desc: Verify Inverse operator function, equal.
594  * @tc.type: FUNC
595  * @tc.require: AR000EEMQ9
596  */
597 HWTEST_F(MathTest, Matrix3Inverse_001, TestSize.Level0)
598 {
599     Matrix3<uint16_t>* matrix1 = new Matrix3<uint16_t>(1, 1, 1, 1, 1, 1, 1, 1, 1);
600     if (matrix1 == nullptr) {
601         EXPECT_EQ(1, 0);
602         return;
603     }
604     Matrix3<uint16_t> matrix2 = matrix1->Inverse();
605 
606     uint16_t i = 0;
607     EXPECT_EQ(matrix2.GetData()[i++], 1);
608     EXPECT_EQ(matrix2.GetData()[i++], 1);
609     EXPECT_EQ(matrix2.GetData()[i++], 1);
610     EXPECT_EQ(matrix2.GetData()[i++], 1);
611     EXPECT_EQ(matrix2.GetData()[i++], 1);
612     EXPECT_EQ(matrix2.GetData()[i++], 1);
613     EXPECT_EQ(matrix2.GetData()[i++], 1);
614     EXPECT_EQ(matrix2.GetData()[i++], 1);
615     EXPECT_EQ(matrix2.GetData()[i++], 1);
616 
617     delete matrix1;
618 }
619 
620 /**
621  * @tc.name: Matrix3Operator_005
622  * @tc.desc: Verify equal operator function, equal.
623  * @tc.type: FUNC
624  * @tc.require: AR000EEMQ9
625  */
626 HWTEST_F(MathTest, Matrix3Operator_005, TestSize.Level0)
627 {
628     Matrix3<uint16_t>* matrix1 = new Matrix3<uint16_t>(1, 1, 1, 1, 1, 1, 1, 1, 1);
629     if (matrix1 == nullptr) {
630         EXPECT_EQ(1, 0);
631         return;
632     }
633     Matrix3<uint16_t>* matrix2 = new Matrix3<uint16_t>(1, 1, 1, 1, 1, 1, 1, 1, 1);
634     if (matrix2 == nullptr) {
635         delete matrix1;
636         EXPECT_EQ(1, 0);
637         return;
638     }
639     Matrix3<uint16_t>* matrix3 = new Matrix3<uint16_t>(1, 1, 1, 1, 1, 1, 0, 1, 1);
640     if (matrix3 == nullptr) {
641         delete matrix1;
642         delete matrix2;
643         EXPECT_EQ(1, 0);
644         return;
645     }
646 
647     EXPECT_EQ(matrix1->operator==(*matrix2), true);
648     EXPECT_EQ(matrix1->operator==(*matrix3), false);
649 
650     delete matrix1;
651     delete matrix2;
652     delete matrix3;
653 }
654 
655 /**
656  * @tc.name: Matrix3Rotate_001
657  * @tc.desc: Verify Rotate function, equal.
658  * @tc.type: FUNC
659  * @tc.require: AR000EEMQ9
660  */
661 HWTEST_F(MathTest, Matrix3Rotate_001, TestSize.Level0)
662 {
663     Matrix3<uint64_t> rotate = Matrix3<uint64_t>::Rotate(0, Vector2<uint64_t>(0, 0));
664     uint16_t i = 0;
665     EXPECT_EQ(rotate.GetData()[i++], 1);
666     EXPECT_EQ(rotate.GetData()[i++], 0);
667     EXPECT_EQ(rotate.GetData()[i++], 0);
668     EXPECT_EQ(rotate.GetData()[i++], 0);
669     EXPECT_EQ(rotate.GetData()[i++], 1);
670     EXPECT_EQ(rotate.GetData()[i++], 0);
671     EXPECT_EQ(rotate.GetData()[i++], 0);
672     EXPECT_EQ(rotate.GetData()[i++], 0);
673     EXPECT_EQ(rotate.GetData()[i++], 1);
674 }
675 
676 /**
677  * @tc.name: Matrix3Scale_001
678  * @tc.desc: Verify Scale function, equal.
679  * @tc.type: FUNC
680  * @tc.require: AR000EEMQ9
681  */
682 HWTEST_F(MathTest, Matrix3Scale_001, TestSize.Level0)
683 {
684     Matrix3<int64_t> scale =
685         Matrix3<int64_t>::Scale(Vector2<int64_t>(1, 1), Vector2<int64_t>(0, 0));
686     uint16_t i = 0;
687     EXPECT_EQ(scale.GetData()[i++], 1);
688     EXPECT_EQ(scale.GetData()[i++], 0);
689     EXPECT_EQ(scale.GetData()[i++], 0);
690     EXPECT_EQ(scale.GetData()[i++], 0);
691     EXPECT_EQ(scale.GetData()[i++], 1);
692     EXPECT_EQ(scale.GetData()[i++], 0);
693     EXPECT_EQ(scale.GetData()[i++], 0);
694     EXPECT_EQ(scale.GetData()[i++], 0);
695     EXPECT_EQ(scale.GetData()[i++], 1);
696 }
697 
698 /**
699  * @tc.name: Matrix3Translate_001
700  * @tc.desc: Verify Translate function, equal.
701  * @tc.type: FUNC
702  * @tc.require: AR000EEMQ9
703  */
704 HWTEST_F(MathTest, Matrix3Translate_001, TestSize.Level0)
705 {
706     Matrix3<int64_t> translate = Matrix3<int64_t>::Translate(Vector2<int64_t>(0, 0));
707     uint16_t i = 0;
708     EXPECT_EQ(translate.GetData()[i++], 1);
709     EXPECT_EQ(translate.GetData()[i++], 0);
710     EXPECT_EQ(translate.GetData()[i++], 0);
711     EXPECT_EQ(translate.GetData()[i++], 0);
712     EXPECT_EQ(translate.GetData()[i++], 1);
713     EXPECT_EQ(translate.GetData()[i++], 0);
714     EXPECT_EQ(translate.GetData()[i++], 0);
715     EXPECT_EQ(translate.GetData()[i++], 0);
716     EXPECT_EQ(translate.GetData()[i++], 1);
717 }
718 } // namespace OHOS
719