Dali 3D User Interface Engine
Classes | Macros | Functions | Variables
dali-test-suite-utils.h File Reference
#include <cstdarg>
#include <iostream>
#include <dali/public-api/dali-core.h>
#include "test-application.h"
Include dependency graph for dali-test-suite-utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ConstraintAppliedCheck
 
struct  DefaultFunctionCoverage< T >
 A Helper to test default functions. More...
 

Macros

#define STRINGIZE_I(text)   #text
 
#define STRINGIZE(text)   STRINGIZE_I(text)
 
#define TOKENPASTE(x, y)   x y
 
#define TOKENPASTE2(x, y)   TOKENPASTE( x, y )
 
#define TEST_LOCATION   TOKENPASTE2( "Test failed in ", TOKENPASTE2( __FILE__, TOKENPASTE2( ", line ", STRINGIZE(__LINE__) ) ) )
 
#define TET_UNDEF   2
 
#define TET_FAIL   1
 
#define TET_PASS   0
 
#define END_TEST   return ((test_return_value>0)?1:0)
 
#define DALI_TEST_CHECK(condition)
 DALI_TEST_CHECK is a wrapper for tet_result. More...
 

Functions

void tet_infoline (const char *str)
 
void tet_printf (const char *format,...)
 
void tet_result (int value)
 
template<typename Type >
bool CompareType (Type value1, Type value2, float epsilon)
 
template<>
bool CompareType< float > (float value1, float value2, float epsilon)
 A helper for fuzzy-comparing Vector2 objects. More...
 
template<>
bool CompareType< Vector2 > (Vector2 vector1, Vector2 vector2, float epsilon)
 A helper for fuzzy-comparing Vector2 objects. More...
 
template<>
bool CompareType< Vector3 > (Vector3 vector1, Vector3 vector2, float epsilon)
 A helper for fuzzy-comparing Vector3 objects. More...
 
template<>
bool CompareType< Vector4 > (Vector4 vector1, Vector4 vector2, float epsilon)
 A helper for fuzzy-comparing Vector4 objects. More...
 
template<>
bool CompareType< Quaternion > (Quaternion q1, Quaternion q2, float epsilon)
 
template<>
bool CompareType< Radian > (Radian q1, Radian q2, float epsilon)
 
template<>
bool CompareType< Degree > (Degree q1, Degree q2, float epsilon)
 
bool operator== (TimePeriod a, TimePeriod b)
 
std::ostream & operator<< (std::ostream &ostream, TimePeriod value)
 
std::ostream & operator<< (std::ostream &ostream, Radian angle)
 
std::ostream & operator<< (std::ostream &ostream, Degree angle)
 
template<typename Type >
void DALI_TEST_EQUALS (Type value1, Type value2, const char *location)
 Test whether two values are equal. More...
 
template<typename Type >
void DALI_TEST_EQUALS (Type value1, Type value2, float epsilon, const char *location)
 
template<>
void DALI_TEST_EQUALS< TimePeriod > (TimePeriod value1, TimePeriod value2, float epsilon, const char *location)
 Test whether two TimePeriods are within a certain distance of each other. More...
 
void DALI_TEST_EQUALS (const BaseHandle &baseHandle1, const BaseHandle &baseHandle2, const char *location)
 Test whether two base handles are equal. More...
 
void DALI_TEST_EQUALS (const size_t value1, const unsigned int value2, const char *location)
 Test whether a size_t value and an unsigned int are equal. More...
 
void DALI_TEST_EQUALS (const unsigned int value1, const size_t value2, const char *location)
 Test whether an unsigned int and a size_t value and are equal. More...
 
void DALI_TEST_EQUALS (const Matrix3 &matrix1, const Matrix3 &matrix2, const char *location)
 Test whether two Matrix3 objects are equal. More...
 
void DALI_TEST_EQUALS (const Matrix3 &matrix1, const Matrix3 &matrix2, float epsilon, const char *location)
 Test whether two Matrix3 objects are equal (fuzzy compare). More...
 
void DALI_TEST_EQUALS (const Matrix &matrix1, const Matrix &matrix2, const char *location)
 Test whether two Matrix objects are equal. More...
 
void DALI_TEST_EQUALS (const Matrix &matrix1, const Matrix &matrix2, float epsilon, const char *location)
 Test whether two Matrix objects are equal (fuzzy-compare). More...
 
template<>
void DALI_TEST_EQUALS< const char * > (const char *str1, const char *str2, const char *location)
 Test whether two strings are equal. More...
 
