Revert "[Tizen] Appendix log for ttrace + Print keycode and timestamp"
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Degree.cpp
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <dali-test-suite-utils.h>
19 #include <dali/public-api/dali-core.h>
20 #include <stdlib.h>
21
22 #include <iostream>
23
24 using namespace Dali;
25
26 void utc_dali_degree_startup(void)
27 {
28   test_return_value = TET_UNDEF;
29 }
30
31 void utc_dali_degree_cleanup(void)
32 {
33   test_return_value = TET_PASS;
34 }
35
36 // Positive test case for constructors
37 int UtcDaliDegreeConstructors01(void)
38 {
39   TestApplication application;
40
41   // Default constructor, does not initialise the value
42   Degree degree0(0.0f);
43
44   // Test assignment operator
45   degree0 = Degree(180.0f);
46   DALI_TEST_EQUALS(degree0.degree, 180.0f, 0.001f, TEST_LOCATION);
47
48   // Constructor from float value
49   Degree degree1(180.0f);
50   DALI_TEST_EQUALS(degree1.degree, 180.0f, 0.001f, TEST_LOCATION);
51
52   // Constructor from a Radian
53   Degree degree2(Radian(Math::PI));
54   DALI_TEST_EQUALS(degree2.degree, 180.0f, 0.001f, TEST_LOCATION);
55
56   END_TEST;
57 }
58
59 int UtcDaliDegreeCopyConstructor(void)
60 {
61   Degree degree0(90.0f);
62   Degree degree1(degree0);
63   DALI_TEST_EQUALS(degree1.degree, 90.0f, 0.001f, TEST_LOCATION);
64
65   END_TEST;
66 }
67
68 int UtcDaliDegreeMoveConstructor(void)
69 {
70   Degree degree0(90.0f);
71   Degree degree1 = std::move(degree0);
72   DALI_TEST_EQUALS(degree1.degree, 90.0f, 0.001f, TEST_LOCATION);
73
74   END_TEST;
75 }
76
77 int UtcDaliDegreeCopyAssignment(void)
78 {
79   Degree degree0(90.0f);
80   Degree degree1;
81   degree1 = degree0;
82   DALI_TEST_EQUALS(degree1.degree, 90.0f, 0.001f, TEST_LOCATION);
83
84   END_TEST;
85 }
86
87 int UtcDaliDegreeMoveAssignment(void)
88 {
89   Degree degree0(90.0f);
90   Degree degree1;
91   degree1 = std::move(degree0);
92   DALI_TEST_EQUALS(degree1.degree, 90.0f, 0.001f, TEST_LOCATION);
93
94   END_TEST;
95 }
96
97 // Positive test case for comparison
98 int UtcDaliDegreeComparison01(void)
99 {
100   TestApplication application;
101
102   // Comparison between degrees
103   Degree degree0(90.0f);
104   Degree degree1(90.0f);
105   Degree degree2(180.0f);
106
107   DALI_TEST_CHECK(degree0 == degree1);
108   DALI_TEST_CHECK(degree0 != degree2);
109
110   // Comparison between radian to degree
111   Degree degree3(180.0f);
112   Degree degree4(90.0f);
113   Radian radian0(Math::PI);
114
115   DALI_TEST_CHECK(degree3 == Degree(radian0));
116   DALI_TEST_CHECK(degree4 != Degree(radian0));
117
118   // Comparison with float
119   Degree degree5(90.0f);
120
121   DALI_TEST_CHECK(degree5.degree == 90.0f);
122   DALI_TEST_CHECK(degree5.degree != 180.0f);
123
124   END_TEST;
125 }
126
127 int UtcDaliDegreeOperatorEquals(void)
128 {
129   TestApplication application;
130
131   Degree a(90.0f);
132   Degree b(90.0f);
133   Degree c(180.0f);
134
135   DALI_TEST_EQUALS(a == a, true, TEST_LOCATION);
136   DALI_TEST_EQUALS(a == b, true, TEST_LOCATION);
137   DALI_TEST_EQUALS(a == c, false, TEST_LOCATION);
138   END_TEST;
139 }
140
141 int UtcDaliDegreeOperatorNotEquals(void)
142 {
143   TestApplication application;
144
145   Degree a(90.0f);
146   Degree b(90.0f);
147   Degree c(180.0f);
148
149   DALI_TEST_EQUALS(a != a, false, TEST_LOCATION);
150   DALI_TEST_EQUALS(a != b, false, TEST_LOCATION);
151   DALI_TEST_EQUALS(a != c, true, TEST_LOCATION);
152   END_TEST;
153 }