4 #include <dali/public-api/dali-core.h>
5 #include <dali-test-suite-utils.h>
9 void utc_dali_degree_startup(void)
11 test_return_value = TET_UNDEF;
14 void utc_dali_degree_cleanup(void)
16 test_return_value = TET_PASS;
20 // Positive test case for constructors
21 int UtcDaliDegreeConstructors01(void)
23 TestApplication application;
25 // Default constructor, does not initialise the value
26 Degree degree0( 0.0f );
28 // Test float assignment operator
30 DALI_TEST_EQUALS( float(degree0), 180.0f, 0.001f, TEST_LOCATION );
32 // Constructor from float value
33 Degree degree1( 180.0f );
34 DALI_TEST_EQUALS( float(degree1), 180.0f, 0.001f, TEST_LOCATION );
36 // Constructor from a Radian
37 Degree degree2( Radian( Math::PI ) );
38 DALI_TEST_EQUALS( float(degree2), 180.0f, 0.001f, TEST_LOCATION );
40 // Assignment from Radian
41 Degree degree3( 0.0f );
42 degree3 = Radian( Math::PI );
43 DALI_TEST_EQUALS( float(degree3), 180.0f, 0.001f, TEST_LOCATION );
47 // Positive test case for comparison
48 int UtcDaliDegreeComparison01(void)
50 TestApplication application;
52 // Comparison between radians
53 Degree degree0( 90.0f );
54 Degree degree1( 90.0f );
55 Degree degree2( 180.0f );
57 DALI_TEST_CHECK( degree0 == degree1 );
58 DALI_TEST_CHECK( degree0 != degree2 );
60 // Comparison between radian to degree
61 Degree degree3( 180.0f );
62 Degree degree4( 90.0f );
63 Radian radian0( Math::PI );
65 DALI_TEST_CHECK( degree3 == radian0 );
66 DALI_TEST_CHECK( degree4 != radian0 );
68 // Comparison with float
69 Degree degree5( 90.0f );
71 DALI_TEST_CHECK( degree5 == 90.0f );
72 DALI_TEST_CHECK( degree5 != 180.0f );
78 // test case for cast operators
79 int UtcDaliDegreeCastOperators01(void)
81 TestApplication application; // Exceptions require TestApplication
83 Degree degree0( 180.0f );
85 const float& value0( degree0 );
86 DALI_TEST_EQUALS( value0, 180.0f, 0.001f, TEST_LOCATION );
89 DALI_TEST_EQUALS( value0, 90.0f, 0.001f, TEST_LOCATION );
91 float& value1( degree0 );
92 DALI_TEST_EQUALS( value1, 90.0f, 0.001f, TEST_LOCATION );
95 DALI_TEST_EQUALS( float(degree0), 180.0f, 0.001f, TEST_LOCATION );
101 int UtcDaliDegreeCastOperatorEquals(void)
103 TestApplication application;
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 UtcDaliDegreeCastOperatorNotEquals(void)
117 TestApplication application;
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 UtcDaliDegreeCastOperatorLessThan(void)
131 TestApplication application;
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);