template<>
void DALI_TEST_EQUALS< const std::string & > (const std::string &str1, const std::string &str2, const char *location)
 Test whether two strings are equal. More...
 
void DALI_TEST_EQUALS (const std::string &str1, const char *str2, const char *location)
 Test whether two strings are equal. More...
 
void DALI_TEST_EQUALS (const char *str1, const std::string &str2, const char *location)
 Test whether two strings are equal. More...
 
template<typename T >
void DALI_TEST_GREATER (T value1, T value2, const char *location)
 Test whether one unsigned integer value is greater than another. More...
 
void DALI_TEST_ASSERT (DaliException &e, std::string conditionSubString, const char *location)
 Test whether the assertion condition that failed and thus triggered the exception e contained a given substring. More...
 
void DALI_TEST_PRINT_ASSERT (DaliException &e)
 Print the assert. More...
 
BufferImage CreateBufferImage ()
 

Variables

int test_return_value
 

Macro Definition Documentation

#define DALI_TEST_CHECK (   condition)
Value:
if ( (condition) ) \
{ \
tet_result(TET_PASS); \
} \
else \
{ \
fprintf(stderr, "%s Failed in %s at line %d\n", __PRETTY_FUNCTION__, __FILE__, __LINE__); \
tet_result(TET_FAIL); \
throw("TET_FAIL"); \
}

DALI_TEST_CHECK is a wrapper for tet_result.

If the condition evaluates to false, the test is stopped.

Parameters
[in]Theboolean expression to check

Definition at line 63 of file dali-test-suite-utils.h.

Referenced by DefaultFunctionCoverage< T >::DefaultFunctionCoverage().

#define END_TEST   return ((test_return_value>0)?1:0)

Definition at line 52 of file dali-test-suite-utils.h.

#define STRINGIZE (   text)    STRINGIZE_I(text)

Definition at line 36 of file dali-test-suite-utils.h.

#define STRINGIZE_I (   text)    #text

Definition at line 35 of file dali-test-suite-utils.h.

#define TEST_LOCATION   TOKENPASTE2( "Test failed in ", TOKENPASTE2( __FILE__, TOKENPASTE2( ", line ", STRINGIZE(__LINE__) ) ) )

Definition at line 42 of file dali-test-suite-utils.h.

#define TET_FAIL   1
#define TET_PASS   0
#define TET_UNDEF   2

Definition at line 44 of file dali-test-suite-utils.h.

#define TOKENPASTE (   x,
 
)    x y

Definition at line 40 of file dali-test-suite-utils.h.

#define TOKENPASTE2 (   x,
 
)    TOKENPASTE( x, y )

Definition at line 41 of file dali-test-suite-utils.h.

Function Documentation

template<typename Type >
bool CompareType ( Type  value1,
Type  value2,
float  epsilon 
)
inline
template<>
bool CompareType< Degree > ( Degree  q1,
Degree  q2,
float  epsilon 
)
inline

Definition at line 150 of file dali-test-suite-utils.h.

References CompareType< float >().

Here is the call graph for this function:

template<>
bool CompareType< float > ( float  value1,
float  value2,
float  epsilon 
)
inline

A helper for fuzzy-comparing Vector2 objects.

Parameters
[in]vector1the first object
[in]vector2the second object
[in]epsilondifference threshold
Returns
true if difference is smaller than epsilon threshold, false otherwise

Definition at line 86 of file dali-test-suite-utils.h.

References Dali::anonymous_namespace{compile-time-math.cpp}::value1, and Dali::anonymous_namespace{compile-time-math.cpp}::value2.

template<>
bool CompareType< Quaternion > ( Quaternion  q1,
Quaternion  q2,
float  epsilon 
)
inline

Definition at line 137 of file dali-test-suite-utils.h.

References CompareType< Vector4 >(), and Dali::Quaternion::mVector.

Here is the call graph for this function:

template<>
bool CompareType< Radian > ( Radian  q1,
Radian  q2,
float  epsilon 
)
inline

Definition at line 144 of file dali-test-suite-utils.h.

References CompareType< float >().

Here is the call graph for this function:

template<>
bool CompareType< Vector2 > ( Vector2  vector1,
Vector2  vector2,
float  epsilon 
)
inline

A helper for fuzzy-comparing Vector2 objects.

Parameters
[in]vector1the first object
[in]vector2the second object
[in]epsilondifference threshold
Returns
true if difference is smaller than epsilon threshold, false otherwise

