#define GOOD 0
#endif
+// ----------- a couple of globals make it easier ---------------------------------------
+static int ts_tests_driven = 0; // number of fail_if calls made == numer of tests driven
+
+// ---------------------------------------------------------------------------------------
+
+/*
+ Support test counting, reset and summary.
+*/
+static int test_get_attempted() {
+ return ts_tests_driven;
+}
+
+static void test_reset_attempted() {
+ ts_tests_driven = 0;
+}
+
+static void test_summary( int ecount, char* tag ) {
+ fprintf( stderr, "<SUMMARY> %s completed; %d total tests, %d passed, %d failed\n",
+ tag, ts_tests_driven, ts_tests_driven - ecount, ecount );
+}
+
/*
Snag the optional positional parameter at pp, return defval if not there.
*/
}
+/*
+ Assert like logic except these just record the test and return state so that we
+ can attempt all tests and not abort on the first failure as an assert would do.
+*/
static int fail_if_nil( void* p, char* what ) {
+ ts_tests_driven++;
+
if( !p ) {
fprintf( stderr, "<FAIL> %s: pointer was nil\n", what );
}
}
static int fail_not_nil( void* p, char* what ) {
+ ts_tests_driven++;
+
if( p ) {
fprintf( stderr, "<FAIL> %s: pointer was not nil\n", what );
}
}
static int fail_if_false( int bv, char* what ) {
+ ts_tests_driven++;
+
if( !bv ) {
fprintf( stderr, "<FAIL> %s: expected true, boolean test was false (%d)\n", what, bv );
}
}
static int fail_if_true( int bv, char* what ) {
+ ts_tests_driven++;
+
if( bv ) {
fprintf( stderr, "<FAIL> %s: expected false, boolean test was true (%d)\n", what, bv );
}
Same as fail_if_true(), but reads easier in the test code.
*/
static int fail_if( int bv, char* what ) {
+ ts_tests_driven++;
+
if( bv ) {
fprintf( stderr, "<FAIL> %s: expected false, boolean test was true (%d)\n", what, bv );
return bv ? BAD : GOOD;
}
+static int fail_pequal( void* a, void* b, char* what ) {
+ ts_tests_driven++;
+
+ if( a == b ) {
+ fprintf( stderr, "<FAIL> %s: pointers were not equal a=%p b=%p\n", what, a, b );
+ }
+ return a == b ? GOOD : BAD; // user may override good/bad so do NOT return a==b directly!
+}
+
+static int fail_not_pequal( void* a, void* b, char* what ) {
+ ts_tests_driven++;
+
+ if( a != b ) {
+ fprintf( stderr, "<FAIL> %s: pointers were not equal a=%p b=%p\n", what, a, b );
+ }
+ return a == b ? GOOD : BAD; // user may override good/bad so do NOT return a==b directly!
+}
+
static int fail_not_equal( int a, int b, char* what ) {
+ ts_tests_driven++;
+
if( a != b ) {
fprintf( stderr, "<FAIL> %s: values were not equal a=%d b=%d\n", what, a, b );
}
}
static int fail_if_equal( int a, int b, char* what ) {
+ ts_tests_driven++;
+
if( a == b ) {
fprintf( stderr, "<FAIL> %s values were equal a=%d b=%d\n", what, a, b );
}
}
static int fail_not_equalp( void* a, void* b, char* what ) {
+ ts_tests_driven++;
+
if( a != b ) {
fprintf( stderr, "<FAIL> %s: pointers were not equal a=%p b=%p\n", what, a, b );
}
}
static int fail_if_equalp( void* a, void* b, char* what ) {
+ ts_tests_driven++;
+
if( a == b ) {
fprintf( stderr, "<FAIL> %s pointers were equal a=%p b=%p\n", what, a, b );
}
/*
Build a message and populate both the msg buffer and the tranport header
- with mid, sid, and payload len. Tr_len causes that much space in the
+ with mid, sid, and payload len. Tr_len causes that much space in the
header for trace info to be reserved.
*/
static rmr_mbuf_t* mk_populated_msg( int alloc_len, int tr_len, int mtype, int sid, int plen ) {
}
+// end no dummy rmr
#endif
#endif