Merge "Add method to get ObjectRegistry from Core" into devel/master
[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 <iostream>
19
20 #include <stdlib.h>
21 #include <dali/public-api/dali-core.h>
22 #include <dali-test-suite-utils.h>
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
37 // Positive test case for constructors
38 int UtcDaliDegreeConstructors01(void)
39 {
40   TestApplication application;
41
42   // Default constructor, does not initialise the value
43   Degree degree0( 0.0f );
44
45   // Test assignment operator
46   degree0 = Degree(180.0f);
47   DALI_TEST_EQUALS( degree0.degree, 180.0f, 0.001f, TEST_LOCATION );
48
49   // Constructor from float value
50   Degree degree1( 180.0f );
51   DALI_TEST_EQUALS( degree1.degree, 180.0f, 0.001f, TEST_LOCATION );
52
53   // Constructor from a Radian
54   Degree degree2( Radian( Math::PI ) );
55   DALI_TEST_EQUALS( degree2.degree, 180.0f, 0.001f, TEST_LOCATION );
56
57   END_TEST;
58 }
59
60 int UtcDaliDegreeCopyConstructor(void)
61 {
62   Degree degree0( 90.0f );
63   Degree degree1( degree0 );
64   DALI_TEST_EQUALS( degree1.degree, 90.0f, 0.001f, TEST_LOCATION );
65
66   END_TEST;
67 }
68
69 int UtcDaliDegreeMoveConstructor(void)
70 {
71   Degree degree0( 90.0f );
72   Degree degree1 = std::move( degree0 );
73   DALI_TEST_EQUALS( degree1.degree, 90.0f, 0.001f, TEST_LOCATION );
74
75   END_TEST;
76 }
77
78 int UtcDaliDegreeCopyAssignment(void)
79 {
80   Degree degree0( 90.0f );
81   Degree degree1;
82   degree1 = degree0;
83   DALI_TEST_EQUALS( degree1.degree, 90.0f, 0.001f, TEST_LOCATION );
84
85   END_TEST;
86 }
87
88 int UtcDaliDegreeMoveAssignment(void)
89 {
90   Degree degree0( 90.0f );
91   Degree degree1;
92   degree1 = std::move( degree0 );
93   DALI_TEST_EQUALS( degree1.degree, 90.0f, 0.001f, TEST_LOCATION );
94
95   END_TEST;
96 }
97
98 // Positive test case for comparison
99 int UtcDaliDegreeComparison01(void)
100 {
101   TestApplication application;
102
103   // Comparison between degrees
104   Degree degree0( 90.0f );
105   Degree degree1( 90.0f );
106   Degree degree2( 180.0f );
107
108   DALI_TEST_CHECK( degree0 == degree1 );
109   DALI_TEST_CHECK( degree0 != degree2 );
110
111   // Comparison between radian to degree
112   Degree degree3( 180.0f );
113   Degree degree4( 90.0f );
114   Radian radian0( Math::PI );
115
116   DALI_TEST_CHECK( degree3 == Degree(radian0) );
117   DALI_TEST_CHECK( degree4 != Degree(radian0) );
118
119   // Comparison with float
120   Degree degree5( 90.0f );
121
122   DALI_TEST_CHECK( degree5.degree == 90.0f );
123   DALI_TEST_CHECK( degree5.degree != 180.0f );
124
125   END_TEST;
126 }
127
128 int UtcDaliDegreeOperatorEquals(void)
129 {
130   TestApplication application;
131
132   Degree a(90.0f);
133   Degree b(90.0f);
134   Degree c(180.0f);
135
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);
139   END_TEST;
140 }
141
142 int UtcDaliDegreeOperatorNotEquals(void)
143 {
144   TestApplication application;
145
146   Degree a(90.0f);
147   Degree b(90.0f);
148   Degree c(180.0f);
149
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);
153   END_TEST;
154 }