Jafar
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
jafarTestMacro.hpp
Go to the documentation of this file.
00001 /* $Id$ */
00002 
00008 #ifndef KERNEL_JAFAR_TEST_MACRO_HPP_
00009 #define KERNEL_JAFAR_TEST_MACRO_HPP_
00010 
00011 #define TEST_MACRO_EPSILON 1e-6
00012 
00016 #define JFR_CHECK(a) BOOST_CHECK_MESSAGE( (a) , (a) << " is not true");
00017 
00021 #define JFR_CHECK_NULL(a) BOOST_CHECK_MESSAGE(fabs(a) < TEST_MACRO_EPSILON, (a) << " is not null");
00022 
00025 #define JFR_CHECK_EQUAL(a,b) BOOST_CHECK_MESSAGE( fabs((a) - (b)) < TEST_MACRO_EPSILON, (a) << " != " << (b ));
00026 
00029 #define JFR_CHECK_NOT_EQUAL(a,b) BOOST_CHECK_MESSAGE( fabs((a) - (b)) > TEST_MACRO_EPSILON, (a) << " == " << (b ));
00030 
00033 #define JFR_CHECK_STRICT_EQUAL(a,b) BOOST_CHECK_MESSAGE( (a) == (b), (a) << " != " << (b ));
00034 
00037 #define JFR_CHECK_STRICT_NOT_EQUAL(a,b) BOOST_CHECK_MESSAGE( (a) != (b), (a) << " == " << (b ));
00038 
00041 #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) );
00042 
00045 #define JFR_CHECK_VEC_NULL(a) BOOST_CHECK_MESSAGE( ublas::norm_2(a) < TEST_MACRO_EPSILON, (a) << " != 0 ");
00046 
00049 #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) );
00050 
00053 #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) );
00054 
00057 #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) );
00058 
00066 #define JAFAR_AUTO_TEST_CASE_BEGIN( _TEST_NAME_ ) \
00067   BOOST_AUTO_TEST_CASE( _TEST_NAME_ ) \
00068   { \
00069     try
00070 
00074 #define JAFAR_AUTO_TEST_CASE_END() \
00075   catch( jafar::kernel::JafarException ex ) \
00076   { \
00077     std::cout << "** jafar::kernel::JafarException: **" << std::endl; \
00078     std::cout << ex << std::endl; \
00079     BOOST_CHECK_MESSAGE(false, ex ); \
00080   } \
00081   catch (std::exception& ex) { \
00082     std::cout << "** std::exception: **" << std::endl; \
00083     std::cout << ex.what() << std::endl; \
00084     BOOST_CHECK_MESSAGE(false, ex.what() ); \
00085   } \
00086 }
00087 
00088 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Wed Oct 15 2014 00:37:24 for Jafar by doxygen 1.7.6.1
LAAS-CNRS