+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
#include <iostream>
#include <stdlib.h>
// Default constructor, does not initialise the value
Degree degree0( 0.0f );
- // Test float assignment operator
- degree0 = 180.0f;
- DALI_TEST_EQUALS( float(degree0), 180.0f, 0.001f, TEST_LOCATION );
+ // Test assignment operator
+ degree0 = Degree(180.0f);
+ DALI_TEST_EQUALS( degree0.degree, 180.0f, 0.001f, TEST_LOCATION );
// Constructor from float value
Degree degree1( 180.0f );
- DALI_TEST_EQUALS( float(degree1), 180.0f, 0.001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( degree1.degree, 180.0f, 0.001f, TEST_LOCATION );
// Constructor from a Radian
Degree degree2( Radian( Math::PI ) );
- DALI_TEST_EQUALS( float(degree2), 180.0f, 0.001f, TEST_LOCATION );
+ DALI_TEST_EQUALS( degree2.degree, 180.0f, 0.001f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliDegreeCopyConstructor(void)
+{
+ Degree degree0( 90.0f );
+ Degree degree1( degree0 );
+ DALI_TEST_EQUALS( degree1.degree, 90.0f, 0.001f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliDegreeMoveConstructor(void)
+{
+ Degree degree0( 90.0f );
+ Degree degree1 = std::move( degree0 );
+ DALI_TEST_EQUALS( degree1.degree, 90.0f, 0.001f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliDegreeCopyAssignment(void)
+{
+ Degree degree0( 90.0f );
+ Degree degree1;
+ degree1 = degree0;
+ DALI_TEST_EQUALS( degree1.degree, 90.0f, 0.001f, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliDegreeMoveAssignment(void)
+{
+ Degree degree0( 90.0f );
+ Degree degree1;
+ degree1 = std::move( degree0 );
+ DALI_TEST_EQUALS( degree1.degree, 90.0f, 0.001f, TEST_LOCATION );
- // Assignment from Radian
- Degree degree3( 0.0f );
- degree3 = Radian( Math::PI );
- DALI_TEST_EQUALS( float(degree3), 180.0f, 0.001f, TEST_LOCATION );
END_TEST;
}
{
TestApplication application;
- // Comparison between radians
+ // Comparison between degrees
Degree degree0( 90.0f );
Degree degree1( 90.0f );
Degree degree2( 180.0f );
Degree degree4( 90.0f );
Radian radian0( Math::PI );
- DALI_TEST_CHECK( degree3 == radian0 );
- DALI_TEST_CHECK( degree4 != radian0 );
+ DALI_TEST_CHECK( degree3 == Degree(radian0) );
+ DALI_TEST_CHECK( degree4 != Degree(radian0) );
// Comparison with float
Degree degree5( 90.0f );
- DALI_TEST_CHECK( degree5 == 90.0f );
- DALI_TEST_CHECK( degree5 != 180.0f );
-
- END_TEST;
-}
-
-
-// test case for cast operators
-int UtcDaliDegreeCastOperators01(void)
-{
- TestApplication application; // Exceptions require TestApplication
-
- Degree degree0( 180.0f );
-
- const float& value0( degree0 );
- DALI_TEST_EQUALS( value0, 180.0f, 0.001f, TEST_LOCATION );
-
- degree0 = 90.0f;
- DALI_TEST_EQUALS( value0, 90.0f, 0.001f, TEST_LOCATION );
+ DALI_TEST_CHECK( degree5.degree == 90.0f );
+ DALI_TEST_CHECK( degree5.degree != 180.0f );
- float& value1( degree0 );
- DALI_TEST_EQUALS( value1, 90.0f, 0.001f, TEST_LOCATION );
-
- value1 = 180.0f;
- DALI_TEST_EQUALS( float(degree0), 180.0f, 0.001f, TEST_LOCATION );
END_TEST;
}
-
-
-int UtcDaliDegreeCastOperatorEquals(void)
+int UtcDaliDegreeOperatorEquals(void)
{
TestApplication application;
END_TEST;
}
-int UtcDaliDegreeCastOperatorNotEquals(void)
+int UtcDaliDegreeOperatorNotEquals(void)
{
TestApplication application;
DALI_TEST_EQUALS(a != c, true, TEST_LOCATION);
END_TEST;
}
-
-int UtcDaliDegreeCastOperatorLessThan(void)
-{
- TestApplication application;
-
- Degree a(45.0f);
- Degree b(90.0f);
- Degree c(180.0f);
- Degree d(360.0f);
- Degree e(-180.0f);
-
- DALI_TEST_EQUALS(a < a, false, TEST_LOCATION);
- DALI_TEST_EQUALS(a < b, true, TEST_LOCATION);
- DALI_TEST_EQUALS(a < c, true, TEST_LOCATION);
- DALI_TEST_EQUALS(a < d, true, TEST_LOCATION);
- DALI_TEST_EQUALS(a < e, false, TEST_LOCATION);
-
- DALI_TEST_EQUALS(b < a, false, TEST_LOCATION);
- DALI_TEST_EQUALS(b < b, false, TEST_LOCATION);
- DALI_TEST_EQUALS(c < b, false, TEST_LOCATION);
- DALI_TEST_EQUALS(d < b, false, TEST_LOCATION);
- DALI_TEST_EQUALS(e < b, true, TEST_LOCATION);
- END_TEST;
-}