Jafar
|
Defines usefull macros when writting tests. More...
Defines usefull macros when writting tests.
Definition in file jafarTestMacro.hpp.
Go to the source code of this file.
Defines | |
#define | TEST_MACRO_EPSILON 1e-6 |
#define | JFR_CHECK(a) BOOST_CHECK_MESSAGE( (a) , (a) << " is not true"); |
This macro check if a value is true. | |
#define | JFR_CHECK_NULL(a) BOOST_CHECK_MESSAGE(fabs(a) < TEST_MACRO_EPSILON, (a) << " is not null"); |
This macro check if a value is nearly null ( fabs(a) < TEST_MACRO_EPSILON ) | |
#define | JFR_CHECK_EQUAL(a, b) BOOST_CHECK_MESSAGE( fabs((a) - (b)) < TEST_MACRO_EPSILON, (a) << " != " << (b )); |
This macro check that two values are nearly equal ( fabs(a - b) < TEST_MACRO_EPSILON ) | |
#define | JFR_CHECK_NOT_EQUAL(a, b) BOOST_CHECK_MESSAGE( fabs((a) - (b)) > TEST_MACRO_EPSILON, (a) << " == " << (b )); |
This macro check that two values aren't nearly equal ( fabs(a - b) > TEST_MACRO_EPSILON ) | |
#define | JFR_CHECK_STRICT_EQUAL(a, b) BOOST_CHECK_MESSAGE( (a) == (b), (a) << " != " << (b )); |
This macro check that two values are strictly equal ( a == b ) | |
#define | JFR_CHECK_STRICT_NOT_EQUAL(a, b) BOOST_CHECK_MESSAGE( (a) != (b), (a) << " == " << (b )); |
This macro check that two values are strictly different ( a != b ) | |
#define | JFR_CHECK_VEC_EQUAL(a, b) BOOST_CHECK_MESSAGE( (ublas::norm_2((a) - (b)) / (ublas::norm_2(a) * ublas::norm_2(b))) < TEST_MACRO_EPSILON, (a) << " != " << (b) ); |
This macro check that two vectors are nearly equal ( |a - b | / (|a|*|b|) < TEST_MACRO_EPSILON ) | |
#define | JFR_CHECK_VEC_NULL(a) BOOST_CHECK_MESSAGE( ublas::norm_2(a) < TEST_MACRO_EPSILON, (a) << " != 0 "); |
This macro check that a vector is nearly null ( |a| < TEST_MACRO_EPSILON) | |
#define | JFR_CHECK_VEC_NOT_EQUAL(a, b) BOOST_CHECK_MESSAGE( (ublas::norm_2((a) - (b)) / (ublas::norm_2(a) * ublas::norm_2(b)) ) > TEST_MACRO_EPSILON, (a) << " == " << (b) ); |
This macro check that two vectors aren't nearly equal ( |a - b | / (|a|*|b|) > TEST_MACRO_EPSILON ) | |
#define | JFR_CHECK_MAT_EQUAL(a, b) BOOST_CHECK_MESSAGE( jmath::ublasExtra::trace( ublas::prod( ((a) - (b)), ublas::trans((a)-(b)) ) ) < TEST_MACRO_EPSILON, (a) << " != " << (b) ); |
This macro check that two matrix are nearly equal ( tr( (a - b) * transpose(a-b) ) ) < TEST_MACRO_EPSILON) | |
#define | JFR_CHECK_MAT_NOT_EQUAL(a, b) BOOST_CHECK_MESSAGE( jmath::ublasExtra::trace( ublas::prod( ((a) - (b)), ublas::trans((a)-(b)) ) ) > TEST_MACRO_EPSILON, (a) << " == " << (b) ); |
This macro check that two matrix aren't nearly equal ( tr( (a - b) * transpose(a-b) ) ) > TEST_MACRO_EPSILON) | |
#define | JAFAR_AUTO_TEST_CASE_BEGIN(_TEST_NAME_) |
Use this macro instead of BOOST_AUTO_TEST_CASE to define a test in case you want jafar exception to be catched and display. | |
#define | JAFAR_AUTO_TEST_CASE_END() |
Finalize a test that was created with JAFAR_AUTO_TEST_CASE_BEGIN . |
#define JAFAR_AUTO_TEST_CASE_BEGIN | ( | _TEST_NAME_ | ) |
BOOST_AUTO_TEST_CASE( _TEST_NAME_ ) \ { \ try
Use this macro instead of BOOST_AUTO_TEST_CASE to define a test in case you want jafar exception to be catched and display.
You need to call JAFAR_AUTO_TEST_CASE_END after to finish the creation of the test case. Exceptions will be reported as Boost.Test classical error.
Definition at line 66 of file jafarTestMacro.hpp.
#define JAFAR_AUTO_TEST_CASE_END | ( | ) |
catch( jafar::kernel::JafarException ex ) \ { \ std::cout << "** jafar::kernel::JafarException: **" << std::endl; \ std::cout << ex << std::endl; \ BOOST_CHECK_MESSAGE(false, ex ); \ } \ catch (std::exception& ex) { \ std::cout << "** std::exception: **" << std::endl; \ std::cout << ex.what() << std::endl; \ BOOST_CHECK_MESSAGE(false, ex.what() ); \ } \ }
Finalize a test that was created with JAFAR_AUTO_TEST_CASE_BEGIN .
Definition at line 74 of file jafarTestMacro.hpp.
Generated on Wed Oct 15 2014 00:37:29 for Jafar by doxygen 1.7.6.1 |