2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include <dali-test-suite-utils.h>
19 #include <dali/public-api/dali-core.h>
26 void utc_dali_degree_startup(void)
28 test_return_value = TET_UNDEF;
31 void utc_dali_degree_cleanup(void)
33 test_return_value = TET_PASS;
36 // Positive test case for constructors
37 int UtcDaliDegreeConstructors01(void)
39 TestApplication application;
41 // Default constructor, does not initialise the value
44 // Test assignment operator
45 degree0 = Degree(180.0f);
46 DALI_TEST_EQUALS(degree0.degree, 180.0f, 0.001f, TEST_LOCATION);
48 // Constructor from float value
49 Degree degree1(180.0f);
50 DALI_TEST_EQUALS(degree1.degree, 180.0f, 0.001f, TEST_LOCATION);
52 // Constructor from a Radian
53 Degree degree2(Radian(Math::PI));
54 DALI_TEST_EQUALS(degree2.degree, 180.0f, 0.001f, TEST_LOCATION);
59 int UtcDaliDegreeCopyConstructor(void)
61 Degree degree0(90.0f);
62 Degree degree1(degree0);
63 DALI_TEST_EQUALS(degree1.degree, 90.0f, 0.001f, TEST_LOCATION);
68 int UtcDaliDegreeMoveConstructor(void)
70 Degree degree0(90.0f);
71 Degree degree1 = std::move(degree0);
72 DALI_TEST_EQUALS(degree1.degree, 90.0f, 0.001f, TEST_LOCATION);
77 int UtcDaliDegreeCopyAssignment(void)
79 Degree degree0(90.0f);
82 DALI_TEST_EQUALS(degree1.degree, 90.0f, 0.001f, TEST_LOCATION);
87 int UtcDaliDegreeMoveAssignment(void)
89 Degree degree0(90.0f);
91 degree1 = std::move(degree0);
92 DALI_TEST_EQUALS(degree1.degree, 90.0f, 0.001f, TEST_LOCATION);
97 // Positive test case for comparison
98 int UtcDaliDegreeComparison01(void)
100 TestApplication application;
102 // Comparison between degrees
103 Degree degree0(90.0f);
104 Degree degree1(90.0f);
105 Degree degree2(180.0f);
107 DALI_TEST_CHECK(degree0 == degree1);
108 DALI_TEST_CHECK(degree0 != degree2);
110 // Comparison between radian to degree
111 Degree degree3(180.0f);
112 Degree degree4(90.0f);
113 Radian radian0(Math::PI);
115 DALI_TEST_CHECK(degree3 == Degree(radian0));
116 DALI_TEST_CHECK(degree4 != Degree(radian0));
118 // Comparison with float
119 Degree degree5(90.0f);
121 DALI_TEST_CHECK(degree5.degree == 90.0f);
122 DALI_TEST_CHECK(degree5.degree != 180.0f);
127 int UtcDaliDegreeOperatorEquals(void)
129 TestApplication application;
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);
141 int UtcDaliDegreeOperatorNotEquals(void)
143 TestApplication application;
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);