From b807c61834bacd2bfa43f0320fb25af18baede81 Mon Sep 17 00:00:00 2001 From: Kimmo Hoikka Date: Thu, 11 Jun 2015 13:40:03 +0100 Subject: [PATCH] Fix incorrect radian constant value and radian test cases, make failing tests debuggable (by not catching the exception) Change-Id: I150380290104d8ce442168ff3ce722b7f790d8f1 --- .../dali-test-suite-utils.cpp | 2 +- .../dali/dali-test-suite-utils/test-harness.cpp | 22 +++++++++------------ automated-tests/src/dali/utc-Dali-Quaternion.cpp | 2 +- automated-tests/src/dali/utc-Dali-Radian.cpp | 12 ----------- dali/public-api/math/radian.h | 23 +++++++++++----------- 5 files changed, 23 insertions(+), 38 deletions(-) diff --git a/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.cpp b/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.cpp index 938d585..7862cff 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.cpp +++ b/automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.cpp @@ -84,7 +84,7 @@ void DALI_TEST_EQUALS( const Matrix3& matrix1, const Matrix3& matrix2, const cha for (int i=0;i<9;++i) { - equivalent &= (m1[i] != m2[i]); + equivalent &= (fabsf(m1[i] - m2[i])< GetRangedEpsilon(m1[i], m2[i])); } if (!equivalent) diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-harness.cpp b/automated-tests/src/dali/dali-test-suite-utils/test-harness.cpp index 3fed0a2..475b62a 100644 --- a/automated-tests/src/dali/dali-test-suite-utils/test-harness.cpp +++ b/automated-tests/src/dali/dali-test-suite-utils/test-harness.cpp @@ -42,27 +42,23 @@ int RunTestCase( struct ::testcase_s& testCase ) { int result = EXIT_STATUS_TESTCASE_FAILED; - try +// dont want to catch exception as we want to be able to get +// gdb stack trace from the first error +// by default tests should all always pass with no exceptions + if( testCase.startup ) { - if( testCase.startup ) - { - testCase.startup(); - } - result = testCase.function(); - if( testCase.cleanup ) - { - testCase.cleanup(); - } + testCase.startup(); } - catch (...) + result = testCase.function(); + if( testCase.cleanup ) { - printf("Caught exception in test case.\n"); - result = EXIT_STATUS_TESTCASE_ABORTED; + testCase.cleanup(); } return result; } + int RunTestCaseInChildProcess( struct ::testcase_s& testCase, bool suppressOutput ) { int testResult = EXIT_STATUS_TESTCASE_FAILED; diff --git a/automated-tests/src/dali/utc-Dali-Quaternion.cpp b/automated-tests/src/dali/utc-Dali-Quaternion.cpp index 62d2f45..aac64e6 100644 --- a/automated-tests/src/dali/utc-Dali-Quaternion.cpp +++ b/automated-tests/src/dali/utc-Dali-Quaternion.cpp @@ -930,7 +930,7 @@ int UtcDaliQuaternionSlerpP02(void) // @ 50%, will be at M_PI/3 around z q = Quaternion::Slerp( q1, q2, 0.5f ); - Quaternion r( Dali::ANGLE_120, Vector3( 0.0f, 0.0f, 1.0f)); + Quaternion r( Dali::ANGLE_60, Vector3( 0.0f, 0.0f, 1.0f)); DALI_TEST_EQUALS( q, r, 0.001, TEST_LOCATION ); END_TEST; } diff --git a/automated-tests/src/dali/utc-Dali-Radian.cpp b/automated-tests/src/dali/utc-Dali-Radian.cpp index b869fd1..cfb3528 100644 --- a/automated-tests/src/dali/utc-Dali-Radian.cpp +++ b/automated-tests/src/dali/utc-Dali-Radian.cpp @@ -21,8 +21,6 @@ void utc_dali_radian_cleanup(void) // Positive test case for constructors int UtcDaliRadianConstructors01(void) { - TestApplication application; - // Default constructor, does not initialise the value Radian radian0( 0.0f ); @@ -48,8 +46,6 @@ int UtcDaliRadianConstructors01(void) // Positive test case for comparison int UtcDaliRadianComparison01(void) { - TestApplication application; - // Comparison between radians Radian radian0( Math::PI_2 ); Radian radian1( Math::PI_2 ); @@ -79,8 +75,6 @@ int UtcDaliRadianComparison01(void) // test case for cast operators int UtcDaliRadianCastOperators01(void) { - TestApplication application; // Exceptions require TestApplication - Radian radian0( Math::PI ); const float& value0( radian0.radian ); @@ -100,8 +94,6 @@ int UtcDaliRadianCastOperators01(void) int UtcDaliRadianCastOperatorEquals(void) { - TestApplication application; - Radian a(Math::PI_2); Radian b(Math::PI_2); Radian c(Math::PI); @@ -115,8 +107,6 @@ int UtcDaliRadianCastOperatorEquals(void) int UtcDaliRadianCastOperatorNotEquals(void) { - TestApplication application; - Radian a(Math::PI_2); Radian b(Math::PI_2); Radian c(Math::PI); @@ -130,8 +120,6 @@ int UtcDaliRadianCastOperatorNotEquals(void) int UtcDaliRadianCastOperatorLessThan(void) { - TestApplication application; - Radian a(Math::PI_4); Radian b(Math::PI_2); Radian c(Math::PI); diff --git a/dali/public-api/math/radian.h b/dali/public-api/math/radian.h index 6657851..8f0e961 100644 --- a/dali/public-api/math/radian.h +++ b/dali/public-api/math/radian.h @@ -102,17 +102,18 @@ public: // compiler generated destructor, copy constructor and assignment operators are ok as this class is POD // useful constant angles -static const Radian ANGLE_360 = Radian( Math::PI * 2.00f ); ///< 360 degree turn in radians -static const Radian ANGLE_315 = Radian( Math::PI * 1.75f ); ///< 315 degree turn in radians -static const Radian ANGLE_270 = Radian( Math::PI * 1.50f );///< 270 degree turn in radians -static const Radian ANGLE_225 = Radian( Math::PI * 1.25f ); ///< 225 degree turn in radians -static const Radian ANGLE_180 = Radian( Math::PI ); ///< 180 degree turn in radians -static const Radian ANGLE_135 = Radian( Math::PI * 0.75f ); ///< 135 degree turn in radians -static const Radian ANGLE_120 = Radian( Math::PI / 3.00f ); ///< 120 degree turn in radians -static const Radian ANGLE_90 = Radian( Math::PI_2 ); ///< 90 degree turn in radians -static const Radian ANGLE_45 = Radian( Math::PI_4 ); ///< 45 degree turn in radians -static const Radian ANGLE_30 = Radian( Math::PI / 6.00f ); ///< 30 degree turn in radians -static const Radian ANGLE_0 = Radian( 0.0f ); ///< 0 degree turn in radians +static const Radian ANGLE_360 = Radian( Math::PI * 2.f ); ///< 360 degree turn in radians +static const Radian ANGLE_315 = Radian( Math::PI * 1.75f ); ///< 315 degree turn in radians +static const Radian ANGLE_270 = Radian( Math::PI * 1.50f ); ///< 270 degree turn in radians +static const Radian ANGLE_225 = Radian( Math::PI * 1.25f ); ///< 225 degree turn in radians +static const Radian ANGLE_180 = Radian( Math::PI ); ///< 180 degree turn in radians +static const Radian ANGLE_135 = Radian( Math::PI * 0.75f ); ///< 135 degree turn in radians +static const Radian ANGLE_120 = Radian( Math::PI * 2.f/3.f ); ///< 120 degree turn in radians +static const Radian ANGLE_90 = Radian( Math::PI_2 ); ///< 90 degree turn in radians +static const Radian ANGLE_45 = Radian( Math::PI_4 ); ///< 45 degree turn in radians +static const Radian ANGLE_60 = Radian( Math::PI / 3.f ); ///< 60 degree turn in radians +static const Radian ANGLE_30 = Radian( Math::PI / 6.f ); ///< 30 degree turn in radians +static const Radian ANGLE_0 = Radian( 0.0f ); ///< 0 degree turn in radians /** * @brief Compare equality between two radians. -- 2.7.4