5 #include <dali-test-suite-utils.h>
10 void utc_dali_radian_startup(void)
12 test_return_value = TET_UNDEF;
15 void utc_dali_radian_cleanup(void)
17 test_return_value = TET_PASS;
21 // Positive test case for constructors
22 int UtcDaliRadianConstructors01(void)
24 TestApplication application;
26 // Default constructor, does not initialise the value
27 Radian radian0( 0.0f );
29 // Test float assignment operator
31 DALI_TEST_EQUALS( float(radian0), Math::PI, 0.001f, TEST_LOCATION );
33 // Constructor from float value
34 Radian radian1( Math::PI );
35 DALI_TEST_EQUALS( float(radian1), Math::PI, 0.001f, TEST_LOCATION );
37 // Constructor from a Degree
38 Radian radian2( Degree( 180.0f ) );
39 DALI_TEST_EQUALS( float(radian2), Math::PI, 0.001f, TEST_LOCATION );
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 );
48 // Positive test case for comparison
49 int UtcDaliRadianComparison01(void)
51 TestApplication application;
53 // Comparison between radians
54 Radian radian0( Math::PI_2 );
55 Radian radian1( Math::PI_2 );
56 Radian radian2( Math::PI );
58 DALI_TEST_CHECK( radian0 == radian1 );
59 DALI_TEST_CHECK( radian0 != radian2 );
61 // Comparison between radian to degree
62 Radian radian3( Math::PI );
63 Radian radian4( Math::PI_2 );
64 Degree degree0( 180.0f );
66 DALI_TEST_CHECK( radian3 == degree0 );
67 DALI_TEST_CHECK( radian4 != degree0 );
69 // Comparison with float
70 Radian radian5( Math::PI_2 );
72 DALI_TEST_CHECK( radian5 == Math::PI_2 );
73 DALI_TEST_CHECK( radian5 != Math::PI );
79 // test case for cast operators
80 int UtcDaliRadianCastOperators01(void)
82 TestApplication application; // Exceptions require TestApplication
84 Radian radian0( Math::PI );
86 const float& value0( radian0 );
87 DALI_TEST_EQUALS( value0, Math::PI, 0.001f, TEST_LOCATION );
90 DALI_TEST_EQUALS( value0, Math::PI_2, 0.001f, TEST_LOCATION );
92 float& value1( radian0 );
93 DALI_TEST_EQUALS( value1, Math::PI_2, 0.001f, TEST_LOCATION );
96 DALI_TEST_EQUALS( float(radian0), Math::PI, 0.001f, TEST_LOCATION );
101 int UtcDaliRadianCastOperatorEquals(void)
103 TestApplication application;
105 Radian a(Math::PI_2);
106 Radian b(Math::PI_2);
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);
115 int UtcDaliRadianCastOperatorNotEquals(void)
117 TestApplication application;
119 Radian a(Math::PI_2);
120 Radian b(Math::PI_2);
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);
129 int UtcDaliRadianCastOperatorLessThan(void)
131 TestApplication application;
133 Radian a(Math::PI_4);
134 Radian b(Math::PI_2);
136 Radian d(2.0f*Math::PI);
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);
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);
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);