1 #ifndef MOCKS_HEADER 2 #define MOCKS_HEADER 3 4 #ifdef __cplusplus 5 extern "C" { 6 #endif 7 8 #include <inttypes.h> 9 #include <stdarg.h> 10 #include <cgreen/reporter.h> 11 #include <cgreen/constraint.h> 12 13 #define mock(...) mock_(__func__, #__VA_ARGS__, (intptr_t)__VA_ARGS__ +0) 14 #define expect(f, ...) expect_(#f, __FILE__, __LINE__, (Constraint *)__VA_ARGS__ +0, (Constraint *)0) 15 #define always_expect(f, ...) always_expect_(#f, __FILE__, __LINE__, (Constraint *)__VA_ARGS__ +0, (Constraint *)0) 16 #define expect_never(f) expect_never_(#f, __FILE__, __LINE__) 17 #define will_return(f, r) will_return_(#f, (intptr_t)r) 18 #define always_return(f, r) always_return_(#f, (intptr_t)r) 19 #define will_respond(f, r, ...) will_return_(#f, (intptr_t)r); expect_(#f, __FILE__, __LINE__, (Constraint *)__VA_ARGS__ +0, (Constraint *)0) 20 #define always_respond(f, r, ...) always_return_(#f, (intptr_t)r); always_expect_(#f, __FILE__, __LINE__, (Constraint *)__VA_ARGS__ +0, (Constraint *)0) 21 22 intptr_t mock_(const char *function, const char *parameters, ...); 23 void expect_(const char *function, const char *test_file, int test_line, ...); 24 void always_expect_(const char *function, const char *test_file, int test_line, ...); 25 void expect_never_(const char *function, const char *test_file, int test_line); 26 void will_return_(const char *function, intptr_t result); 27 void always_return_(const char *function, intptr_t result); 28 void clear_mocks(); 29 void tally_mocks(TestReporter *reporter); 30 31 #ifdef __cplusplus 32 } 33 #endif 34 35 #endif 36