Definition at line 99 of file dali-test-suite-utils.h.

template<>
bool CompareType< Vector3 > ( Vector3  vector1,
Vector3  vector2,
float  epsilon 
)
inline

A helper for fuzzy-comparing Vector3 objects.

Parameters
[in]vector1the first object
[in]vector2the second object
[in]epsilondifference threshold
Returns
true if difference is smaller than epsilon threshold, false otherwise

Definition at line 112 of file dali-test-suite-utils.h.

template<>
bool CompareType< Vector4 > ( Vector4  vector1,
Vector4  vector2,
float  epsilon 
)
inline

A helper for fuzzy-comparing Vector4 objects.

Parameters
[in]vector1the first object
[in]vector2the second object
[in]epsilondifference threshold
Returns
true if difference is smaller than epsilon threshold, false otherwise

Definition at line 128 of file dali-test-suite-utils.h.

BufferImage CreateBufferImage ( )

Definition at line 302 of file dali-test-suite-utils.cpp.

void DALI_TEST_ASSERT ( DaliException e,
std::string  conditionSubString,
const char *  location 
)

Test whether the assertion condition that failed and thus triggered the exception e contained a given substring.

Parameters
[in]eThe exception that we expect was fired by a runtime assertion failure.
[in]conditionSubStringThe text that we expect to be present in an assertion which triggered the exception.
[in]locationThe TEST_LOCATION macro should be used here.

Definition at line 247 of file dali-test-suite-utils.cpp.

template<typename Type >
void DALI_TEST_EQUALS ( Type  value1,
Type  value2,
const char *  location 
)
inline

Test whether two values are equal.

Parameters
[in]value1The first value
[in]value2The second value
[in]locationThe TEST_LOCATION macro should be used here

Definition at line 167 of file dali-test-suite-utils.h.

References TET_FAIL, TET_PASS, and tet_result().

Here is the call graph for this function:

template<typename Type >
void DALI_TEST_EQUALS ( Type  value1,
Type  value2,
float  epsilon,
const char *  location 
)
inline

Definition at line 183 of file dali-test-suite-utils.h.

References TET_FAIL, TET_PASS, and tet_result().

Here is the call graph for this function:

void DALI_TEST_EQUALS ( const BaseHandle baseHandle1,
const BaseHandle baseHandle2,
const char *  location 
)

Test whether two base handles are equal.

Parameters
[in]baseHandle1The first value
[in]baseHandle2The second value
[in]locationThe TEST_LOCATION macro should be used here

Definition at line 79 of file dali-test-suite-utils.cpp.

void DALI_TEST_EQUALS ( const size_t  value1,
const unsigned int  value2,
const char *  location 
)

Test whether a size_t value and an unsigned int are equal.

Parameters
[in]value1The first value
[in]value2The second value
[in]locationThe TEST_LOCATION macro should be used here

Definition at line 84 of file dali-test-suite-utils.cpp.

void DALI_TEST_EQUALS ( const unsigned int  value1,
const size_t  value2,
const char *  location 
)

Test whether an unsigned int and a size_t value and are equal.

Parameters
[in]value1The first value
[in]value2The second value
[in]locationThe TEST_LOCATION macro should be used here

Definition at line 89 of file dali-test-suite-utils.cpp.

void DALI_TEST_EQUALS ( const Matrix3 matrix1,
const Matrix3 matrix2,
const char *  location 
)

Test whether two Matrix3 objects are equal.

Parameters
[in]matrix1The first object
[in]matrix2The second object
[in]locationThe TEST_LOCATION macro should be used here

Definition at line 94 of file dali-test-suite-utils.cpp.

void DALI_TEST_EQUALS ( const Matrix3 matrix1,
const Matrix3 matrix2,
float  epsilon,
const char *  location 
)

Test whether two Matrix3 objects are equal (fuzzy compare).

Parameters
[in]matrix1The first object
[in]matrix2The second object
[in]epsilonThe epsilon to use for comparison
[in]locationThe TEST_LOCATION macro should be used here

Definition at line 127 of file dali-test-suite-utils.cpp.

void DALI_TEST_EQUALS ( const Matrix matrix1,
const Matrix matrix2,
const char *  location 
)

Test whether two Matrix objects are equal.

Parameters
[in]matrix1The first object
[in]matrix2The second object
[in]locationThe TEST_LOCATION macro should be used here

Definition at line 157 of file dali-test-suite-utils.cpp.

