Back to home page

Enduro/X

 
 

    


0001 #ifndef MOCKS_HEADER
0002 #define MOCKS_HEADER
0003 
0004 #include <cgreen/internal/mocks_internal.h>
0005 #include <cgreen/constraint.h>
0006 #include <cgreen/reporter.h>
0007 
0008 #ifdef __cplusplus
0009 namespace cgreen {
0010     extern "C" {
0011 #endif
0012 
0013 /* Program the mocked functions to expect (or not) calls when parameters match constraints...
0014 
0015    expect(<function>, when(<parameter>, <constraint>), ...
0016 
0017    expect(<function>, when(<parameter>, <constraint>), will_return(<value>));
0018 */
0019 #define expect(f, ...) expect_(get_test_reporter(), #f, __FILE__, __LINE__, (Constraint *)__VA_ARGS__ +0, (Constraint *)0)
0020 #define always_expect(f, ...) always_expect_(get_test_reporter(), #f, __FILE__, __LINE__, (Constraint *)__VA_ARGS__ +0, (Constraint *)0)
0021 #define never_expect(f, ...) never_expect_(get_test_reporter(), #f, __FILE__, __LINE__, (Constraint *)__VA_ARGS__ +0, (Constraint *)0)
0022 
0023 
0024 #ifdef _MSC_VER
0025 // another workaround for fundamental variadic macro deficiencies in Visual C++ 2012
0026 #define mock(...) PP_NARG(__VA_ARGS__)(get_test_reporter(), __func__, __FILE__, __LINE__, #__VA_ARGS__ "", __VA_ARGS__)
0027 #else
0028 #define mock(...) PP_NARG(__VA_ARGS__)(get_test_reporter(), __func__, __FILE__, __LINE__, #__VA_ARGS__ "", __VA_ARGS__ +0)
0029 #endif
0030 
0031 #define when(parameter, constraint) when_(#parameter, constraint)
0032 
0033 /* Make Cgreen mocks strict, loose or learning */
0034 typedef enum { strict_mocks = 0, loose_mocks = 1, learning_mocks = 2 } CgreenMockMode;
0035 void cgreen_mocks_are(CgreenMockMode);
0036 
0037 extern const int UNLIMITED_TIME_TO_LIVE;
0038 
0039 #ifdef __cplusplus
0040     }
0041 }
0042 #endif
0043 
0044 #endif