Adding 'override', removing 'virtual' from overriding functions' declarations in...
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Degree.cpp
index be2cbd0..eb64d9c 100644 (file)
@@ -1,3 +1,20 @@
+/*
+ * 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>
@@ -25,22 +42,56 @@ int UtcDaliDegreeConstructors01(void)
   // 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;
 }
 
@@ -49,7 +100,7 @@ int UtcDaliDegreeComparison01(void)
 {
   TestApplication application;
 
-  // Comparison between radians
+  // Comparison between degrees
   Degree degree0( 90.0f );
   Degree degree1( 90.0f );
   Degree degree2( 180.0f );
@@ -62,43 +113,19 @@ int UtcDaliDegreeComparison01(void)
   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;
 
@@ -112,7 +139,7 @@ int UtcDaliDegreeCastOperatorEquals(void)
   END_TEST;
 }
 
-int UtcDaliDegreeCastOperatorNotEquals(void)
+int UtcDaliDegreeOperatorNotEquals(void)
 {
   TestApplication application;
 
@@ -125,27 +152,3 @@ int UtcDaliDegreeCastOperatorNotEquals(void)
   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;
-}