Back to home page

Enduro/X

 
 

    


0001 #ifndef ASSERTIONS_INTERNAL_HEADER
0002 #define ASSERTIONS_INTERNAL_HEADER
0003 
0004 #include <cgreen/string_comparison.h>
0005 
0006 #ifdef __cplusplus
0007 #include "cpp_assertions.h"
0008 #else
0009 #include "c_assertions.h"
0010 #endif
0011 
0012 
0013 #ifdef __cplusplus
0014 namespace cgreen {
0015     extern "C" {
0016 #endif
0017 
0018 /* At the cost of duplication, these macros now give more descriptive error messages */
0019 #define ASSERT_THAT_VA_NUM_ARGS(...) ASSERT_THAT_VA_NUM_ARGS_IMPL_((__VA_ARGS__, _CALLED_WITH_TOO_MANY_ARGS,  _constraint,  _expression))
0020 #define ASSERT_THAT_VA_NUM_ARGS_IMPL_(tuple) ASSERT_THAT_VA_NUM_ARGS_IMPL tuple
0021 
0022 #define ASSERT_THAT_VA_NUM_ARGS_IMPL(_1, _2, _3, N, ...) N
0023 
0024 
0025 #define ASSERT_THAT_macro_dispatcher(func, ...)   ASSERT_THAT_macro_dispatcher_(func, ASSERT_THAT_VA_NUM_ARGS(__VA_ARGS__))
0026 
0027 #define ASSERT_THAT_macro_dispatcher_(func, nargs)           ASSERT_THAT_macro_dispatcher__(func, nargs)
0028 #define ASSERT_THAT_macro_dispatcher__(func, nargs)           ASSERT_THAT_macro_dispatcher___(func, nargs)
0029 #define ASSERT_THAT_macro_dispatcher___(func, nargs)          func ## nargs
0030 
0031 
0032 
0033 #define assert_that_NARG(...) ASSERT_THAT_macro_dispatcher(assert_that, __VA_ARGS__)
0034 
0035 #define assert_that_expression(expression) \
0036         assert_that_(__FILE__, __LINE__, #expression, expression, is_true);
0037 
0038 void assert_equal_(const char *file, int line, const char *expression, intptr_t tried, intptr_t expected);
0039 void assert_not_equal_(const char *file, int line, const char *expression, intptr_t tried, intptr_t expected);
0040 void assert_double_equal_(const char *file, int line, const char *expression, double tried, double expected);
0041 void assert_double_not_equal_(const char *file, int line, const char *expression, double tried, double expected);
0042 void assert_string_equal_(const char *file, int line, const char *expression, const char *tried, const char *expected);
0043 void assert_string_not_equal_(const char *file, int line, const char *expression, const char *tried, const char *expected);
0044 void assert_that_double_(const char *file, int line, const char *actual_string, double actual, Constraint *constraint);
0045 
0046 const char *show_null_as_the_string_null(const char *string);
0047 bool doubles_are_equal(double tried, double expected);
0048 
0049 #ifdef __cplusplus
0050     }
0051 }
0052 #endif
0053 
0054 #endif