static CgreenVector *create_vector_of_actuals(va_list actuals, int count) { int i; CgreenVector *actual_values = create_cgreen_vector(NULL); for (i = 0; i < count; i++) { uintptr_t actual = va_arg(actuals, uintptr_t); cgreen_vector_add(actual_values, (void*)actual); } return actual_values; }
static RecordedExpectation *create_recorded_expectation(const char *function, const char *test_file, int test_line, va_list constraints) { RecordedExpectation *expectation = NULL; Constraint *constraint = NULL; ensure_expectation_queue_exists(); expectation = (RecordedExpectation *)malloc(sizeof(RecordedExpectation)); expectation->function = function; expectation->test_file = test_file; expectation->test_line = test_line; expectation->constraints = create_cgreen_vector(&destroy_constraint); while ((constraint = va_arg(constraints, Constraint *)) != (Constraint *)0) { cgreen_vector_add(expectation->constraints, constraint); } cgreen_vector_add(expectation_queue, expectation); return expectation; }
void enable_mock_(const char *function) { if (enabled_mocks == NULL) { enabled_mocks = create_cgreen_vector(NULL); } cgreen_vector_add(enabled_mocks, (void *)function); }
static void ensure_unwanted_calls_list_exists() { if (unwanted_calls == NULL) { unwanted_calls = create_cgreen_vector(&free); } }
static void ensure_expectation_queue_exists() { if (expectation_queue == NULL) { expectation_queue = create_cgreen_vector(&destroy_expectation); } }
static void ensure_result_queue_exists() { if (result_queue == NULL) { result_queue = create_cgreen_vector(&free); } }
static void ensure_expectation_queue_exists() { if (global_expectation_queue == NULL) { global_expectation_queue = create_cgreen_vector((GenericDestructor)&destroy_expectation); } }
static void ensure_learned_mock_calls_list_exists() { if (learned_mock_calls == NULL) { // learned_mock_calls are __func__, so there's nothing to destroy learned_mock_calls = create_cgreen_vector(NULL); } }
static void ensure_successfully_mocked_calls_list_exists() { if (successfully_mocked_calls == NULL) { // successfully_mocked_calls are __func__, so there's nothing to destroy successfully_mocked_calls = create_cgreen_vector(NULL); } }
static CgreenVector *create_constraints_vector(void) { return create_cgreen_vector((GenericDestructor)&destroy_constraint); }