trick/trick_source/sim_services/UnitTest/include/trick_tests.h
Alex Lin 14a75508a3 Cleaning up once include variables and copyright cleanup.
Changed all header file once include variables to follow the same naming
convention and not start with any underscores.  Also deleted old
incorrect copyright notices.  Also removed $Id: tags from all files.

Fixes #14.  Fixes #22.
2015-03-23 16:03:14 -05:00

96 lines
3.1 KiB
C

#include <math.h>
#ifdef TRICK_UNIT_TEST
#define TRICK_EXPECT_TRUE( a , test_suite , test_case) \
if ( a ) { \
add_test_result( test_suite , test_case , "" ) ; \
} else { \
add_test_result( test_suite , test_case , "TRICK_EXPECT_TRUE failed" ) ; \
}
#define TRICK_EXPECT_FALSE( a , test_suite , test_case) \
if ( !(a) ) { \
add_test_result( test_suite , test_case , "" ) ; \
} else { \
add_test_result( test_suite , test_case , "TRICK_EXPECT_FALSE failed" ) ; \
}
#define TRICK_EXPECT_EQ( a , b , test_suite , test_case) \
if ( a == b ) { \
add_test_result( test_suite , test_case , "" ) ; \
} else { \
add_test_result( test_suite , test_case , "TRICK_EXPECT_EQ failed" ) ; \
}
#define TRICK_EXPECT_NE( a , b , test_suite , test_case) \
if ( a != b ) { \
add_test_result( test_suite , test_case , "" ) ; \
} else { \
add_test_result( test_suite , test_case , "TRICK_EXPECT_NE failed" ) ; \
}
#define TRICK_EXPECT_LT( a , b , test_suite , test_case) \
if ( a < b ) { \
add_test_result( test_suite , test_case , "" ) ; \
} else { \
add_test_result( test_suite , test_case , "TRICK_EXPECT_LT failed" ) ; \
}
#define TRICK_EXPECT_LE( a , b , test_suite , test_case) \
if ( a <= b ) { \
add_test_result( test_suite , test_case , "" ) ; \
} else { \
add_test_result( test_suite , test_case , "TRICK_EXPECT_LE failed" ) ; \
}
#define TRICK_EXPECT_GT( a , b , test_suite , test_case) \
if ( a > b ) { \
add_test_result( test_suite , test_case , "" ) ; \
} else { \
add_test_result( test_suite , test_case , "TRICK_EXPECT_GT failed" ) ; \
}
#define TRICK_EXPECT_GE( a , b , test_suite , test_case) \
if ( a >= b ) { \
add_test_result( test_suite , test_case , "" ) ; \
} else { \
add_test_result( test_suite , test_case , "TRICK_EXPECT_GE failed" ) ; \
}
#define TRICK_EXPECT_NEAR( a , b , tol , test_suite , test_case) \
if ( fabs ( a - b ) < tol ) { \
add_test_result( test_suite , test_case , "" ) ; \
} else { \
add_test_result( test_suite , test_case , "floating point not within tolerance" ) ; \
}
#else
#define TRICK_EXPECT_TRUE( a , test_suite , test_case)
#define TRICK_EXPECT_FALSE( a , test_suite , test_case)
#define TRICK_EXPECT_EQ( a , test_suite , test_case)
#define TRICK_EXPECT_NE( a , test_suite , test_case)
#define TRICK_EXPECT_LT( a , test_suite , test_case)
#define TRICK_EXPECT_LE( a , test_suite , test_case)
#define TRICK_EXPECT_GT( a , test_suite , test_case)
#define TRICK_EXPECT_GE( a , test_suite , test_case)
#define TRICK_EXPECT_NEAR( a , b , tol , test_suite , test_case)
#endif
#ifdef __cplusplus
extern "C" {
#endif
int trick_test_add_parent(const char * in_test_suite_name,
const char * in_test_case,
const char * par_num ) ;
int add_test_result( const char * in_test_suite_name ,
const char * in_test_case ,
const char * in_failure_string ) ;
int call_write_output() ;
#ifdef __cplusplus
}
#endif