Back to home page

Enduro/X

 
 

    


0001 #ifndef CONSTRAINT_SYNTAX_HELPERS_HEADER
0002 #define CONSTRAINT_SYNTAX_HELPERS_HEADER
0003 
0004 
0005 #include <cgreen/constraint.h>
0006 #ifdef __cplusplus
0007 #include <cgreen/cpp_constraint.h>
0008 #endif
0009 #include <stdint.h>
0010 
0011 #ifdef __cplusplus
0012 namespace cgreen {
0013 extern "C" {
0014 #endif
0015 
0016 /* we normally want to favor delegating functions (for namespacing, and to avoid confusing symbol/preprocessor conflicts),
0017  * but for the intptr_t catch-all type, we need an explicit cast lest we get warnings-as-errors in newer compilers.
0018  * also, we need the textual representation of the expected value and this is the only reasonable way to do it.
0019  */
0020 #define is_equal_to(value) create_equal_to_value_constraint((intptr_t)value, #value)
0021 #define is_not_equal_to(value) create_not_equal_to_value_constraint((intptr_t)value, #value)
0022 
0023 #define is_greater_than(value) create_greater_than_value_constraint((intptr_t)value, #value)
0024 #define is_less_than(value) create_less_than_value_constraint((intptr_t)value, #value)
0025 
0026 #define is_equal_to_contents_of(pointer, size_of_contents) create_equal_to_contents_constraint((void *)pointer, size_of_contents, #pointer)
0027 #define is_not_equal_to_contents_of(pointer, size_of_contents) create_not_equal_to_contents_constraint((void *)pointer, size_of_contents, #pointer)
0028 
0029 #define is_equal_to_string(value) create_equal_to_string_constraint(value, #value)
0030 #define is_not_equal_to_string(value) create_not_equal_to_string_constraint(value, #value)
0031 #define contains_string(value) create_contains_string_constraint(value, #value)
0032 #define does_not_contain_string(value) create_does_not_contain_string_constraint(value, #value)
0033 #define begins_with_string(value) create_begins_with_string_constraint(value, #value)
0034 
0035 #define is_equal_to_double(value) create_equal_to_double_constraint(value, #value)
0036 #define is_not_equal_to_double(value) create_not_equal_to_double_constraint(value, #value)
0037 
0038 #define will_return(value) create_return_value_constraint((intptr_t)value)
0039 #define will_set_contents_of_parameter(parameter_name, value, size) create_set_parameter_value_constraint(#parameter_name, (intptr_t)value, (size_t)size)
0040 
0041 
0042 
0043 /* these constraints don't take arguments, and we don't want to force users to put "()" on the end of every usage.
0044  * we also want to avoid macros when practical, for the namespacing and confusing symbol collision issues, 
0045  * so we use singleton instances.
0046  */
0047 extern Constraint static_non_null_constraint;
0048 extern Constraint *is_non_null;
0049 #define is_not_null (is_non_null)
0050 
0051 extern Constraint static_null_constraint;
0052 extern Constraint *is_null;
0053 
0054 extern Constraint static_false_constraint;
0055 extern Constraint *is_false;
0056 
0057 extern Constraint static_true_constraint;
0058 extern Constraint *is_true;
0059 
0060 #ifdef __cplusplus
0061     }
0062 }
0063 #endif
0064 
0065 #endif