void DALI_TEST_EQUALS ( const Matrix matrix1,
const Matrix matrix2,
float  epsilon,
const char *  location 
)

Test whether two Matrix objects are equal (fuzzy-compare).

Parameters
[in]matrix1The first object
[in]matrix2The second object
[in]locationThe TEST_LOCATION macro should be used here

Definition at line 193 of file dali-test-suite-utils.cpp.

void DALI_TEST_EQUALS ( const std::string &  str1,
const char *  str2,
const char *  location 
)

Test whether two strings are equal.

Parameters
[in]str1The first string
[in]str2The second string
[in]locationThe TEST_LOCATION macro should be used here

Definition at line 231 of file dali-test-suite-utils.cpp.

void DALI_TEST_EQUALS ( const char *  str1,
const std::string &  str2,
const char *  location 
)

Test whether two strings are equal.

Parameters
[in]str1The first string
[in]str2The second string
[in]locationThe TEST_LOCATION macro should be used here

Definition at line 242 of file dali-test-suite-utils.cpp.

template<>
void DALI_TEST_EQUALS< const char * > ( const char *  str1,
const char *  str2,
const char *  location 
)
inline

Test whether two strings are equal.

Parameters
[in]str1The first string
[in]str2The second string
[in]locationThe TEST_LOCATION macro should be used here

Definition at line 287 of file dali-test-suite-utils.h.

References TET_FAIL, TET_PASS, and tet_result().

Here is the call graph for this function:

template<>
void DALI_TEST_EQUALS< const std::string & > ( const std::string &  str1,
const std::string &  str2,
const char *  location 
)
inline

Test whether two strings are equal.

Parameters
[in]str1The first string
[in]str2The second string
[in]locationThe TEST_LOCATION macro should be used here

Definition at line 307 of file dali-test-suite-utils.h.

References DALI_TEST_EQUALS().

Here is the call graph for this function:

template<>
void DALI_TEST_EQUALS< TimePeriod > ( TimePeriod  value1,
TimePeriod  value2,
float  epsilon,
const char *  location 
)
inline

Test whether two TimePeriods are within a certain distance of each other.

Parameters
[in]value1The first value
[in]value2The second value
[in]epsilonThe values must be within this distance of each other
[in]locationThe TEST_LOCATION macro should be used here

Definition at line 206 of file dali-test-suite-utils.h.

References TET_FAIL, TET_PASS, tet_result(), Dali::anonymous_namespace{compile-time-math.cpp}::value1, and Dali::anonymous_namespace{compile-time-math.cpp}::value2.

Here is the call graph for this function:

template<typename T >
void DALI_TEST_GREATER ( value1,
value2,
const char *  location 
)

Test whether one unsigned integer value is greater than another.

Test succeeds if value1 > value2

Parameters
[in]value1The first value
[in]value2The second value
[in]locationThe TEST_LOCATION macro should be used here

Definition at line 336 of file dali-test-suite-utils.h.

References TET_FAIL, TET_PASS, and tet_result().

Here is the call graph for this function:

void DALI_TEST_PRINT_ASSERT ( DaliException e)
inline

Print the assert.

Parameters
[in]eThe exception that we expect was fired by a runtime assertion failure.

Definition at line 363 of file dali-test-suite-utils.h.

References Dali::DaliException::condition, Dali::DaliException::location, and tet_printf().

Here is the call graph for this function:

std::ostream& operator<< ( std::ostream &  ostream,
TimePeriod  value 
)

Definition at line 62 of file dali-test-suite-utils.cpp.

std::ostream& operator<< ( std::ostream &  ostream,
Radian  angle 
)

Definition at line 67 of file dali-test-suite-utils.cpp.

std::ostream& operator<< ( std::ostream &  ostream,
Degree  angle 
)

Definition at line 73 of file dali-test-suite-utils.cpp.

bool operator== ( TimePeriod  a,
TimePeriod  b 
)

Definition at line 57 of file dali-test-suite-utils.cpp.

void tet_infoline ( const char *  str)

Definition at line 44 of file dali-test-suite-utils.cpp.

void tet_printf ( const char *  format,
  ... 
)

Definition at line 49 of file dali-test-suite-utils.cpp.

void tet_result ( int  value)

Definition at line 31 of file dali-test-suite-utils.cpp.

Variable Documentation

int test_return_value

Definition at line 29 of file dali-test-suite-utils.cpp.

Dali Docs Home
Read more about Dali