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.
21 #include <dali/public-api/dali-core.h>
22 #include <dali-test-suite-utils.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;
37 // Positive test case for constructors
38 int UtcDaliDegreeConstructors01(void)
40 TestApplication application;
42 // Default constructor, does not initialise the value
43 Degree degree0( 0.0f );
45 // Test assignment operator
46 degree0 = Degree(180.0f);
47 DALI_TEST_EQUALS( degree0.degree, 180.0f, 0.001f, TEST_LOCATION );
49 // Constructor from float value
50 Degree degree1( 180.0f );
51 DALI_TEST_EQUALS( degree1.degree, 180.0f, 0.001f, TEST_LOCATION );
53 // Constructor from a Radian
54 Degree degree2( Radian( Math::PI ) );
55 DALI_TEST_EQUALS( degree2.degree, 180.0f, 0.001f, TEST_LOCATION );
60 int UtcDaliDegreeCopyConstructor(void)
62 Degree degree0( 90.0f );
63 Degree degree1( degree0 );
64 DALI_TEST_EQUALS( degree1.degree, 90.0f, 0.001f, TEST_LOCATION );
69 int UtcDaliDegreeMoveConstructor(void)
71 Degree degree0( 90.0f );
72 Degree degree1 = std::move( degree0 );
73 DALI_TEST_EQUALS( degree1.degree, 90.0f, 0.001f, TEST_LOCATION );
78 int UtcDaliDegreeCopyAssignment(void)
80 Degree degree0( 90.0f );
83 DALI_TEST_EQUALS( degree1.degree, 90.0f, 0.001f, TEST_LOCATION );
88 int UtcDaliDegreeMoveAssignment(void)
90 Degree degree0( 90.0f );
92 degree1 = std::move( degree0 );
93 DALI_TEST_EQUALS( degree1.degree, 90.0f, 0.001f, TEST_LOCATION );
98 // Positive test case for comparison
99 int UtcDaliDegreeComparison01(void)
101 TestApplication application;
103 // Comparison between degrees
104 Degree degree0( 90.0f );
105 Degree degree1( 90.0f );
106 Degree degree2( 180.0f );
108 DALI_TEST_CHECK( degree0 == degree1 );
109 DALI_TEST_CHECK( degree0 != degree2 );
111 // Comparison between radian to degree
112 Degree degree3( 180.0f );
113 Degree degree4( 90.0f );
114 Radian radian0( Math::PI );
116 DALI_TEST_CHECK( degree3 == Degree(radian0) );
117 DALI_TEST_CHECK( degree4 != Degree(radian0) );
119 // Comparison with float
120 Degree degree5( 90.0f );
122 DALI_TEST_CHECK( degree5.degree == 90.0f );
123 DALI_TEST_CHECK( degree5.degree != 180.0f );
128 int UtcDaliDegreeOperatorEquals(void)
130 TestApplication application;
136 DALI_TEST_EQUALS(a == a, true, TEST_LOCATION);
137 DALI_TEST_EQUALS(a == b, true, TEST_LOCATION);
138 DALI_TEST_EQUALS(a == c, false, TEST_LOCATION);
142 int UtcDaliDegreeOperatorNotEquals(void)
144 TestApplication application;
150 DALI_TEST_EQUALS(a != a, false, TEST_LOCATION);
151 DALI_TEST_EQUALS(a != b, false, TEST_LOCATION);
152 DALI_TEST_EQUALS(a != c, true, TEST_LOCATION);