Revert "[Tizen] Fix TC code conflict"
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Vector.cpp
index 5220315..c7fbe71 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -27,8 +27,21 @@ using namespace Dali;
 namespace
 {
 const Dali::VectorBase::SizeType ZERO(0);
+
+/// Compare a short with an int
+void DALI_TEST_EQUALS( short value1, int value2, const char* location )
+{
+  ::DALI_TEST_EQUALS< short >( value1, static_cast< short >( value2 ), location );
+}
+
+/// Compare a char with an int
+void DALI_TEST_EQUALS( char value1, int value2, const char* location )
+{
+  ::DALI_TEST_EQUALS< char >( value1, static_cast< char >( value2 ), location );
 }
 
+} // unnamed namespace
+
 int UtcDaliEmptyVectorInt(void)
 {
   tet_infoline("Testing Dali::Vector<int>");
@@ -717,7 +730,6 @@ int UtcDaliVectorAcidTest(void)
   int* ptr = NULL;
   for( unsigned int i = 0; i < acidCount; ++i )
   {
-    ++ptr;
     pairvector.PushBack( std::make_pair( i, i ) );
     doublevector.PushBack( (double)i );
     intptrvector.PushBack( (int*)ptr );
@@ -1255,6 +1267,104 @@ int UtcDaliVectorIntEraseRangeAssert(void)
   END_TEST;
 }
 
+int UtcDaliVectorVector2P(void)
+{
+  tet_infoline("Testing Dali::Vector< Vector2 >");
+
+  Vector< Vector2 > classvector;
+  DALI_TEST_EQUALS( ZERO, classvector.Count(), TEST_LOCATION );
+  DALI_TEST_EQUALS( ZERO, classvector.Capacity(), TEST_LOCATION );
+
+  classvector.PushBack( Vector2() );
+
+  DALI_TEST_EQUALS( 1u, classvector.Count(), TEST_LOCATION );
+  DALI_TEST_GREATER( classvector.Capacity(), ZERO, TEST_LOCATION );
+
+  classvector.PushBack( Vector2( 0.1f, 0.2f ) );
+
+  DALI_TEST_EQUALS( 2u, classvector.Count(), TEST_LOCATION );
+
+  DALI_TEST_EQUALS( Vector2(), classvector[ 0 ], TEST_LOCATION );
+  DALI_TEST_EQUALS( Vector2( 0.1f, 0.2f ), classvector[ 1 ], TEST_LOCATION );
+
+  tet_result(TET_PASS); // for now
+  END_TEST;
+}
+
+int UtcDaliVectorVector3P(void)
+{
+  tet_infoline("Testing Dali::Vector< Vector3 >");
+
+  Vector< Vector3 > classvector;
+  DALI_TEST_EQUALS( ZERO, classvector.Count(), TEST_LOCATION );
+  DALI_TEST_EQUALS( ZERO, classvector.Capacity(), TEST_LOCATION );
+
+  classvector.PushBack( Vector3() );
+
+  DALI_TEST_EQUALS( 1u, classvector.Count(), TEST_LOCATION );
+  DALI_TEST_GREATER( classvector.Capacity(), ZERO, TEST_LOCATION );
+
+  classvector.PushBack( Vector3( 0.1f, 0.2f, 0.3f ) );
+
+  DALI_TEST_EQUALS( 2u, classvector.Count(), TEST_LOCATION );
+
+  DALI_TEST_EQUALS( Vector3(), classvector[ 0 ], TEST_LOCATION );
+  DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), classvector[ 1 ], TEST_LOCATION );
+
+  tet_result(TET_PASS); // for now
+  END_TEST;
+}
+
+int UtcDaliVectorMatrixP(void)
+{
+  tet_infoline("Testing Dali::Vector< Matrix >");
+
+  Vector< Matrix > classvector;
+  DALI_TEST_EQUALS( ZERO, classvector.Count(), TEST_LOCATION );
+  DALI_TEST_EQUALS( ZERO, classvector.Capacity(), TEST_LOCATION );
+
+  classvector.PushBack( Matrix() );
+
+  DALI_TEST_EQUALS( 1u, classvector.Count(), TEST_LOCATION );
+  DALI_TEST_GREATER( classvector.Capacity(), ZERO, TEST_LOCATION );
+
+  classvector.PushBack( Matrix::IDENTITY );
+
+  DALI_TEST_EQUALS( 2u, classvector.Count(), TEST_LOCATION );
+
+  DALI_TEST_EQUALS( Matrix(), classvector[ 0 ], TEST_LOCATION );
+  DALI_TEST_EQUALS( Matrix::IDENTITY, classvector[ 1 ], TEST_LOCATION );
+
+  tet_result(TET_PASS); // for now
+  END_TEST;
+}
+
+int UtcDaliVectorCpp11ForP(void)
+{
+  Vector< Vector3 > classvector;
+  for ( auto i : classvector )
+  {
+    std::ignore = i;
+    tet_result( TET_FAIL );
+  }
+
+  classvector.PushBack( Vector3( 0.1f, 0.2f, 0.3f ) );
+  classvector.PushBack( Vector3( 0.1f, 0.2f, 0.3f ) );
+  classvector.PushBack( Vector3( 0.1f, 0.2f, 0.3f ) );
+
+  for ( auto i : classvector )
+  {
+    DALI_TEST_EQUALS( Vector3( 0.1f, 0.2f, 0.3f ), i, TEST_LOCATION );
+  }
+
+  END_TEST;
+}
+
+
+/*
+ * this does not compile at the moment
+ * Vector< Actor > classvector; this does not compile yet either
+ *
 namespace
 {
 
@@ -1275,13 +1385,11 @@ struct ComplexType
 
 } // anonymous namespace
 
-
-int UtcDaliVectorComplex(void)
+int UtcDaliVectorComplex( void)
 {
-  tet_infoline("Testing Dali::Vector< int* > exception handling");
+  tet_infoline("Testing Dali::Vector< ComplexType > ");
 
-  // this does not compile at the moment
-/*  Vector< ComplexType > classvector;
+  Vector< ComplexType > classvector;
   DALI_TEST_EQUALS( ZERO, classvector.Count(), TEST_LOCATION );
   DALI_TEST_EQUALS( ZERO, classvector.Capacity(), TEST_LOCATION );
 
@@ -1291,8 +1399,7 @@ int UtcDaliVectorComplex(void)
   DALI_TEST_EQUALS( true, gConstructorCalled, TEST_LOCATION );
   classvector.Clear();
   DALI_TEST_EQUALS( true, gDestructorCalled, TEST_LOCATION );
-*/
-//  Vector< Actor > classvector; this does not compile yet either
   tet_result(TET_PASS); // for now
   END_TEST;
 }
+*/