va_start(args, format);
return_value = vsnprintf(temporary_buffer, sizeof(temporary_buffer),
format, args);
- check_expected(temporary_buffer);
+ check_expected_ptr(temporary_buffer);
va_end(args);
return return_value;
}
va_start(args, format);
return_value = vsnprintf(temporary_buffer, sizeof(temporary_buffer),
format, args);
- check_expected(temporary_buffer);
+ check_expected_ptr(temporary_buffer);
va_end(args);
return return_value;
}
static void test_find_operator_function_by_string_valid_null_functions(void **state) {
(void) state; /* unused */
- assert_int_equal(find_operator_function_by_string(0, NULL, "test"), NULL);
+ assert_int_equal(
+ cast_ptr_to_largest_integral_type(
+ find_operator_function_by_string(0, NULL, "test")),
+ 0);
}
/* Ensure find_operator_function_by_string() returns NULL when searching for
(void) state; /* unused */
- assert_int_equal(find_operator_function_by_string(
- array_length(operator_functions), operator_functions, "test"),
- NULL);
+ assert_int_equal(
+ cast_ptr_to_largest_integral_type(
+ find_operator_function_by_string(array_length(operator_functions),
+ operator_functions,
+ "test")),
+ 0);
}
/* Ensure find_operator_function_by_string() returns the correct function when
(void) state; /* unused */
- assert_int_equal(find_operator_function_by_string(
- array_length(operator_functions), operator_functions, "-"),
+ assert_int_equal(
+ cast_ptr_to_largest_integral_type(
+ find_operator_function_by_string(array_length(operator_functions),
+ operator_functions,
+ "-")),
0xDEADBEEF);
}
"1", "+", "3", "*", "10",
};
int number_of_intermediate_values;
- int *intermediate_values;
+ int *intermediate_values = NULL;
int error_occurred;
(void) state; /* unused */
&intermediate_values, &error_occurred), 40);
assert_int_equal(error_occurred, 0);
- assert_true(intermediate_values);
+ assert_non_null(intermediate_values);
assert_int_equal(intermediate_values[0], 4);
assert_int_equal(intermediate_values[1], 40);
test_free(intermediate_values);
bool knows_dish;
char *dish;
- check_expected(order);
+ check_expected_ptr(order);
knows_dish = mock_type(bool);
if (knows_dish == false) {
will_return(__wrap_chef_cook, true);
will_return(__wrap_chef_cook, true);
/* The result will be a hotdog and the cooking process will succeed */
- will_return(__wrap_chef_cook, "hotdog");
+ will_return(__wrap_chef_cook, cast_ptr_to_largest_integral_type("hotdog"));
will_return(__wrap_chef_cook, 0);
/* Test the waiter */
* We expect the waiter to handle the bad dish and return an error
* code
*/
- will_return(__wrap_chef_cook, "burger");
+ will_return(__wrap_chef_cook, cast_ptr_to_largest_integral_type("burger"));
will_return(__wrap_chef_cook, 0);
/* Test the waiter */
/* Perform an unsigned cast to uintptr_t. */
#define cast_to_pointer_integral_type(value) \
- ((uintptr_t)(value))
+ ((uintptr_t)((size_t)(value)))
/* Perform a cast of a pointer to uintmax_t */
#define cast_ptr_to_largest_integral_type(value) \
cast_to_largest_integral_type(parameter))
#endif
+#ifdef DOXYGEN
+/**
+ * @brief Determine whether a function parameter is correct.
+ *
+ * This ensures the next value queued by one of the expect_*() macros matches
+ * the specified variable.
+ *
+ * This function needs to be called in the mock object.
+ *
+ * @param[in] #parameter The pointer to check.
+ */
+void check_expected_ptr(#parameter);
+#else
+#define check_expected_ptr(parameter) \
+ _check_expected(__func__, #parameter, __FILE__, __LINE__, \
+ cast_ptr_to_largest_integral_type(parameter))
+#endif
+
/** @} */
/**