Merge "Added api to specify a playing range inside an animation" into tizen
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Radian.cpp
1 #include <iostream>
2
3 #include <stdlib.h>
4 #include <dali/public-api/dali-core.h>
5 #include <dali-test-suite-utils.h>
6
7 using namespace Dali;
8
9
10 void utc_dali_radian_startup(void)
11 {
12   test_return_value = TET_UNDEF;
13 }
14
15 void utc_dali_radian_cleanup(void)
16 {
17   test_return_value = TET_PASS;
18 }
19
20
21 // Positive test case for constructors
22 int UtcDaliRadianConstructors01(void)
23 {
24   TestApplication application;
25
26   // Default constructor, does not initialise the value
27   Radian radian0( 0.0f );
28
29   // Test float assignment operator
30   radian0 = Math::PI;
31   DALI_TEST_EQUALS( float(radian0), Math::PI, 0.001f, TEST_LOCATION );
32
33   // Constructor from float value
34   Radian radian1( Math::PI );
35   DALI_TEST_EQUALS( float(radian1), Math::PI, 0.001f, TEST_LOCATION );
36
37   // Constructor from a Degree
38   Radian radian2( Degree( 180.0f ) );
39   DALI_TEST_EQUALS( float(radian2), Math::PI, 0.001f, TEST_LOCATION );
40
41   // Assignment from Degree
42   Radian radian3( 0.0f );
43   radian3 = Degree( 180.0f );
44   DALI_TEST_EQUALS( float(radian3), Math::PI, 0.001f, TEST_LOCATION );
45   END_TEST;
46 }
47
48 // Positive test case for comparison
49 int UtcDaliRadianComparison01(void)
50 {
51   TestApplication application;
52
53   // Comparison between radians
54   Radian radian0( Math::PI_2 );
55   Radian radian1( Math::PI_2 );
56   Radian radian2( Math::PI );
57
58   DALI_TEST_CHECK( radian0 == radian1 );
59   DALI_TEST_CHECK( radian0 != radian2 );
60
61   // Comparison between radian to degree
62   Radian radian3( Math::PI );
63   Radian radian4( Math::PI_2 );
64   Degree degree0( 180.0f );
65
66   DALI_TEST_CHECK( radian3 == degree0 );
67   DALI_TEST_CHECK( radian4 != degree0 );
68
69   // Comparison with float
70   Radian radian5( Math::PI_2 );
71
72   DALI_TEST_CHECK( radian5 == Math::PI_2 );
73   DALI_TEST_CHECK( radian5 != Math::PI );
74
75   END_TEST;
76 }
77
78
79 // test case for cast operators
80 int UtcDaliRadianCastOperators01(void)
81 {
82   TestApplication application;  // Exceptions require TestApplication
83
84   Radian radian0( Math::PI );
85
86   const float& value0( radian0 );
87   DALI_TEST_EQUALS( value0, Math::PI, 0.001f, TEST_LOCATION );
88
89   radian0 = Math::PI_2;
90   DALI_TEST_EQUALS( value0, Math::PI_2, 0.001f, TEST_LOCATION );
91
92   float& value1( radian0 );
93   DALI_TEST_EQUALS( value1, Math::PI_2, 0.001f, TEST_LOCATION );
94
95   value1 = Math::PI;
96   DALI_TEST_EQUALS( float(radian0), Math::PI, 0.001f, TEST_LOCATION );
97   END_TEST;
98 }
99
100
101 int UtcDaliRadianCastOperatorEquals(void)
102 {
103   TestApplication application;
104
105   Radian a(Math::PI_2);
106   Radian b(Math::PI_2);
107   Radian c(Math::PI);
108
109   DALI_TEST_EQUALS(a == a, true, TEST_LOCATION);
110   DALI_TEST_EQUALS(a == b, true, TEST_LOCATION);
111   DALI_TEST_EQUALS(a == c, false, TEST_LOCATION);
112   END_TEST;
113 }
114
115 int UtcDaliRadianCastOperatorNotEquals(void)
116 {
117   TestApplication application;
118
119   Radian a(Math::PI_2);
120   Radian b(Math::PI_2);
121   Radian c(Math::PI);
122
123   DALI_TEST_EQUALS(a != a, false, TEST_LOCATION);
124   DALI_TEST_EQUALS(a != b, false, TEST_LOCATION);
125   DALI_TEST_EQUALS(a != c, true, TEST_LOCATION);
126   END_TEST;
127 }
128
129 int UtcDaliRadianCastOperatorLessThan(void)
130 {
131   TestApplication application;
132
133   Radian a(Math::PI_4);
134   Radian b(Math::PI_2);
135   Radian c(Math::PI);
136   Radian d(2.0f*Math::PI);
137   Radian e(-Math::PI);
138
139   DALI_TEST_EQUALS(a < a, false, TEST_LOCATION);
140   DALI_TEST_EQUALS(a < b, true, TEST_LOCATION);
141   DALI_TEST_EQUALS(a < c, true, TEST_LOCATION);
142   DALI_TEST_EQUALS(a < d, true, TEST_LOCATION);
143   DALI_TEST_EQUALS(a < e, false, TEST_LOCATION);
144
145   DALI_TEST_EQUALS(b < a, false, TEST_LOCATION);
146   DALI_TEST_EQUALS(b < b, false, TEST_LOCATION);
147   DALI_TEST_EQUALS(c < b, false, TEST_LOCATION);
148   DALI_TEST_EQUALS(d < b, false, TEST_LOCATION);
149   DALI_TEST_EQUALS(e < b, true, TEST_LOCATION);
150
151   DALI_TEST_EQUALS(Radian(Math::PI_2) < Degree(180.0f), true,  TEST_LOCATION);
152   DALI_TEST_EQUALS(Radian(Math::PI_2) < Degree(90.0f),  false, TEST_LOCATION);
153   DALI_TEST_EQUALS(Radian(Math::PI_2) < Degree(45.0f),  false, TEST_LOCATION);
154   END_TEST;
155 }