diff --git a/doc/cgreen-guide-en.asciidoc b/doc/cgreen-guide-en.asciidoc index fa4d602c..30b1ce73 100644 --- a/doc/cgreen-guide-en.asciidoc +++ b/doc/cgreen-guide-en.asciidoc @@ -621,7 +621,7 @@ results. Here are the standard constraints... |========================================================= -|*Constraint* |*Passes if actual value/expression...* +|*CgreenConstraint* |*Passes if actual value/expression...* | _Basic_ | | `is_true` | evaluates to true, buy you can also just leave out the constraint, e.g. `assert_that(found)` if `found` is of boolean type @@ -1678,7 +1678,7 @@ There is a multitude of constraints available (actually, exactly the same as for the assertions we saw earlier): |========================================================================== -|*Constraint* |*Type* +|*CgreenConstraint* |*Type* |`is_equal_to(value)` | Integers |`is_not_equal_to(value)` | Integers |`is_greater_than(value)` | Integers @@ -1986,7 +1986,7 @@ When it comes to double typed values this has spilled over even further. For double typed values we have |========================================================================== -| *Constraint* +| *CgreenConstraint* | `is_equal_to_double(value)` | `is_not_equal_to_double(value)` | `is_less_than_double(value)` diff --git a/include/cgreen/constraint.h b/include/cgreen/constraint.h index 1840c1c6..fe1aa118 100644 --- a/include/cgreen/constraint.h +++ b/include/cgreen/constraint.h @@ -20,14 +20,14 @@ typedef enum { CALL_COUNTER } ConstraintType; -typedef struct Constraint_ Constraint; -struct Constraint_ { +typedef struct CgreenConstraint_ CgreenConstraint; +struct CgreenConstraint_ { ConstraintType type; const char *name; - void (*destroy)(Constraint *); - bool (*compare)(Constraint *, CgreenValue); - void (*execute)(Constraint *, const char *, CgreenValue, const char *, int, TestReporter *); - char *(*failure_message)(Constraint *, const char *, intptr_t); + void (*destroy)(CgreenConstraint *); + bool (*compare)(CgreenConstraint *, CgreenValue); + void (*execute)(CgreenConstraint *, const char *, CgreenValue, const char *, int, TestReporter *); + char *(*failure_message)(CgreenConstraint *, const char *, intptr_t); const char *actual_value_message; const char *expected_value_message; CgreenValue expected_value; @@ -43,38 +43,38 @@ namespace cgreen { extern "C" { #endif -Constraint *create_constraint(void); -Constraint *create_parameter_constraint_for(const char *parameter_name); +CgreenConstraint *create_constraint(void); +CgreenConstraint *create_parameter_constraint_for(const char *parameter_name); -bool compare_want_value(Constraint *constraint, CgreenValue actual); -bool compare_do_not_want_value(Constraint *constraint, CgreenValue actual); -void test_want(Constraint *constraint, const char *function, CgreenValue actual, const char *test_file, int test_line, TestReporter *reporter); +bool compare_want_value(CgreenConstraint *constraint, CgreenValue actual); +bool compare_do_not_want_value(CgreenConstraint *constraint, CgreenValue actual); +void test_want(CgreenConstraint *constraint, const char *function, CgreenValue actual, const char *test_file, int test_line, TestReporter *reporter); -void test_constraint(Constraint *constraint, const char *function, intptr_t actual, const char *test_file, int test_line, TestReporter *reporter); +void test_constraint(CgreenConstraint *constraint, const char *function, intptr_t actual, const char *test_file, int test_line, TestReporter *reporter); -Constraint *create_equal_to_value_constraint(intptr_t expected_value, const char *expected_value_name); -Constraint *create_equal_to_hexvalue_constraint(intptr_t expected_value, const char *expected_value_name); -Constraint *create_not_equal_to_value_constraint(intptr_t expected_value, const char *expected_value_name); -Constraint *create_greater_than_value_constraint(intptr_t expected_value, const char *expected_value_name); -Constraint *create_less_than_value_constraint(intptr_t expected_value, const char *expected_value_name); -Constraint *create_equal_to_contents_constraint(void *pointer_to_compare, size_t size_to_compare, const char *compared_pointer_name); -Constraint *create_not_equal_to_contents_constraint(void *pointer_to_compare, size_t size_to_compare, const char *compared_pointer_name); -Constraint *create_equal_to_string_constraint(const char* expected_value, const char *expected_value_name); -Constraint *create_not_equal_to_string_constraint(const char* expected_value, const char *expected_value_name); -Constraint *create_contains_string_constraint(const char* expected_value, const char *expected_value_name); -Constraint *create_does_not_contain_string_constraint(const char* expected_value, const char *expected_value_name); -Constraint *create_begins_with_string_constraint(const char* expected_value, const char *expected_value_name); -Constraint *create_does_not_begin_with_string_constraint(const char* expected_value, const char *expected_value_name); -Constraint *create_ends_with_string_constraint(const char* expected_value, const char *expected_value_name); -Constraint *create_does_not_end_with_string_constraint(const char* expected_value, const char *expected_value_name); +CgreenConstraint *create_equal_to_value_constraint(intptr_t expected_value, const char *expected_value_name); +CgreenConstraint *create_equal_to_hexvalue_constraint(intptr_t expected_value, const char *expected_value_name); +CgreenConstraint *create_not_equal_to_value_constraint(intptr_t expected_value, const char *expected_value_name); +CgreenConstraint *create_greater_than_value_constraint(intptr_t expected_value, const char *expected_value_name); +CgreenConstraint *create_less_than_value_constraint(intptr_t expected_value, const char *expected_value_name); +CgreenConstraint *create_equal_to_contents_constraint(void *pointer_to_compare, size_t size_to_compare, const char *compared_pointer_name); +CgreenConstraint *create_not_equal_to_contents_constraint(void *pointer_to_compare, size_t size_to_compare, const char *compared_pointer_name); +CgreenConstraint *create_equal_to_string_constraint(const char* expected_value, const char *expected_value_name); +CgreenConstraint *create_not_equal_to_string_constraint(const char* expected_value, const char *expected_value_name); +CgreenConstraint *create_contains_string_constraint(const char* expected_value, const char *expected_value_name); +CgreenConstraint *create_does_not_contain_string_constraint(const char* expected_value, const char *expected_value_name); +CgreenConstraint *create_begins_with_string_constraint(const char* expected_value, const char *expected_value_name); +CgreenConstraint *create_does_not_begin_with_string_constraint(const char* expected_value, const char *expected_value_name); +CgreenConstraint *create_ends_with_string_constraint(const char* expected_value, const char *expected_value_name); +CgreenConstraint *create_does_not_end_with_string_constraint(const char* expected_value, const char *expected_value_name); -Constraint *create_equal_to_double_constraint(double expected_value, const char *expected_value_name); -Constraint *create_not_equal_to_double_constraint(double expected_value, const char *expected_value_name); -Constraint *create_less_than_double_constraint(double expected_value, const char *expected_value_name); -Constraint *create_greater_than_double_constraint(double expected_value, const char *expected_value_name); -Constraint *create_return_value_constraint(intptr_t value_to_return); -Constraint *create_return_double_value_constraint(double value_to_return); -Constraint *create_set_parameter_value_constraint(const char *parameter_name, intptr_t value_to_set, size_t size_to_set); +CgreenConstraint *create_equal_to_double_constraint(double expected_value, const char *expected_value_name); +CgreenConstraint *create_not_equal_to_double_constraint(double expected_value, const char *expected_value_name); +CgreenConstraint *create_less_than_double_constraint(double expected_value, const char *expected_value_name); +CgreenConstraint *create_greater_than_double_constraint(double expected_value, const char *expected_value_name); +CgreenConstraint *create_return_value_constraint(intptr_t value_to_return); +CgreenConstraint *create_return_double_value_constraint(double value_to_return); +CgreenConstraint *create_set_parameter_value_constraint(const char *parameter_name, intptr_t value_to_set, size_t size_to_set); /* Utility: */ int get_significant_figures(void); diff --git a/include/cgreen/constraints.h b/include/cgreen/constraints.h index 1b202d0d..d08181d1 100644 --- a/include/cgreen/constraints.h +++ b/include/cgreen/constraints.h @@ -55,18 +55,18 @@ extern "C" { * macros when practical, for the namespacing and confusing symbol * collision issues, so we use singleton instances. */ -extern Constraint static_non_null_constraint; -extern Constraint *is_non_null; +extern CgreenConstraint static_non_null_constraint; +extern CgreenConstraint *is_non_null; #define is_not_null (is_non_null) -extern Constraint static_null_constraint; -extern Constraint *is_null; +extern CgreenConstraint static_null_constraint; +extern CgreenConstraint *is_null; -extern Constraint static_false_constraint; -extern Constraint *is_false; +extern CgreenConstraint static_false_constraint; +extern CgreenConstraint *is_false; -extern Constraint static_true_constraint; -extern Constraint *is_true; +extern CgreenConstraint static_true_constraint; +extern CgreenConstraint *is_true; #ifdef __cplusplus } diff --git a/include/cgreen/cpp_constraint.h b/include/cgreen/cpp_constraint.h index 10835122..9d6a87d0 100644 --- a/include/cgreen/cpp_constraint.h +++ b/include/cgreen/cpp_constraint.h @@ -8,22 +8,22 @@ namespace cgreen { template -class CppConstraint : public Constraint { +class CppConstraint : public CgreenConstraint { public: T expected_real_value; bool (*compare)(CppConstraint *, T); }; -Constraint *create_equal_to_string_constraint(const std::string& expected_value, const char *expected_value_name); -Constraint *create_equal_to_string_constraint(const std::string* expected_value, const char *expected_value_name); -Constraint *create_not_equal_to_string_constraint(const std::string& expected_value, const char *expected_value_name); -Constraint *create_not_equal_to_string_constraint(const std::string* expected_value, const char *expected_value_name); -Constraint *create_contains_string_constraint(const std::string& expected_value, const char *expected_value_name); -Constraint *create_contains_string_constraint(const std::string* expected_value, const char *expected_value_name); -Constraint *create_does_not_contain_string_constraint(const std::string& expected_value, const char *expected_value_name); -Constraint *create_does_not_contain_string_constraint(const std::string* expected_value, const char *expected_value_name); -Constraint *create_begins_with_string_constraint(const std::string& expected_value, const char *expected_value_name); -Constraint *create_begins_with_string_constraint(const std::string* expected_value, const char *expected_value_name); +CgreenConstraint *create_equal_to_string_constraint(const std::string& expected_value, const char *expected_value_name); +CgreenConstraint *create_equal_to_string_constraint(const std::string* expected_value, const char *expected_value_name); +CgreenConstraint *create_not_equal_to_string_constraint(const std::string& expected_value, const char *expected_value_name); +CgreenConstraint *create_not_equal_to_string_constraint(const std::string* expected_value, const char *expected_value_name); +CgreenConstraint *create_contains_string_constraint(const std::string& expected_value, const char *expected_value_name); +CgreenConstraint *create_contains_string_constraint(const std::string* expected_value, const char *expected_value_name); +CgreenConstraint *create_does_not_contain_string_constraint(const std::string& expected_value, const char *expected_value_name); +CgreenConstraint *create_does_not_contain_string_constraint(const std::string* expected_value, const char *expected_value_name); +CgreenConstraint *create_begins_with_string_constraint(const std::string& expected_value, const char *expected_value_name); +CgreenConstraint *create_begins_with_string_constraint(const std::string* expected_value, const char *expected_value_name); template @@ -56,7 +56,7 @@ CppConstraint *create_equal_to_value_constraint(CgreenValue cgreen_value, T e (void)cgreen_value; /* Avoid warnings for UNUSED, which it is for now */ - constraint->Constraint::compare = &compare_want_value; + constraint->CgreenConstraint::compare = &compare_want_value; constraint->execute = &test_want; constraint->name = "equal"; constraint->expected_value = expected_value; diff --git a/include/cgreen/internal/assertions_internal.h b/include/cgreen/internal/assertions_internal.h index d388892b..316b28a4 100755 --- a/include/cgreen/internal/assertions_internal.h +++ b/include/cgreen/internal/assertions_internal.h @@ -49,7 +49,7 @@ void assert_double_equal_(const char *file, int line, const char *expression, do void assert_double_not_equal_(const char *file, int line, const char *expression, double tried, double expected); void assert_string_equal_(const char *file, int line, const char *expression, const char *tried, const char *expected); void assert_string_not_equal_(const char *file, int line, const char *expression, const char *tried, const char *expected); -void assert_that_double_(const char *file, int line, const char *actual_string, double actual, Constraint *constraint); +void assert_that_double_(const char *file, int line, const char *actual_string, double actual, CgreenConstraint *constraint); #ifdef __cplusplus } diff --git a/include/cgreen/internal/c_assertions.h b/include/cgreen/internal/c_assertions.h index 35fd03d8..fe39ae61 100644 --- a/include/cgreen/internal/c_assertions.h +++ b/include/cgreen/internal/c_assertions.h @@ -14,8 +14,8 @@ extern "C" { #endif -void assert_core_(const char *file, int line, const char *actual_string, intptr_t actual, Constraint *constraint); -void assert_that_double_(const char *file, int line, const char *expression, double actual, Constraint* constraint); +void assert_core_(const char *file, int line, const char *actual_string, intptr_t actual, CgreenConstraint *constraint); +void assert_that_double_(const char *file, int line, const char *expression, double actual, CgreenConstraint* constraint); #ifdef __cplusplus } diff --git a/include/cgreen/internal/cpp_assertions.h b/include/cgreen/internal/cpp_assertions.h index 16dab2b9..7816c2f7 100644 --- a/include/cgreen/internal/cpp_assertions.h +++ b/include/cgreen/internal/cpp_assertions.h @@ -12,14 +12,14 @@ namespace cgreen { #define assert_that_constraint(actual, constraint) assert_that_(__FILE__, __LINE__, STRINGIFY_TOKEN(actual), actual, constraint) - void assert_that_(const char *file, int line, const char *actual_string, const std::string& actual, Constraint *constraint); - void assert_that_(const char *file, int line, const char *actual_string, const std::string *actual, Constraint *constraint); - void assert_that_(const char *file, int line, const char *actual_string, double actual, Constraint *constraint); + void assert_that_(const char *file, int line, const char *actual_string, const std::string& actual, CgreenConstraint *constraint); + void assert_that_(const char *file, int line, const char *actual_string, const std::string *actual, CgreenConstraint *constraint); + void assert_that_(const char *file, int line, const char *actual_string, double actual, CgreenConstraint *constraint); // this isn't declared in assertions.h because you can't have overloads for an extern "C"-declared function, so it seems - void assert_that_(const char *file, int line, const char *actual_string, intptr_t actual, Constraint *constraint); + void assert_that_(const char *file, int line, const char *actual_string, intptr_t actual, CgreenConstraint *constraint); - template void assert_that_(const char *file, int line, const char *actual_string, T actual, Constraint *constraint) { + template void assert_that_(const char *file, int line, const char *actual_string, T actual, CgreenConstraint *constraint) { if (typeid(actual) == typeid(std::string&) || typeid(actual) == typeid(const std::string&) || diff --git a/include/cgreen/internal/mocks_internal.h b/include/cgreen/internal/mocks_internal.h index dfe033b0..9fe7c818 100755 --- a/include/cgreen/internal/mocks_internal.h +++ b/include/cgreen/internal/mocks_internal.h @@ -40,7 +40,7 @@ extern intptr_t mock_(TestReporter *test_reporter, const char *function, const c passes the test case. /@awilke */ -extern Constraint *when_(const char *parameter, Constraint *constraint) WARN_UNUSED_RESULT; +extern CgreenConstraint *when_(const char *parameter, CgreenConstraint *constraint) WARN_UNUSED_RESULT; extern Constraint *times_(int number_times_called); diff --git a/include/cgreen/message_formatting.h b/include/cgreen/message_formatting.h index ea366701..89b76c01 100644 --- a/include/cgreen/message_formatting.h +++ b/include/cgreen/message_formatting.h @@ -9,9 +9,9 @@ namespace cgreen { extern "C" { #endif -char *failure_message_for(Constraint *constraint, const char *actual_string, intptr_t actual); -char *validation_failure_message_for(Constraint *constraint, intptr_t actual); -bool parameters_are_not_valid_for(Constraint *constraint, intptr_t actual); +char *failure_message_for(CgreenConstraint *constraint, const char *actual_string, intptr_t actual); +char *validation_failure_message_for(CgreenConstraint *constraint, intptr_t actual); +bool parameters_are_not_valid_for(CgreenConstraint *constraint, intptr_t actual); #ifdef __cplusplus } diff --git a/include/cgreen/mocks.h b/include/cgreen/mocks.h index 2a17ee47..c48fe945 100644 --- a/include/cgreen/mocks.h +++ b/include/cgreen/mocks.h @@ -18,11 +18,11 @@ namespace cgreen { expect(, when(, ), will_return()); */ #define expect(f, ...) expect_(get_test_reporter(), STRINGIFY_TOKEN(f), __FILE__, __LINE__, \ - (Constraint *)__VA_ARGS__ +0, (Constraint *)0) + (CgreenConstraint *)__VA_ARGS__ +0, (CgreenConstraint *)0) #define always_expect(f, ...) always_expect_(get_test_reporter(), STRINGIFY_TOKEN(f), __FILE__, __LINE__, \ - (Constraint *)__VA_ARGS__ +0, (Constraint *)0) + (CgreenConstraint *)__VA_ARGS__ +0, (CgreenConstraint *)0) #define never_expect(f, ...) never_expect_(get_test_reporter(), STRINGIFY_TOKEN(f), __FILE__, __LINE__, \ - (Constraint *)__VA_ARGS__ +0, (Constraint *)0) + (CgreenConstraint *)__VA_ARGS__ +0, (CgreenConstraint *)0) #ifdef _MSC_VER diff --git a/src/assertions.c b/src/assertions.c index 36a6222a..c3b7427e 100644 --- a/src/assertions.c +++ b/src/assertions.c @@ -21,7 +21,7 @@ const char *show_null_as_the_string_null(const char *string); void assert_core_(const char *file, int line, const char *actual_string, intptr_t actual, - Constraint* constraint) { + CgreenConstraint* constraint) { char *failure_message; @@ -80,7 +80,7 @@ void assert_core_(const char *file, int line, const char *actual_string, intptr_ free(failure_message); } -void assert_that_double_(const char *file, int line, const char *expression, double actual, Constraint* constraint) { +void assert_that_double_(const char *file, int line, const char *expression, double actual, CgreenConstraint* constraint) { BoxedDouble* boxed_actual; if (NULL != constraint && is_not_comparing(constraint)) { diff --git a/src/constraint.c b/src/constraint.c index 66784157..327f99ab 100644 --- a/src/constraint.c +++ b/src/constraint.c @@ -48,45 +48,45 @@ static double absolute_tolerance = DBL_MIN / 1.0e-8; static double accuracy(int significant_figures, double largest); -static bool compare_want_greater_value(Constraint *constraint, CgreenValue actual); +static bool compare_want_greater_value(CgreenConstraint *constraint, CgreenValue actual); -static bool compare_want_lesser_value(Constraint *constraint, CgreenValue actual); +static bool compare_want_lesser_value(CgreenConstraint *constraint, CgreenValue actual); -static bool compare_want_contents(Constraint *constraint, CgreenValue actual); +static bool compare_want_contents(CgreenConstraint *constraint, CgreenValue actual); -static bool compare_do_not_want_contents(Constraint *constraint, CgreenValue actual); +static bool compare_do_not_want_contents(CgreenConstraint *constraint, CgreenValue actual); -static bool compare_true(Constraint *constraint, CgreenValue actual); -static void test_true(Constraint *constraint, const char *function, CgreenValue actual, +static bool compare_true(CgreenConstraint *constraint, CgreenValue actual); +static void test_true(CgreenConstraint *constraint, const char *function, CgreenValue actual, const char *test_file, int test_line, TestReporter *reporter); -static bool compare_want_string(Constraint *constraint, CgreenValue actual); -static bool compare_do_not_want_string(Constraint *constraint, CgreenValue actual); -static bool compare_want_substring(Constraint *constraint, CgreenValue actual); -static bool compare_do_not_want_substring(Constraint *constraint, CgreenValue actual); -static bool compare_want_beginning_of_string(Constraint *constraint, CgreenValue actual); -static bool compare_do_not_want_beginning_of_string(Constraint *constraint, CgreenValue actual); -static bool compare_want_end_of_string(Constraint *constraint, CgreenValue actual); -static bool compare_do_not_want_end_of_string(Constraint *constraint, CgreenValue actual); - -static bool compare_want_double(Constraint *constraint, CgreenValue actual); -static void test_want_double(Constraint *constraint, const char *function, CgreenValue actual, +static bool compare_want_string(CgreenConstraint *constraint, CgreenValue actual); +static bool compare_do_not_want_string(CgreenConstraint *constraint, CgreenValue actual); +static bool compare_want_substring(CgreenConstraint *constraint, CgreenValue actual); +static bool compare_do_not_want_substring(CgreenConstraint *constraint, CgreenValue actual); +static bool compare_want_beginning_of_string(CgreenConstraint *constraint, CgreenValue actual); +static bool compare_do_not_want_beginning_of_string(CgreenConstraint *constraint, CgreenValue actual); +static bool compare_want_end_of_string(CgreenConstraint *constraint, CgreenValue actual); +static bool compare_do_not_want_end_of_string(CgreenConstraint *constraint, CgreenValue actual); + +static bool compare_want_double(CgreenConstraint *constraint, CgreenValue actual); +static void test_want_double(CgreenConstraint *constraint, const char *function, CgreenValue actual, const char *test_file, int test_line, TestReporter *reporter); -static bool compare_do_not_want_double(Constraint *constraint, CgreenValue actual); -static void test_do_not_want_double(Constraint *constraint, const char *function, CgreenValue actual, +static bool compare_do_not_want_double(CgreenConstraint *constraint, CgreenValue actual); +static void test_do_not_want_double(CgreenConstraint *constraint, const char *function, CgreenValue actual, const char *test_file, int test_line, TestReporter *reporter); -static bool compare_want_lesser_double(Constraint *constraint, CgreenValue actual); -static bool compare_want_greater_double(Constraint *constraint, CgreenValue actual); +static bool compare_want_lesser_double(CgreenConstraint *constraint, CgreenValue actual); +static bool compare_want_greater_double(CgreenConstraint *constraint, CgreenValue actual); -static void set_contents(Constraint *constraint, const char *function, CgreenValue actual, +static void set_contents(CgreenConstraint *constraint, const char *function, CgreenValue actual, const char *test_file, int test_line, TestReporter *reporter); static const char *default_actual_value_message = "\n\t\tactual value:\t\t\t[%" PRIdPTR "]"; static const char *default_expected_value_message = "\t\texpected value:\t\t\t[%" PRIdPTR "]"; -Constraint *create_constraint() { - Constraint *constraint = (Constraint *)malloc(sizeof(Constraint)); +CgreenConstraint *create_constraint() { + CgreenConstraint *constraint = (CgreenConstraint *)malloc(sizeof(CgreenConstraint)); /* TODO: setting this to NULL as an implicit type check :( */ constraint->parameter_name = NULL; constraint->destroy = &destroy_empty_constraint; @@ -98,8 +98,8 @@ Constraint *create_constraint() { return constraint; } -static Constraint *create_constraint_expecting(CgreenValue expected_value, const char *expected_value_name) { - Constraint *constraint = create_constraint(); +static CgreenConstraint *create_constraint_expecting(CgreenValue expected_value, const char *expected_value_name) { + CgreenConstraint *constraint = create_constraint(); constraint->expected_value = expected_value; constraint->expected_value_name = string_dup(expected_value_name); @@ -107,7 +107,7 @@ static Constraint *create_constraint_expecting(CgreenValue expected_value, const return constraint; } -void destroy_empty_constraint(Constraint *constraint) { +void destroy_empty_constraint(CgreenConstraint *constraint) { constraint->name = NULL; constraint->parameter_name = NULL; constraint->compare = NULL; @@ -120,28 +120,28 @@ void destroy_empty_constraint(Constraint *constraint) { free(constraint); } -void destroy_static_constraint(Constraint *constraint) { +void destroy_static_constraint(CgreenConstraint *constraint) { /* static constraints helpers (e.g. is_null) act as singletons, and are never destroyed */ (void)constraint; } -void destroy_constraint(Constraint *constraint) { +void destroy_constraint(CgreenConstraint *constraint) { if (constraint->destroy != NULL) (*constraint->destroy)(constraint); } void destroy_constraints(va_list constraints) { - Constraint *constraint = NULL; - while ((constraint = va_arg(constraints, Constraint *)) != (Constraint *)0) { + CgreenConstraint *constraint = NULL; + while ((constraint = va_arg(constraints, CgreenConstraint *)) != (CgreenConstraint *)0) { destroy_constraint(constraint); } } -bool constraint_is_for_parameter(const Constraint *constraint, const char *parameter) { +bool constraint_is_for_parameter(const CgreenConstraint *constraint, const char *parameter) { return !constraint_is_not_for_parameter(constraint, parameter); } -bool constraint_is_not_for_parameter(const Constraint *constraint, const char *parameter) { +bool constraint_is_not_for_parameter(const CgreenConstraint *constraint, const char *parameter) { if (is_not_comparing(constraint) && is_not_content_setting(constraint)) { return true; } @@ -149,8 +149,8 @@ bool constraint_is_not_for_parameter(const Constraint *constraint, const char *p return strcmp(constraint->parameter_name, parameter) != 0; } -Constraint *create_equal_to_value_constraint(intptr_t expected_value, const char *expected_value_name) { - Constraint *constraint = create_constraint_expecting(make_cgreen_integer_value(expected_value), expected_value_name); +CgreenConstraint *create_equal_to_value_constraint(intptr_t expected_value, const char *expected_value_name) { + CgreenConstraint *constraint = create_constraint_expecting(make_cgreen_integer_value(expected_value), expected_value_name); constraint->type = VALUE_COMPARER; constraint->compare = &compare_want_value; @@ -161,8 +161,8 @@ Constraint *create_equal_to_value_constraint(intptr_t expected_value, const char return constraint; } -Constraint *create_equal_to_hexvalue_constraint(intptr_t expected_value, const char *expected_value_name) { - Constraint *constraint = create_constraint_expecting(make_cgreen_integer_value(expected_value), expected_value_name); +CgreenConstraint *create_equal_to_hexvalue_constraint(intptr_t expected_value, const char *expected_value_name) { + CgreenConstraint *constraint = create_constraint_expecting(make_cgreen_integer_value(expected_value), expected_value_name); constraint->type = VALUE_COMPARER; constraint->compare = &compare_want_value; @@ -175,8 +175,8 @@ Constraint *create_equal_to_hexvalue_constraint(intptr_t expected_value, const c return constraint; } -Constraint *create_not_equal_to_value_constraint(intptr_t expected_value, const char *expected_value_name) { - Constraint *constraint = create_constraint_expecting(make_cgreen_integer_value(expected_value), expected_value_name); +CgreenConstraint *create_not_equal_to_value_constraint(intptr_t expected_value, const char *expected_value_name) { + CgreenConstraint *constraint = create_constraint_expecting(make_cgreen_integer_value(expected_value), expected_value_name); constraint->type = VALUE_COMPARER; constraint->compare = &compare_do_not_want_value; @@ -187,8 +187,8 @@ Constraint *create_not_equal_to_value_constraint(intptr_t expected_value, const return constraint; } -Constraint *create_less_than_value_constraint(intptr_t expected_value, const char *expected_value_name) { - Constraint *constraint = create_constraint_expecting(make_cgreen_integer_value(expected_value), expected_value_name); +CgreenConstraint *create_less_than_value_constraint(intptr_t expected_value, const char *expected_value_name) { + CgreenConstraint *constraint = create_constraint_expecting(make_cgreen_integer_value(expected_value), expected_value_name); constraint->type = VALUE_COMPARER; constraint->compare = &compare_want_lesser_value; @@ -200,8 +200,8 @@ Constraint *create_less_than_value_constraint(intptr_t expected_value, const cha return constraint; } -Constraint *create_greater_than_value_constraint(intptr_t expected_value, const char *expected_value_name) { - Constraint *constraint = create_constraint_expecting(make_cgreen_integer_value(expected_value), expected_value_name); +CgreenConstraint *create_greater_than_value_constraint(intptr_t expected_value, const char *expected_value_name) { + CgreenConstraint *constraint = create_constraint_expecting(make_cgreen_integer_value(expected_value), expected_value_name); constraint->type = VALUE_COMPARER; constraint->compare = &compare_want_greater_value; @@ -213,8 +213,8 @@ Constraint *create_greater_than_value_constraint(intptr_t expected_value, const return constraint; } -Constraint *create_equal_to_contents_constraint(void *pointer_to_compare, size_t size_to_compare, const char *compared_pointer_name) { - Constraint *constraint = create_constraint_expecting(make_cgreen_pointer_value(pointer_to_compare), compared_pointer_name); +CgreenConstraint *create_equal_to_contents_constraint(void *pointer_to_compare, size_t size_to_compare, const char *compared_pointer_name) { + CgreenConstraint *constraint = create_constraint_expecting(make_cgreen_pointer_value(pointer_to_compare), compared_pointer_name); constraint->type = CONTENT_COMPARER; constraint->compare = &compare_want_contents; @@ -225,8 +225,8 @@ Constraint *create_equal_to_contents_constraint(void *pointer_to_compare, size_t return constraint; } -Constraint *create_not_equal_to_contents_constraint(void *pointer_to_compare, size_t size_to_compare, const char *compared_pointer_name) { - Constraint *constraint = create_constraint_expecting(make_cgreen_pointer_value(pointer_to_compare), compared_pointer_name); +CgreenConstraint *create_not_equal_to_contents_constraint(void *pointer_to_compare, size_t size_to_compare, const char *compared_pointer_name) { + CgreenConstraint *constraint = create_constraint_expecting(make_cgreen_pointer_value(pointer_to_compare), compared_pointer_name); constraint->type = CONTENT_COMPARER; constraint->compare = &compare_do_not_want_contents; @@ -237,8 +237,8 @@ Constraint *create_not_equal_to_contents_constraint(void *pointer_to_compare, si return constraint; } -Constraint *create_equal_to_string_constraint(const char* expected_value, const char *expected_value_name) { - Constraint *constraint = create_constraint_expecting(make_cgreen_string_value(expected_value), expected_value_name); +CgreenConstraint *create_equal_to_string_constraint(const char* expected_value, const char *expected_value_name) { + CgreenConstraint *constraint = create_constraint_expecting(make_cgreen_string_value(expected_value), expected_value_name); constraint->type = STRING_COMPARER; constraint->compare = &compare_want_string; @@ -250,8 +250,8 @@ Constraint *create_equal_to_string_constraint(const char* expected_value, const return constraint; } -Constraint *create_not_equal_to_string_constraint(const char* expected_value, const char *expected_value_name) { - Constraint *constraint = create_constraint_expecting(make_cgreen_string_value(expected_value), expected_value_name); +CgreenConstraint *create_not_equal_to_string_constraint(const char* expected_value, const char *expected_value_name) { + CgreenConstraint *constraint = create_constraint_expecting(make_cgreen_string_value(expected_value), expected_value_name); constraint->type = STRING_COMPARER; constraint->compare = &compare_do_not_want_string; @@ -263,8 +263,8 @@ Constraint *create_not_equal_to_string_constraint(const char* expected_value, co return constraint; } -Constraint *create_contains_string_constraint(const char* expected_value, const char *expected_value_name) { - Constraint *constraint = create_constraint_expecting(make_cgreen_string_value(expected_value), expected_value_name); +CgreenConstraint *create_contains_string_constraint(const char* expected_value, const char *expected_value_name) { + CgreenConstraint *constraint = create_constraint_expecting(make_cgreen_string_value(expected_value), expected_value_name); constraint->type = STRING_COMPARER; constraint->compare = &compare_want_substring; @@ -276,8 +276,8 @@ Constraint *create_contains_string_constraint(const char* expected_value, const return constraint; } -Constraint *create_does_not_contain_string_constraint(const char* expected_value, const char *expected_value_name) { - Constraint *constraint = create_constraint_expecting(make_cgreen_string_value(expected_value), expected_value_name); +CgreenConstraint *create_does_not_contain_string_constraint(const char* expected_value, const char *expected_value_name) { + CgreenConstraint *constraint = create_constraint_expecting(make_cgreen_string_value(expected_value), expected_value_name); constraint->type = STRING_COMPARER; constraint->compare = &compare_do_not_want_substring; @@ -289,8 +289,8 @@ Constraint *create_does_not_contain_string_constraint(const char* expected_value return constraint; } -Constraint *create_begins_with_string_constraint(const char* expected_value, const char *expected_value_name) { - Constraint *constraint = create_constraint_expecting(make_cgreen_string_value(expected_value), expected_value_name); +CgreenConstraint *create_begins_with_string_constraint(const char* expected_value, const char *expected_value_name) { + CgreenConstraint *constraint = create_constraint_expecting(make_cgreen_string_value(expected_value), expected_value_name); constraint->type = STRING_COMPARER; constraint->compare = &compare_want_beginning_of_string; @@ -302,8 +302,8 @@ Constraint *create_begins_with_string_constraint(const char* expected_value, con return constraint; } -Constraint *create_does_not_begin_with_string_constraint(const char* expected_value, const char *expected_value_name) { - Constraint *constraint = create_constraint_expecting(make_cgreen_string_value(expected_value), expected_value_name); +CgreenConstraint *create_does_not_begin_with_string_constraint(const char* expected_value, const char *expected_value_name) { + CgreenConstraint *constraint = create_constraint_expecting(make_cgreen_string_value(expected_value), expected_value_name); constraint->type = STRING_COMPARER; constraint->compare = &compare_do_not_want_beginning_of_string; @@ -315,8 +315,8 @@ Constraint *create_does_not_begin_with_string_constraint(const char* expected_va return constraint; } -Constraint *create_ends_with_string_constraint(const char* expected_value, const char *expected_value_name) { - Constraint *constraint = create_constraint_expecting(make_cgreen_string_value(expected_value), expected_value_name); +CgreenConstraint *create_ends_with_string_constraint(const char* expected_value, const char *expected_value_name) { + CgreenConstraint *constraint = create_constraint_expecting(make_cgreen_string_value(expected_value), expected_value_name); constraint->type = STRING_COMPARER; constraint->compare = &compare_want_end_of_string; @@ -328,8 +328,8 @@ Constraint *create_ends_with_string_constraint(const char* expected_value, const return constraint; } -Constraint *create_does_not_end_with_string_constraint(const char* expected_value, const char *expected_value_name) { - Constraint *constraint = create_constraint_expecting(make_cgreen_string_value(expected_value), expected_value_name); +CgreenConstraint *create_does_not_end_with_string_constraint(const char* expected_value, const char *expected_value_name) { + CgreenConstraint *constraint = create_constraint_expecting(make_cgreen_string_value(expected_value), expected_value_name); constraint->type = STRING_COMPARER; constraint->compare = &compare_do_not_want_end_of_string; @@ -341,8 +341,8 @@ Constraint *create_does_not_end_with_string_constraint(const char* expected_valu return constraint; } -Constraint *create_equal_to_double_constraint(double expected_value, const char *expected_value_name) { - Constraint *constraint = create_constraint_expecting(make_cgreen_double_value(expected_value), expected_value_name); +CgreenConstraint *create_equal_to_double_constraint(double expected_value, const char *expected_value_name) { + CgreenConstraint *constraint = create_constraint_expecting(make_cgreen_double_value(expected_value), expected_value_name); constraint->type = DOUBLE_COMPARER; constraint->compare = &compare_want_double; @@ -353,8 +353,8 @@ Constraint *create_equal_to_double_constraint(double expected_value, const char return constraint; } -Constraint *create_not_equal_to_double_constraint(double expected_value, const char *expected_value_name) { - Constraint *constraint = create_constraint_expecting(make_cgreen_double_value(expected_value), expected_value_name); +CgreenConstraint *create_not_equal_to_double_constraint(double expected_value, const char *expected_value_name) { + CgreenConstraint *constraint = create_constraint_expecting(make_cgreen_double_value(expected_value), expected_value_name); constraint->type = DOUBLE_COMPARER; constraint->compare = &compare_do_not_want_double; @@ -365,8 +365,8 @@ Constraint *create_not_equal_to_double_constraint(double expected_value, const c return constraint; } -Constraint *create_less_than_double_constraint(double expected_value, const char *expected_value_name) { - Constraint *constraint = create_constraint_expecting(make_cgreen_double_value(expected_value), expected_value_name); +CgreenConstraint *create_less_than_double_constraint(double expected_value, const char *expected_value_name) { + CgreenConstraint *constraint = create_constraint_expecting(make_cgreen_double_value(expected_value), expected_value_name); constraint->type = DOUBLE_COMPARER; constraint->compare = &compare_want_lesser_double; @@ -378,8 +378,8 @@ Constraint *create_less_than_double_constraint(double expected_value, const char return constraint; } -Constraint *create_greater_than_double_constraint(double expected_value, const char *expected_value_name) { - Constraint *constraint = create_constraint_expecting(make_cgreen_double_value(expected_value), expected_value_name); +CgreenConstraint *create_greater_than_double_constraint(double expected_value, const char *expected_value_name) { + CgreenConstraint *constraint = create_constraint_expecting(make_cgreen_double_value(expected_value), expected_value_name); constraint->type = DOUBLE_COMPARER; constraint->compare = &compare_want_greater_double; @@ -391,8 +391,8 @@ Constraint *create_greater_than_double_constraint(double expected_value, const c return constraint; } -Constraint *create_return_value_constraint(intptr_t value_to_return) { - Constraint* constraint = create_constraint(); +CgreenConstraint *create_return_value_constraint(intptr_t value_to_return) { + CgreenConstraint* constraint = create_constraint(); constraint->type = RETURN_VALUE; constraint->compare = &compare_true; @@ -403,8 +403,8 @@ Constraint *create_return_value_constraint(intptr_t value_to_return) { return constraint; } -Constraint *create_return_double_value_constraint(double value_to_return) { - Constraint* constraint = create_constraint(); +CgreenConstraint *create_return_double_value_constraint(double value_to_return) { + CgreenConstraint* constraint = create_constraint(); constraint->type = RETURN_VALUE; constraint->compare = &compare_true; @@ -415,8 +415,8 @@ Constraint *create_return_double_value_constraint(double value_to_return) { return constraint; } -Constraint *create_set_parameter_value_constraint(const char *parameter_name, intptr_t value_to_set, size_t size_to_set) { - Constraint* constraint = create_constraint(); +CgreenConstraint *create_set_parameter_value_constraint(const char *parameter_name, intptr_t value_to_set, size_t size_to_set) { + CgreenConstraint* constraint = create_constraint(); constraint->type = CONTENT_SETTER; constraint->compare = &compare_true; @@ -429,24 +429,24 @@ Constraint *create_set_parameter_value_constraint(const char *parameter_name, in return constraint; } -bool compare_want_value(Constraint *constraint, CgreenValue actual) { +bool compare_want_value(CgreenConstraint *constraint, CgreenValue actual) { return constraint->expected_value.value.integer_value == actual.value.integer_value; } -bool compare_do_not_want_value(Constraint *constraint, CgreenValue actual) { +bool compare_do_not_want_value(CgreenConstraint *constraint, CgreenValue actual) { return !compare_want_value(constraint, actual); } -bool compare_want_greater_value(Constraint *constraint, CgreenValue actual) { +bool compare_want_greater_value(CgreenConstraint *constraint, CgreenValue actual) { return actual.value.integer_value > constraint->expected_value.value.integer_value ; } -bool compare_want_lesser_value(Constraint *constraint, CgreenValue actual) { +bool compare_want_lesser_value(CgreenConstraint *constraint, CgreenValue actual) { return actual.value.integer_value < constraint->expected_value.value.integer_value; } -bool compare_want_contents(Constraint *constraint, CgreenValue actual) { +bool compare_want_contents(CgreenConstraint *constraint, CgreenValue actual) { /* We can't inspect the contents of a NULL pointer, so comparison always fails */ /* TODO: This should really be .pointer_value */ if ((void *)actual.value.integer_value == NULL) { @@ -457,7 +457,7 @@ bool compare_want_contents(Constraint *constraint, CgreenValue actual) { (void *)actual.value.integer_value, constraint->size_of_expected_value); } -bool compare_do_not_want_contents(Constraint *constraint, CgreenValue actual) { +bool compare_do_not_want_contents(CgreenConstraint *constraint, CgreenValue actual) { /* we can't inspect the contents of a NULL pointer, so comparison always fails */ if ((void *)actual.value.integer_value == NULL) { return 0; @@ -466,7 +466,7 @@ bool compare_do_not_want_contents(Constraint *constraint, CgreenValue actual) { return !compare_want_contents(constraint, actual); } -static void set_contents(Constraint *constraint, const char *function, CgreenValue actual, +static void set_contents(CgreenConstraint *constraint, const char *function, CgreenValue actual, const char *test_file, int test_line, TestReporter *reporter) { char *message; (void)function; @@ -491,7 +491,7 @@ static void set_contents(Constraint *constraint, const char *function, CgreenVal -void test_want(Constraint *constraint, const char *function, CgreenValue actual, +void test_want(CgreenConstraint *constraint, const char *function, CgreenValue actual, const char *test_file, int test_line, TestReporter *reporter) { char *message; char parameter_name_actual_string[255]; @@ -524,19 +524,19 @@ void test_want(Constraint *constraint, const char *function, CgreenValue actual, free(message); } -static bool compare_want_string(Constraint *constraint, CgreenValue actual) { +static bool compare_want_string(CgreenConstraint *constraint, CgreenValue actual) { return strings_are_equal(constraint->expected_value.value.string_value, actual.value.string_value); } -static bool compare_do_not_want_string(Constraint *constraint, CgreenValue actual) { +static bool compare_do_not_want_string(CgreenConstraint *constraint, CgreenValue actual) { return !compare_want_string(constraint, actual); } -static bool compare_do_not_want_substring(Constraint *constraint, CgreenValue actual) { +static bool compare_do_not_want_substring(CgreenConstraint *constraint, CgreenValue actual) { return !compare_want_substring(constraint, actual); } -static bool compare_want_substring(Constraint *constraint, CgreenValue actual) { +static bool compare_want_substring(CgreenConstraint *constraint, CgreenValue actual) { return string_contains(actual.value.string_value, constraint->expected_value.value.string_value); } @@ -553,20 +553,20 @@ static unsigned int strpos(const char *haystack, const char *needle) return NOT_FOUND; } -static bool compare_want_beginning_of_string(Constraint *constraint, CgreenValue actual) { +static bool compare_want_beginning_of_string(CgreenConstraint *constraint, CgreenValue actual) { return strpos(actual.value.string_value, constraint->expected_value.value.string_value) == 0; } -static bool compare_do_not_want_beginning_of_string(Constraint *constraint, CgreenValue actual) { +static bool compare_do_not_want_beginning_of_string(CgreenConstraint *constraint, CgreenValue actual) { return strpos(actual.value.string_value, constraint->expected_value.value.string_value) != 0; } -static bool compare_want_end_of_string(Constraint *constraint, CgreenValue actual) { +static bool compare_want_end_of_string(CgreenConstraint *constraint, CgreenValue actual) { return strpos(actual.value.string_value, constraint->expected_value.value.string_value) == strlen(actual.value.string_value) - strlen(constraint->expected_value.value.string_value); } -static bool compare_do_not_want_end_of_string(Constraint *constraint, CgreenValue actual) { +static bool compare_do_not_want_end_of_string(CgreenConstraint *constraint, CgreenValue actual) { return strpos(actual.value.string_value, constraint->expected_value.value.string_value) != strlen(actual.value.string_value) - strlen(constraint->expected_value.value.string_value); } @@ -575,19 +575,19 @@ static bool compare_do_not_want_end_of_string(Constraint *constraint, CgreenValu // Double -static bool compare_want_double(Constraint *constraint, CgreenValue actual) { +static bool compare_want_double(CgreenConstraint *constraint, CgreenValue actual) { return doubles_are_equal(constraint->expected_value.value.double_value, actual.value.double_value); } -static bool compare_want_lesser_double(Constraint *constraint, CgreenValue actual) { +static bool compare_want_lesser_double(CgreenConstraint *constraint, CgreenValue actual) { return double_is_lesser(constraint->expected_value.value.double_value, actual.value.double_value); } -static bool compare_want_greater_double(Constraint *constraint, CgreenValue actual) { +static bool compare_want_greater_double(CgreenConstraint *constraint, CgreenValue actual) { return double_is_greater(constraint->expected_value.value.double_value, actual.value.double_value); } -static void test_want_double(Constraint *constraint, const char *function, CgreenValue actual, +static void test_want_double(CgreenConstraint *constraint, const char *function, CgreenValue actual, const char *test_file, int test_line, TestReporter *reporter) { (*reporter->assert_true)( reporter, @@ -601,11 +601,11 @@ static void test_want_double(Constraint *constraint, const char *function, Cgree constraint->parameter_name); } -static bool compare_do_not_want_double(Constraint *constraint, CgreenValue actual) { +static bool compare_do_not_want_double(CgreenConstraint *constraint, CgreenValue actual) { return !compare_want_double(constraint, actual); } -static void test_do_not_want_double(Constraint *constraint, const char *function, CgreenValue actual, +static void test_do_not_want_double(CgreenConstraint *constraint, const char *function, CgreenValue actual, const char *test_file, int test_line, TestReporter *reporter) { (*reporter->assert_true)( reporter, @@ -619,23 +619,23 @@ static void test_do_not_want_double(Constraint *constraint, const char *function constraint->parameter_name); } -void destroy_double_constraint(Constraint *constraint) { +void destroy_double_constraint(CgreenConstraint *constraint) { destroy_empty_constraint(constraint); } -void destroy_string_constraint(Constraint *constraint) { +void destroy_string_constraint(CgreenConstraint *constraint) { destroy_cgreen_value(constraint->expected_value); destroy_empty_constraint(constraint); } -static bool compare_true(Constraint *constraint, CgreenValue actual) { +static bool compare_true(CgreenConstraint *constraint, CgreenValue actual) { (void)constraint; (void)actual; return true; } -static void test_true(Constraint *constraint, const char *function, CgreenValue actual, +static void test_true(CgreenConstraint *constraint, const char *function, CgreenValue actual, const char *test_file, int test_line, TestReporter *reporter) { (void)constraint; (void)function; @@ -645,51 +645,51 @@ static void test_true(Constraint *constraint, const char *function, CgreenValue (void)reporter; } -bool values_are_strings_in(const Constraint *constraint) { +bool values_are_strings_in(const CgreenConstraint *constraint) { return is_string_comparing(constraint) && (constraint->expected_value.value.string_value != NULL); } -bool no_expected_value_in(const Constraint *constraint) { +bool no_expected_value_in(const CgreenConstraint *constraint) { return constraint->destroy == destroy_static_constraint; } -bool is_content_comparing(const Constraint *constraint) { +bool is_content_comparing(const CgreenConstraint *constraint) { return constraint->type == CONTENT_COMPARER; } -bool is_content_setting(const Constraint *constraint) { +bool is_content_setting(const CgreenConstraint *constraint) { return constraint->type == CONTENT_SETTER; } -bool is_not_content_setting(const Constraint *constraint) { +bool is_not_content_setting(const CgreenConstraint *constraint) { return !is_content_setting(constraint); } -bool is_string_comparing(const Constraint *constraint) { +bool is_string_comparing(const CgreenConstraint *constraint) { return constraint->type == STRING_COMPARER; } -bool is_double_comparing(const Constraint *constraint) { +bool is_double_comparing(const CgreenConstraint *constraint) { return constraint->type == DOUBLE_COMPARER; } -bool is_comparing(const Constraint *constraint) { +bool is_comparing(const CgreenConstraint *constraint) { return is_string_comparing(constraint) || is_content_comparing(constraint) || is_double_comparing(constraint) || constraint->type == VALUE_COMPARER; } -bool is_not_comparing(const Constraint *constraint) { +bool is_not_comparing(const CgreenConstraint *constraint) { return !is_comparing(constraint); } -bool is_parameter(const Constraint *constraint) { +bool is_parameter(const CgreenConstraint *constraint) { return is_comparing(constraint) || is_content_setting(constraint); } -bool constraint_is_for_parameter_in(const Constraint *constraint, const char *names) { +bool constraint_is_for_parameter_in(const CgreenConstraint *constraint, const char *names) { int i; bool found = false; diff --git a/src/constraint_internal.h b/src/constraint_internal.h index b3909c98..3cc4eac2 100644 --- a/src/constraint_internal.h +++ b/src/constraint_internal.h @@ -7,27 +7,27 @@ namespace cgreen { extern "C" { #endif -extern void destroy_empty_constraint(Constraint *constraint); -extern void destroy_static_constraint(Constraint *constraint); -extern void destroy_string_constraint(Constraint *constraint); -extern void destroy_double_constraint(Constraint *constraint); -extern void destroy_constraint(Constraint *); +extern void destroy_empty_constraint(CgreenConstraint *constraint); +extern void destroy_static_constraint(CgreenConstraint *constraint); +extern void destroy_string_constraint(CgreenConstraint *constraint); +extern void destroy_double_constraint(CgreenConstraint *constraint); +extern void destroy_constraint(CgreenConstraint *); extern void destroy_constraints(va_list constraints); -extern bool no_expected_value_in(const Constraint *constraint); -extern bool values_are_strings_in(const Constraint *constraint); -extern bool is_content_comparing(const Constraint *constraint); -extern bool is_content_setting(const Constraint *constraint); -extern bool is_not_content_setting(const Constraint *constraint); -extern bool is_string_comparing(const Constraint *constraint); -extern bool is_double_comparing(const Constraint *constraint); -extern bool is_comparing(const Constraint *constraint); -extern bool is_not_comparing(const Constraint *constraint); -extern bool is_parameter(const Constraint *); -extern bool constraint_is_not_for_parameter(const Constraint *, const char *); -extern bool constraint_is_for_parameter(const Constraint *, const char *); -extern bool constraint_is_for_parameter_in(const Constraint *, const char *); +extern bool no_expected_value_in(const CgreenConstraint *constraint); +extern bool values_are_strings_in(const CgreenConstraint *constraint); +extern bool is_content_comparing(const CgreenConstraint *constraint); +extern bool is_content_setting(const CgreenConstraint *constraint); +extern bool is_not_content_setting(const CgreenConstraint *constraint); +extern bool is_string_comparing(const CgreenConstraint *constraint); +extern bool is_double_comparing(const CgreenConstraint *constraint); +extern bool is_comparing(const CgreenConstraint *constraint); +extern bool is_not_comparing(const CgreenConstraint *constraint); +extern bool is_parameter(const CgreenConstraint *); +extern bool constraint_is_not_for_parameter(const CgreenConstraint *, const char *); +extern bool constraint_is_for_parameter(const CgreenConstraint *, const char *); +extern bool constraint_is_for_parameter_in(const CgreenConstraint *, const char *); extern bool doubles_are_equal(double tried, double expected); extern bool double_is_lesser(double actual, double expected); extern bool double_is_greater(double actual, double expected); diff --git a/src/constraints.c b/src/constraints.c index c08afb88..e9ff37c4 100644 --- a/src/constraints.c +++ b/src/constraints.c @@ -6,7 +6,7 @@ #include -Constraint static_is_non_null_constraint = { +CgreenConstraint static_is_non_null_constraint = { /* .type */ VALUE_COMPARER, /* .name */ "be non null", /* .destroy */ destroy_static_constraint, @@ -21,7 +21,7 @@ Constraint static_is_non_null_constraint = { /* .size_of_stored_value */ 0 }; -Constraint static_is_null_constraint = { +CgreenConstraint static_is_null_constraint = { /* .type */ VALUE_COMPARER, /* .name */ "be null", /* .destroy */ destroy_static_constraint, @@ -36,7 +36,7 @@ Constraint static_is_null_constraint = { /* .size_of_stored_value */ 0 }; -Constraint static_is_false_constraint = { +CgreenConstraint static_is_false_constraint = { /* .type */ VALUE_COMPARER, /* .name */ "be false", /* .destroy */ destroy_static_constraint, @@ -51,7 +51,7 @@ Constraint static_is_false_constraint = { /* .size_of_stored_value */ 0 }; -Constraint static_is_true_constraint = { +CgreenConstraint static_is_true_constraint = { /* .type */ VALUE_COMPARER, /* .name */ "be true", /* .destroy */ destroy_static_constraint, @@ -66,9 +66,9 @@ Constraint static_is_true_constraint = { /* .size_of_stored_value */ 0 }; -Constraint *is_non_null = &static_is_non_null_constraint; -Constraint *is_null = &static_is_null_constraint; -Constraint *is_false = &static_is_false_constraint; -Constraint *is_true = &static_is_true_constraint; +CgreenConstraint *is_non_null = &static_is_non_null_constraint; +CgreenConstraint *is_null = &static_is_null_constraint; +CgreenConstraint *is_false = &static_is_false_constraint; +CgreenConstraint *is_true = &static_is_true_constraint; /* vim: set ts=4 sw=4 et cindent: */ diff --git a/src/cpp_assertions.cpp b/src/cpp_assertions.cpp index 9915f35b..235b3a13 100644 --- a/src/cpp_assertions.cpp +++ b/src/cpp_assertions.cpp @@ -11,17 +11,17 @@ namespace cgreen { void assert_that_(const char *file, int line, const char *actual_string, - intptr_t actual, Constraint* constraint) { + intptr_t actual, CgreenConstraint* constraint) { assert_core_(file, line, actual_string, actual, constraint); } void assert_that_(const char *file, int line, const char *actual_string, - double actual, Constraint* constraint) { + double actual, CgreenConstraint* constraint) { assert_that_double_(file, line, actual_string, actual, constraint); } void assert_that_(const char *file, int line, const char *actual_string, - const std::string& actual, Constraint* constraint) { + const std::string& actual, CgreenConstraint* constraint) { // if they are using a string constraint, they are almost certainly meaning to do a deep comparison if (is_string_comparing(constraint)) { @@ -34,7 +34,7 @@ namespace cgreen { } void assert_that_(const char *file, int line, const char *actual_string, - const std::string *actual, Constraint* constraint) { + const std::string *actual, CgreenConstraint* constraint) { // if they are using a string constraint, they are almost certainly meaning to do a deep comparison if (is_string_comparing(constraint)) { diff --git a/src/cpp_constraint.cpp b/src/cpp_constraint.cpp index 1ebbcd43..2a039403 100644 --- a/src/cpp_constraint.cpp +++ b/src/cpp_constraint.cpp @@ -3,52 +3,52 @@ namespace cgreen { -Constraint *create_equal_to_string_constraint(const std::string& expected_value, const char *expected_value_name) +CgreenConstraint *create_equal_to_string_constraint(const std::string& expected_value, const char *expected_value_name) { return create_equal_to_string_constraint(expected_value.c_str(), expected_value_name); } -Constraint *create_equal_to_string_constraint(const std::string* expected_value, const char *expected_value_name) +CgreenConstraint *create_equal_to_string_constraint(const std::string* expected_value, const char *expected_value_name) { return create_equal_to_string_constraint(expected_value->c_str(), expected_value_name); } -Constraint *create_not_equal_to_string_constraint(const std::string& expected_value, const char *expected_value_name) +CgreenConstraint *create_not_equal_to_string_constraint(const std::string& expected_value, const char *expected_value_name) { return create_not_equal_to_string_constraint(expected_value.c_str(), expected_value_name); } -Constraint *create_not_equal_to_string_constraint(const std::string* expected_value, const char *expected_value_name) +CgreenConstraint *create_not_equal_to_string_constraint(const std::string* expected_value, const char *expected_value_name) { return create_not_equal_to_string_constraint(expected_value->c_str(), expected_value_name); } -Constraint *create_contains_string_constraint(const std::string& expected_value, const char *expected_value_name) +CgreenConstraint *create_contains_string_constraint(const std::string& expected_value, const char *expected_value_name) { return create_contains_string_constraint(expected_value.c_str(), expected_value_name); } -Constraint *create_contains_string_constraint(const std::string* expected_value, const char *expected_value_name) +CgreenConstraint *create_contains_string_constraint(const std::string* expected_value, const char *expected_value_name) { return create_contains_string_constraint(expected_value->c_str(), expected_value_name); } -Constraint *create_does_not_contain_string_constraint(const std::string& expected_value, const char *expected_value_name) +CgreenConstraint *create_does_not_contain_string_constraint(const std::string& expected_value, const char *expected_value_name) { return create_does_not_contain_string_constraint(expected_value.c_str(), expected_value_name); } -Constraint *create_does_not_contain_string_constraint(const std::string* expected_value, const char *expected_value_name) +CgreenConstraint *create_does_not_contain_string_constraint(const std::string* expected_value, const char *expected_value_name) { return create_does_not_contain_string_constraint(expected_value->c_str(), expected_value_name); } -Constraint *create_begins_with_string_constraint(const std::string& expected_value, const char *expected_value_name) +CgreenConstraint *create_begins_with_string_constraint(const std::string& expected_value, const char *expected_value_name) { return create_begins_with_string_constraint(expected_value.c_str(), expected_value_name); } -Constraint *create_begins_with_string_constraint(const std::string* expected_value, const char *expected_value_name) +CgreenConstraint *create_begins_with_string_constraint(const std::string* expected_value, const char *expected_value_name) { return create_begins_with_string_constraint(expected_value->c_str(), expected_value_name); } diff --git a/src/message_formatting.c b/src/message_formatting.c index 063e2b21..6681d6bc 100644 --- a/src/message_formatting.c +++ b/src/message_formatting.c @@ -80,7 +80,7 @@ static int find_index_of_difference(void *expected, void *actual, size_t size_to return -1; } -static bool actual_value_not_necessary_for(Constraint *constraint, const char *actual_string, const char *actual_value_string) { +static bool actual_value_not_necessary_for(CgreenConstraint *constraint, const char *actual_string, const char *actual_value_string) { (void)constraint; // UNUSED! return strings_are_equal(actual_string, actual_value_string) || strings_are_equal(actual_string, "true") || @@ -88,7 +88,7 @@ static bool actual_value_not_necessary_for(Constraint *constraint, const char *a } -bool parameters_are_not_valid_for(Constraint *constraint, intptr_t actual) { +bool parameters_are_not_valid_for(CgreenConstraint *constraint, intptr_t actual) { char *message = validation_failure_message_for(constraint, actual); bool not_valid = (strlen(message) > 0); @@ -98,7 +98,7 @@ bool parameters_are_not_valid_for(Constraint *constraint, intptr_t actual) { return not_valid; } -char *validation_failure_message_for(Constraint *constraint, intptr_t actual) { +char *validation_failure_message_for(CgreenConstraint *constraint, intptr_t actual) { const char *name_has_incorrect_size_message = "Wanted to compare contents with [%s],\n" "\t\tbut [%ld] was given for the comparison size."; @@ -165,12 +165,12 @@ char *validation_failure_message_for(Constraint *constraint, intptr_t actual) { } -static bool is_not_equal_to_string_constraint(Constraint *constraint) { +static bool is_not_equal_to_string_constraint(CgreenConstraint *constraint) { return strstr(constraint->name, "not ") != NULL && strstr(constraint->name, "equal ") != NULL; } -char *failure_message_for(Constraint *constraint, const char *actual_string, intptr_t actual_value) { +char *failure_message_for(CgreenConstraint *constraint, const char *actual_string, intptr_t actual_value) { char actual_int_value_string[32]; const char *constraint_as_string_format = "Expected [%s] to [%s]"; const char *expected_value_string_format = "[%s]"; diff --git a/src/mocks.c b/src/mocks.c index 7dfc5e56..da81040d 100644 --- a/src/mocks.c +++ b/src/mocks.c @@ -104,7 +104,7 @@ int number_of_parameter_constraints_in(const CgreenVector* constraints) { int i, parameters = 0; for (i = 0; i < cgreen_vector_size(constraints); i++) { - Constraint *constraint = (Constraint *)cgreen_vector_get(constraints, i); + CgreenConstraint *constraint = (CgreenConstraint *)cgreen_vector_get(constraints, i); if (is_comparing(constraint)) { parameters++; @@ -219,7 +219,7 @@ intptr_t mock_(TestReporter* test_reporter, const char *function, const char *mo // returning a double. for (i = 0; i < cgreen_vector_size(expectation->constraints); i++) { - Constraint *constraint = (Constraint *)cgreen_vector_get(expectation->constraints, i); + CgreenConstraint *constraint = (CgreenConstraint *)cgreen_vector_get(expectation->constraints, i); if(constraint->type == CALL_COUNTER) { expectation->number_times_called++; @@ -315,9 +315,9 @@ static CgreenVector *create_vector_of_actuals(va_list actuals, int count) { } -static Constraint *create_appropriate_equal_constraint_for(const char *parameter_name, +static CgreenConstraint *create_appropriate_equal_constraint_for(const char *parameter_name, CgreenValue actual) { - Constraint *constraint; + CgreenConstraint *constraint; if (actual.type == DOUBLE) constraint = create_equal_to_double_constraint(actual.value.double_value, parameter_name); @@ -334,14 +334,14 @@ static CgreenVector *create_equal_value_constraints_for(CgreenVector *parameter_ for (i = 0; i < cgreen_vector_size(parameter_names); i++) { const char* parameter_name = (const char*)cgreen_vector_get(parameter_names, i); CgreenValue actual = *(CgreenValue*)cgreen_vector_get(actual_values, i); - Constraint *constraint = create_appropriate_equal_constraint_for(parameter_name, actual); + CgreenConstraint *constraint = create_appropriate_equal_constraint_for(parameter_name, actual); cgreen_vector_add(constraints, constraint); } return constraints; } -Constraint *when_(const char *parameter, Constraint* constraint) { +CgreenConstraint *when_(const char *parameter, CgreenConstraint* constraint) { constraint->parameter_name = parameter; return constraint; } @@ -628,7 +628,7 @@ void print_learned_mocks(void) { const char *function_name = expectation->function; fprintf(stderr, "\texpect(%s", function_name); for (c = 0; c < cgreen_vector_size(expectation->constraints); c++) { - Constraint *constraint = (Constraint *)cgreen_vector_get(expectation->constraints, c); + CgreenConstraint *constraint = (CgreenConstraint *)cgreen_vector_get(expectation->constraints, c); if (constraint->expected_value.type == DOUBLE) fprintf(stderr, ", when(%s, is_equal_to_double(%f))", constraint->expected_value_name, constraint->expected_value.value.double_value); @@ -657,8 +657,8 @@ static CgreenVector *create_constraints_vector(void) { static CgreenVector *constraints_vector_from_va_list(va_list constraints) { CgreenVector *vector = create_constraints_vector(); - Constraint *constraint; - while ((constraint = va_arg(constraints, Constraint *)) != (Constraint *)0) { + CgreenConstraint *constraint; + while ((constraint = va_arg(constraints, CgreenConstraint *)) != (CgreenConstraint *)0) { cgreen_vector_add(vector, constraint); } return vector; @@ -816,7 +816,7 @@ static void apply_any_read_only_parameter_constraints(RecordedExpectation *expec int i; for (i = 0; i < cgreen_vector_size(expectation->constraints); i++) { - Constraint *constraint = (Constraint *)cgreen_vector_get(expectation->constraints, i); + CgreenConstraint *constraint = (CgreenConstraint *)cgreen_vector_get(expectation->constraints, i); if (constraint_is_not_for_parameter(constraint, parameter)) { continue; @@ -839,7 +839,7 @@ static void apply_any_read_only_parameter_constraints(RecordedExpectation *expec static void apply_any_content_setting_parameter_constraints(RecordedExpectation *expectation, const char *parameter, CgreenValue actual, TestReporter* test_reporter) { int i; for (i = 0; i < cgreen_vector_size(expectation->constraints); i++) { - Constraint *constraint = (Constraint *)cgreen_vector_get(expectation->constraints, i); + CgreenConstraint *constraint = (CgreenConstraint *)cgreen_vector_get(expectation->constraints, i); if (constraint_is_not_for_parameter(constraint, parameter)) { continue; @@ -862,7 +862,7 @@ static void apply_any_content_setting_parameter_constraints(RecordedExpectation static CgreenValue stored_result_or_default_for(CgreenVector* constraints) { int i; for (i = 0; i < cgreen_vector_size(constraints); i++) { - Constraint *constraint = (Constraint *)cgreen_vector_get(constraints, i); + CgreenConstraint *constraint = (CgreenConstraint *)cgreen_vector_get(constraints, i); if (constraint->type == RETURN_VALUE) { return constraint->expected_value; diff --git a/tests/constraint_tests.c b/tests/constraint_tests.c index a799b3ca..53e83653 100644 --- a/tests/constraint_tests.c +++ b/tests/constraint_tests.c @@ -38,12 +38,12 @@ static bool compare_double_constraint(Constraint *c, double x) { return r; } -Describe(Constraint); -BeforeEach(Constraint) {} -AfterEach(Constraint) {} +Describe(CgreenConstraint); +BeforeEach(CgreenConstraint) {} +AfterEach(CgreenConstraint) {} -Ensure(Constraint, default_destroy_clears_state) { - Constraint *constraint = create_constraint(); +Ensure(CgreenConstraint, default_destroy_clears_state) { + CgreenConstraint *constraint = create_constraint(); destroy_constraint(constraint); /* these tests correctly trip valgrind's use-after-free check, so @@ -58,8 +58,8 @@ Ensure(Constraint, default_destroy_clears_state) { */ } -Ensure(Constraint, parameter_name_matches_correctly) { - Constraint *constraint = +Ensure(CgreenConstraint, parameter_name_matches_correctly) { + CgreenConstraint *constraint = create_constraint(); constraint->type = VALUE_COMPARER; constraint->parameter_name = "label"; @@ -70,10 +70,10 @@ Ensure(Constraint, parameter_name_matches_correctly) { destroy_constraint(constraint); } -Ensure(Constraint, compare_contents_is_correct_on_larger_than_intptr_array) { +Ensure(CgreenConstraint, compare_contents_is_correct_on_larger_than_intptr_array) { int content[] = { 0, 1, 2, 3, 4, 5, 6, 7 ,8 ,9, 10, 11, 12, 13, 14, 15 }; int also_content[] = { 0, 1, 2, 3, 4, 5, 6, 7 ,8 ,9, 10, 11, 12, 13, 14, 15 }; - Constraint *is_equal_to_contents_constraint = + CgreenConstraint *is_equal_to_contents_constraint = create_equal_to_contents_constraint(content, sizeof(content), "content"); int not_content[] = { 0, 1, 2, 3, 4, 5, 6, 7, 108, 109, 110, 111, 112, 113, 114, 115 }; @@ -83,8 +83,8 @@ Ensure(Constraint, compare_contents_is_correct_on_larger_than_intptr_array) { destroy_constraint(is_equal_to_contents_constraint); } -Ensure(Constraint, compare_is_correct_when_using_integers) { - Constraint *is_equal_to_37 = create_equal_to_value_constraint(37, "37"); +Ensure(CgreenConstraint, compare_is_correct_when_using_integers) { + CgreenConstraint *is_equal_to_37 = create_equal_to_value_constraint(37, "37"); assert_that(compare_integer_constraint(is_equal_to_37, 37), is_true); assert_that(compare_integer_constraint(is_equal_to_37, 36), is_false); @@ -92,13 +92,13 @@ Ensure(Constraint, compare_is_correct_when_using_integers) { destroy_constraint(is_equal_to_37); } -Ensure(Constraint, compare_to_is_null_correctly) { +Ensure(CgreenConstraint, compare_to_is_null_correctly) { assert_that(0, is_null); assert_that(14, is_not_null); } -Ensure(Constraint, string_constraint_destroy_clears_state) { - Constraint *string_constraint = +Ensure(CgreenConstraint, string_constraint_destroy_clears_state) { + CgreenConstraint *string_constraint = create_equal_to_string_constraint("Hello", "user_greeting"); destroy_constraint(string_constraint); @@ -114,8 +114,8 @@ Ensure(Constraint, string_constraint_destroy_clears_state) { */ } -Ensure(Constraint, matching_strings_as_equal) { - Constraint *equals_string_hello_constraint = +Ensure(CgreenConstraint, matching_strings_as_equal) { + CgreenConstraint *equals_string_hello_constraint = create_equal_to_string_constraint("Hello", "user_greeting"); assert_that(compare_string_constraint(equals_string_hello_constraint, "Hello"), is_true); @@ -124,8 +124,8 @@ Ensure(Constraint, matching_strings_as_equal) { destroy_constraint(equals_string_hello_constraint); } -Ensure(Constraint, matching_null_string_against_non_null_string) { - Constraint *equals_string_hello_constraint = +Ensure(CgreenConstraint, matching_null_string_against_non_null_string) { + CgreenConstraint *equals_string_hello_constraint = create_equal_to_string_constraint("Hello", "user_greeting"); assert_that(compare_string_constraint(equals_string_hello_constraint, NULL), is_false); @@ -133,8 +133,8 @@ Ensure(Constraint, matching_null_string_against_non_null_string) { destroy_constraint(equals_string_hello_constraint); } -Ensure(Constraint, matching_against_null_string) { - Constraint *equals_null_string_constraint = +Ensure(CgreenConstraint, matching_against_null_string) { + CgreenConstraint *equals_null_string_constraint = create_equal_to_string_constraint((const char *)NULL, "user_greeting"); assert_that(compare_string_constraint(equals_null_string_constraint, NULL), is_true); @@ -143,8 +143,8 @@ Ensure(Constraint, matching_against_null_string) { destroy_constraint(equals_null_string_constraint); } -Ensure(Constraint, matching_doubles_as_equal_with_default_significance) { - Constraint *equal_to_double_37 = create_equal_to_double_constraint(37.0, "height"); +Ensure(CgreenConstraint, matching_doubles_as_equal_with_default_significance) { + CgreenConstraint *equal_to_double_37 = create_equal_to_double_constraint(37.0, "height"); assert_that(compare_double_constraint(equal_to_double_37, 37.0), is_true); assert_that(compare_double_constraint(equal_to_double_37, 36.0), is_false); @@ -152,8 +152,8 @@ Ensure(Constraint, matching_doubles_as_equal_with_default_significance) { destroy_constraint(equal_to_double_37); } -Ensure(Constraint, matching_doubles_respects_significant_figure_setting) { - Constraint *want_337 = create_equal_to_double_constraint(337.0, "height"); +Ensure(CgreenConstraint, matching_doubles_respects_significant_figure_setting) { + CgreenConstraint *want_337 = create_equal_to_double_constraint(337.0, "height"); significant_figures_for_assert_double_are(2); assert_that(compare_double_constraint(want_337, 339.0), is_true); @@ -175,12 +175,12 @@ Ensure(Constraint, matching_doubles_respects_significant_figure_setting) { // return our->length != 0; //} // -//Ensure(Constraint, unequal_structs_with_same_value_for_specific_field_compare_true) { +//Ensure(CgreenConstraint, unequal_structs_with_same_value_for_specific_field_compare_true) { // String name; // name.value = "bob"; // name.length = 3; // -// Constraint *string_constraint = with(name, is_non_empty_string); +// CgreenConstraint *string_constraint = with(name, is_non_empty_string); // // assert_that(compare_constraint(string_constraint, is_non_empty_string), is_equal_to(1)); // @@ -198,24 +198,24 @@ Ensure(Constraint, matching_doubles_respects_significant_figure_setting) { /* these misuse scenarios should be prevented by checks in higher-level constructs */ #ifdef CANNOT_CREATE_NULL_CONSTRAINTS -Ensure(Constraint, cannot_create_contents_constraint_with_null_content) { +Ensure(CgreenConstraint, cannot_create_contents_constraint_with_null_content) { const size_t NON_ZERO = !0; - Constraint *is_equal_to_contents_constraint = create_equal_to_contents_constraint(NULL, NON_ZERO, "NULL"); + CgreenConstraint *is_equal_to_contents_constraint = create_equal_to_contents_constraint(NULL, NON_ZERO, "NULL"); assert_that(is_equal_to_contents_constraint, is_null); } -Ensure(Constraint, cannot_create_contents_constraint_with_zero_size) { +Ensure(CgreenConstraint, cannot_create_contents_constraint_with_zero_size) { int content[] = { 0, 1, 2, 3, 4, 5, 6, 7 }; - Constraint *is_equal_to_contents_constraint = create_equal_to_contents_constraint(content, 0, "content"); + CgreenConstraint *is_equal_to_contents_constraint = create_equal_to_contents_constraint(content, 0, "content"); assert_that(is_equal_to_contents_constraint, is_null); } #endif -Ensure(Constraint, compare_equal_to_contents_is_false_on_null) { +Ensure(CgreenConstraint, compare_equal_to_contents_is_false_on_null) { int content[] = { 0, 1, 2, 3, 4, 5, 6, 7 }; - Constraint *is_equal_to_contents_constraint = + CgreenConstraint *is_equal_to_contents_constraint = create_equal_to_contents_constraint(content, sizeof(content), "content"); assert_that(compare_pointer_constraint(is_equal_to_contents_constraint, NULL), is_false); @@ -223,9 +223,9 @@ Ensure(Constraint, compare_equal_to_contents_is_false_on_null) { destroy_constraint(is_equal_to_contents_constraint); } -Ensure(Constraint, compare_not_equal_to_contents_is_false_on_null) { +Ensure(CgreenConstraint, compare_not_equal_to_contents_is_false_on_null) { int content[] = { 0, 1, 2, 3, 4, 5, 6, 7 }; - Constraint *is_not_equal_to_contents = + CgreenConstraint *is_not_equal_to_contents = create_not_equal_to_contents_constraint(content, sizeof(content), "content"); assert_that(compare_pointer_constraint(is_not_equal_to_contents, NULL), is_false); @@ -233,7 +233,7 @@ Ensure(Constraint, compare_not_equal_to_contents_is_false_on_null) { destroy_constraint(is_not_equal_to_contents); } -Ensure(Constraint, can_compare_to_hex) { +Ensure(CgreenConstraint, can_compare_to_hex) { char chars[3]; memset(chars, 0xaa, sizeof(chars)); assert_that((unsigned char)chars[0], is_equal_to_hex(0xaa)); @@ -241,20 +241,20 @@ Ensure(Constraint, can_compare_to_hex) { TestSuite *constraint_tests(void) { TestSuite *suite = create_test_suite(); - add_test_with_context(suite, Constraint, default_destroy_clears_state); - add_test_with_context(suite, Constraint, parameter_name_matches_correctly); - add_test_with_context(suite, Constraint, compare_is_correct_when_using_integers); - add_test_with_context(suite, Constraint, string_constraint_destroy_clears_state); - add_test_with_context(suite, Constraint, matching_strings_as_equal); - add_test_with_context(suite, Constraint, matching_null_string_against_non_null_string); - add_test_with_context(suite, Constraint, matching_against_null_string); - add_test_with_context(suite, Constraint, matching_doubles_as_equal_with_default_significance); - add_test_with_context(suite, Constraint, matching_doubles_respects_significant_figure_setting); - add_test_with_context(suite, Constraint, compare_contents_is_correct_on_larger_than_intptr_array); - add_test_with_context(suite, Constraint, compare_equal_to_contents_is_false_on_null); - add_test_with_context(suite, Constraint, compare_not_equal_to_contents_is_false_on_null); - add_test_with_context(suite, Constraint, can_compare_to_hex); -// add_test_with_context(suite, Constraint, unequal_structs_with_same_value_for_specific_field_compare_true); + add_test_with_context(suite, CgreenConstraint, default_destroy_clears_state); + add_test_with_context(suite, CgreenConstraint, parameter_name_matches_correctly); + add_test_with_context(suite, CgreenConstraint, compare_is_correct_when_using_integers); + add_test_with_context(suite, CgreenConstraint, string_constraint_destroy_clears_state); + add_test_with_context(suite, CgreenConstraint, matching_strings_as_equal); + add_test_with_context(suite, CgreenConstraint, matching_null_string_against_non_null_string); + add_test_with_context(suite, CgreenConstraint, matching_against_null_string); + add_test_with_context(suite, CgreenConstraint, matching_doubles_as_equal_with_default_significance); + add_test_with_context(suite, CgreenConstraint, matching_doubles_respects_significant_figure_setting); + add_test_with_context(suite, CgreenConstraint, compare_contents_is_correct_on_larger_than_intptr_array); + add_test_with_context(suite, CgreenConstraint, compare_equal_to_contents_is_false_on_null); + add_test_with_context(suite, CgreenConstraint, compare_not_equal_to_contents_is_false_on_null); + add_test_with_context(suite, CgreenConstraint, can_compare_to_hex); +// add_test_with_context(suite, CgreenConstraint, unequal_structs_with_same_value_for_specific_field_compare_true); return suite; } diff --git a/tests/message_formatting_tests.c b/tests/message_formatting_tests.c index a0b8384e..6bc49a8a 100644 --- a/tests/message_formatting_tests.c +++ b/tests/message_formatting_tests.c @@ -13,7 +13,7 @@ AfterEach(MessageFormatting) {} Ensure(MessageFormatting, can_show_failure_message_containing_percent_sign) { const char *string_with_percent = "This contains %!"; - Constraint *constraint = + CgreenConstraint *constraint = create_equal_to_string_constraint(string_with_percent, "string_with_percent"); char *failure_message = failure_message_for(constraint, "actual_string", (intptr_t)"This contains another %!"); @@ -27,7 +27,7 @@ Ensure(MessageFormatting, can_show_failure_message_containing_percent_sign) { Ensure(MessageFormatting, shows_offset_as_zero_based) { char actual_data[] = {0x0a, 0x0b, 0x0c, 0x0d}; char expected_data[] = {0x0b, 0x0b, 0x0c, 0x0d}; - Constraint *constraint = + CgreenConstraint *constraint = create_equal_to_contents_constraint(expected_data, 4, "expectd_data"); char *failure_message = failure_message_for(constraint, "actual_data", (intptr_t)actual_data);