Dali 3D User Interface Engine
utc-Dali-Radian.cpp
Go to the documentation of this file.
1 #include <iostream>
2 
3 #include <stdlib.h>
5 #include <dali-test-suite-utils.h>
6 
7 using namespace Dali;
8 
9 
11 {
13 }
14 
16 {
18 }
19 
20 
21 // Positive test case for constructors
23 {
24  // Default constructor, does not initialise the value
25  Radian radian0( 0.0f );
26 
27  // Test float assignment operator
28  radian0 = Math::PI;
29  DALI_TEST_EQUALS( float(radian0), Math::PI, 0.001f, TEST_LOCATION );
30 
31  // Constructor from float value
32  Radian radian1( Math::PI );
33  DALI_TEST_EQUALS( float(radian1), Math::PI, 0.001f, TEST_LOCATION );
34 
35  // Constructor from a Degree
36  Radian radian2( Degree( 180.0f ) );
37  DALI_TEST_EQUALS( float(radian2), Math::PI, 0.001f, TEST_LOCATION );
38 
39  // Assignment from Degree
40  Radian radian3( 0.0f );
41  radian3 = Degree( 180.0f );
42  DALI_TEST_EQUALS( float(radian3), Math::PI, 0.001f, TEST_LOCATION );
43  END_TEST;
44 }
45 
46 // Positive test case for comparison
48 {
49  // Comparison between radians
50  Radian radian0( Math::PI_2 );
51  Radian radian1( Math::PI_2 );
52  Radian radian2( Math::PI );
53 
54  DALI_TEST_CHECK( radian0 == radian1 );
55  DALI_TEST_CHECK( radian0 != radian2 );
56 
57  // Comparison between radian to degree
58  Radian radian3( Math::PI );
59  Radian radian4( Math::PI_2 );
60  Degree degree0( 180.0f );
61 
62  DALI_TEST_CHECK( radian3 == Radian(degree0) );
63  DALI_TEST_CHECK( radian4 != Radian(degree0) );
64 
65  // Comparison with float
66  Radian radian5( Math::PI_2 );
67 
68  DALI_TEST_CHECK( radian5 == Math::PI_2 );
69  DALI_TEST_CHECK( radian5 != Math::PI );
70 
71  END_TEST;
72 }
73 
74 
75 // test case for cast operators
77 {
78  Radian radian0( Math::PI );
79 
80  const float& value0( radian0.radian );
81  DALI_TEST_EQUALS( value0, Math::PI, 0.001f, TEST_LOCATION );
82 
83  radian0 = Math::PI_2;
84  DALI_TEST_EQUALS( value0, Math::PI_2, 0.001f, TEST_LOCATION );
85 
86  float value1( radian0 );
87  DALI_TEST_EQUALS( value1, Math::PI_2, 0.001f, TEST_LOCATION );
88 
89  radian0 = Math::PI;
90  DALI_TEST_EQUALS( float(radian0), Math::PI, 0.001f, TEST_LOCATION );
91  END_TEST;
92 }
93 
94 
96 {
99  Radian c(Math::PI);
100 
101  DALI_TEST_EQUALS( a == a, true, TEST_LOCATION );
102  DALI_TEST_EQUALS( a == b, true, TEST_LOCATION );
103  DALI_TEST_EQUALS( a == c, false, TEST_LOCATION );
104  DALI_TEST_EQUALS( Degree(c) == c, true, TEST_LOCATION );
105  END_TEST;
106 }
107 
109 {
112  Radian c(Math::PI);
113 
114  DALI_TEST_EQUALS( a != a, false, TEST_LOCATION );
115  DALI_TEST_EQUALS( a != b, false, TEST_LOCATION );
116  DALI_TEST_EQUALS( a != c, true, TEST_LOCATION );
117  DALI_TEST_EQUALS( Degree(a) != c, true, TEST_LOCATION );
118  END_TEST;
119 }
120 
122 {
125  Radian c(Math::PI);
126  Radian d(2.0f*Math::PI);
127  Radian e(-Math::PI);
128 
129  DALI_TEST_EQUALS(a < a, false, TEST_LOCATION);
130  DALI_TEST_EQUALS(a < b, true, TEST_LOCATION);
131  DALI_TEST_EQUALS(a < c, true, TEST_LOCATION);
132  DALI_TEST_EQUALS(a < d, true, TEST_LOCATION);
133  DALI_TEST_EQUALS(a < e, false, TEST_LOCATION);
134 
135  DALI_TEST_EQUALS(b < a, false, TEST_LOCATION);
136  DALI_TEST_EQUALS(b < b, false, TEST_LOCATION);
137  DALI_TEST_EQUALS(c < b, false, TEST_LOCATION);
138  DALI_TEST_EQUALS(d < b, false, TEST_LOCATION);
139  DALI_TEST_EQUALS(e < b, true, TEST_LOCATION);
140 
144 
148 
149  END_TEST;
150 }
Dali Docs Home
Read more about Dali