/** * utest.h * Sam's favorite unit testing macros. Make sure to link your file * with utest.o. */ #ifndef __UTEST_H__ #define __UTEST_H__ // +--------+--------------------------------------------------------- // | Macros | // +--------+ #define CHECK_INT(COMMAND, EXPECTED) check_int (#COMMAND, COMMAND, EXPECTED) #define CHECK_PTR(COMMAND, EXPECTED) check_ptr (#COMMAND, COMMAND, EXPECTED) #define CHECK_STR(COMMAND, EXPECTED) check_str (#COMMAND, COMMAND, EXPECTED) // +---------+-------------------------------------------------------- // | Globals | // +---------+ /** * A count of tests conducted. */ extern int tests; /** * A count of errors encountered. */ extern int errors; // +-----------+------------------------------------------------------ // | Functions | // +-----------+ void check_int (char *command, int result, int expected); void check_ptr (char *command, void *result, void *expected); void check_str (char *command, char *result, char *expected); #endif // __UTEST_H__