void assert_that_double_(const char *file, int line, const char *expression, double actual, Constraint* constraint) { BoxedDouble* boxed_actual; if (NULL != constraint && is_not_comparing(constraint)) { (*get_test_reporter()->assert_true)( get_test_reporter(), file, line, false, "\tGot constraint of type [%s], but they are not allowed for assertions, only in mock expectations.", constraint->name); constraint->destroy(constraint); return; } boxed_actual = (BoxedDouble*)box_double(actual); (*get_test_reporter()->assert_true)(get_test_reporter(), file, line, (*constraint->compare)(constraint, (intptr_t)boxed_actual), "Expected [%s] to [%s] [%s] within [%d] significant figures\n" "\t\tactual value:\t%08f\n" "\t\texpected value:\t%08f", expression, constraint->name, constraint->expected_value_name, get_significant_figures(), actual, as_double(constraint->expected_value)); free(boxed_actual); constraint->destroy(constraint); }
bool constraint_is_not_for_parameter(const Constraint *constraint, const char *parameter) { if (is_not_comparing(constraint) && is_not_content_setting(constraint)) { return true; } return strcmp(constraint->parameter_name, parameter) != 0; }
void assert_that_(const char *file, int line, const char *actual_string, intptr_t actual, Constraint* constraint) { char *failure_message; if (NULL != constraint && is_not_comparing(constraint)) { (*get_test_reporter()->assert_true)( get_test_reporter(), file, line, false, "\tGot constraint of type [%s], but they are not allowed for assertions, only in mock expectations.", constraint->name); constraint->destroy(constraint); return; } if (parameters_are_not_valid_for(constraint, actual)) { char *validation_message = validation_failure_message_for(constraint, actual); (*get_test_reporter()->assert_true)( get_test_reporter(), file, line, false, validation_message); constraint->destroy(constraint); free(validation_message); return; } failure_message = constraint->failure_message(constraint, actual_string, actual); (*get_test_reporter()->assert_true)( get_test_reporter(), file, line, (*constraint->compare)(constraint, actual), failure_message ); constraint->destroy(constraint); free(failure_message); }