25#define CMOCKA_DLLEXTERN __declspec(dllexport)
27#define CMOCKA_DLLEXTERN __declspec(dllimport)
32#define __func__ __FUNCTION__
36#define inline __inline
50#ifndef CMOCKA_DLLEXTERN
51#define CMOCKA_DLLEXTERN
94#ifndef CMOCKA_NO_STANDARD_INCLUDES
113#define cast_to_intmax_type(value) \
117#define cast_to_uintmax_type(value) \
121#define cast_ptr_to_uintmax_type(value) \
122 ((uintmax_t)(uintptr_t)(value))
125#define cast_to_double_type(value) \
129#define cast_to_float_type(value) \
139#define cast_to_void_pointer(ptr) \
140 ((void *)(uintptr_t)(ptr))
149#define cast_int_to_cmocka_value(value) \
152 .uint_val = (uintmax_t)(value) \
156#define cast_ptr_to_cmocka_value(value) \
159 .const_ptr = (value) \
163#define assign_int_to_cmocka_value(value) \
170#define assign_uint_to_cmocka_value(value) \
173 .uint_val = (value) \
177#define assign_float_to_cmocka_value(value) \
180 .float_val = ((float)(value)) \
184#define assign_double_to_cmocka_value(value) \
187 .real_val = ((double)(value)) \
191#define cmocka_tostring(val) #val
196#define CMOCKA_PRINTF_ATTRIBUTE(a,b) \
197 __attribute__ ((__format__ (__printf__, a, b)))
199#define CMOCKA_PRINTF_ATTRIBUTE(a,b)
202#if defined(CMOCKA_DISABLE_DEPRECATION_WARNINGS) || defined(CMOCKA_DISABLE_DEPRECTATION_WARNINGS)
203#define CMOCKA_DEPRECATED
204#define CMOCKA_DEPRECATION_WARNING(msg)
209#define CMOCKA_DEPRECATED __attribute__ ((deprecated))
214#define CMOCKA_DEPRECATED
218#if defined(__GNUC__) || defined(__clang__)
222#define CMOCKA_DEPRECATION_WARNING(msg) \
224 typedef int cmocka_macro __attribute__((deprecated(msg))); \
225 cmocka_macro cmocka_deprecated_var __attribute__((unused)) = 0; \
226 (void)sizeof(cmocka_deprecated_var); \
228#elif defined(_MSC_VER)
229#define CMOCKA_DEPRECATION_WARNING(msg) __pragma(message("warning: " msg))
231#define CMOCKA_DEPRECATION_WARNING(msg)
237#define CMOCKA_NORETURN __attribute__ ((noreturn))
238#elif defined(_MSC_VER)
239#define CMOCKA_NORETURN __declspec(noreturn)
241#define CMOCKA_NORETURN
257#ifdef __has_attribute
258#if __has_attribute(access) && (defined(__clang__) || __GNUC__ >= 11)
259#define CMOCKA_NO_ACCESS_ATTRIBUTE \
260 __attribute__((access(none, 1), access(none, 2)))
263#ifndef CMOCKA_NO_ACCESS_ATTRIBUTE
264#define CMOCKA_NO_ACCESS_ATTRIBUTE
278#if (defined(__clang__) && __clang_major__ >= 8) || \
279 (defined(_MSC_VER) && defined(_MSVC_TRADITIONAL) && !_MSVC_TRADITIONAL) || \
280 (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L)
281#define CMOCKA_VA_ARGS(...) __VA_OPT__(,) __VA_ARGS__
286#define CMOCKA_VA_ARGS(...) , ##__VA_ARGS__
356#define WILL_RETURN_ALWAYS -1
369#define WILL_RETURN_ONCE -2
380#define EXPECT_ALWAYS -1
391#define EXPECT_MAYBE -2
403#define mock() (_mock(__func__, __FILE__, __LINE__, NULL)).uint_val
430#define mock_type(type) ((type) mock())
461#define has_mock() _has_mock(__func__)
481#define mock_int() (_mock(__func__, __FILE__, __LINE__, NULL)).int_val
501#define mock_uint() (_mock(__func__, __FILE__, __LINE__, "uintmax_t")).uint_val
515#define mock_float() (_mock(__func__, __FILE__, __LINE__, NULL)).float_val
529#define mock_double() (_mock(__func__, __FILE__, __LINE__, NULL)).real_val
555#define mock_ptr_type(type) \
556 ((type)(_mock(__func__, __FILE__, __LINE__, NULL)).ptr)
583#define mock_ptr_type_checked(type) \
584 ((type)(_mock(__func__, __FILE__, __LINE__, #type)).ptr)
623#define mock_parameter(name) \
624 (_mock_parameter(__func__, #name, __FILE__, __LINE__, NULL)).uint_val
650#type mock_parameter_type(#name, #type);
652#define mock_parameter_type(name, type) ((type) mock_parameter(#name))
675#define mock_parameter_int(name) \
676 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "intmax_t")).int_val
699#define mock_parameter_uint(name) \
700 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "uintmax_t")).uint_val
723#define mock_parameter_float(name) \
724 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "float")).float_val
747#define mock_parameter_double(name) \
748 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "double")).real_val
770#define mock_parameter_ptr(name) \
771 ((_mock_parameter(__func__, #name, __FILE__, __LINE__, NULL)).ptr)
797#define mock_parameter_ptr_type(name, type) \
798 ((type)(_mock_parameter(__func__, #name, __FILE__, __LINE__, #type)).ptr)
811#define mock_errno() \
813 intmax_t err = (_mock_parameter( \
861#define will_return(function, value) \
862 _will_return(cmocka_tostring(function), \
866 cast_int_to_cmocka_value(value), \
896#define will_return_int(function, value) \
897 _will_return(#function, \
901 assign_int_to_cmocka_value(value), \
941#define will_return_int_count(function, value, count) \
942 _will_return(#function, \
946 assign_int_to_cmocka_value(value), \
977#define will_return_uint(function, value) \
978 _will_return(#function, \
982 assign_uint_to_cmocka_value(value), \
1022#define will_return_uint_count(function, value, count) \
1023 _will_return(#function, \
1027 assign_uint_to_cmocka_value(value), \
1058#define will_return_float(function, value) \
1059 _will_return(#function, \
1063 assign_float_to_cmocka_value(value), \
1103#define will_return_float_count(function, value, count) \
1104 _will_return(#function, \
1108 assign_float_to_cmocka_value(value), \
1139#define will_return_double(function, value) \
1140 _will_return(#function, \
1144 assign_double_to_cmocka_value(value), \
1184#define will_return_double_count(function, value, count) \
1185 _will_return(#function, \
1189 assign_double_to_cmocka_value(value), \
1211#define will_return_int_always(function, value) \
1212 will_return_int_count(function, (value), WILL_RETURN_ALWAYS)
1234#define will_return_uint_always(function, value) \
1235 will_return_uint_count(function, (value), WILL_RETURN_ALWAYS)
1256#define will_return_float_always(function, value) \
1257 will_return_float_count(function, (value), WILL_RETURN_ALWAYS)
1278#define will_return_double_always(function, value) \
1279 will_return_double_count(function, (value), WILL_RETURN_ALWAYS)
1288#define will_return_count(function, value, count) \
1290 CMOCKA_DEPRECATION_WARNING( \
1291 "will_return_count: use will_return_int_count or " \
1292 "will_return_uint_count instead") \
1293 _will_return(cmocka_tostring(function), \
1297 cast_int_to_cmocka_value(value), \
1308#define will_return_always(function, value) \
1310 CMOCKA_DEPRECATION_WARNING( \
1311 "will_return_always: use will_return_int_always or " \
1312 "will_return_uint_always instead") \
1313 will_return_count(function, (value), WILL_RETURN_ALWAYS); \
1341#define will_return_int_maybe(function, value) \
1342 will_return_int_count(function, (value), WILL_RETURN_ONCE)
1370#define will_return_uint_maybe(function, value) \
1371 will_return_uint_count(function, (value), WILL_RETURN_ONCE)
1398#define will_return_float_maybe(function, value) \
1399 will_return_float_count(function, (value), WILL_RETURN_ONCE)
1426#define will_return_double_maybe(function, value) \
1427 will_return_double_count(function, (value), WILL_RETURN_ONCE)
1436#define will_return_maybe(function, value) \
1438 CMOCKA_DEPRECATION_WARNING( \
1439 "will_return_maybe: use will_return_int_maybe or " \
1440 "will_return_uint_maybe instead") \
1441 will_return_count(function, (value), WILL_RETURN_ONCE); \
1472#define will_return_ptr(function, value) \
1473 _will_return(#function, \
1477 cast_ptr_to_cmocka_value(value), \
1512#define will_return_ptr_type(function, value, type) \
1513 _will_return(#function, \
1517 cast_ptr_to_cmocka_value(value), \
1539#define will_return_ptr_count(function, value, count) \
1540 _will_return(#function, \
1544 cast_ptr_to_cmocka_value(value), \
1566#define will_return_ptr_always(function, value) \
1567 will_return_ptr_count(function, (value), WILL_RETURN_ALWAYS)
1594#define will_return_ptr_maybe(function, value) \
1595 will_return_ptr_count(function, (value), WILL_RETURN_ONCE)
1645#define will_set_parameter(function, name, value) \
1646 _will_set_parameter(cmocka_tostring(function), \
1651 cast_int_to_cmocka_value(value), \
1689#define will_set_parameter_int(function, name, value) \
1690 _will_set_parameter(#function, \
1695 assign_int_to_cmocka_value(value), \
1735#define will_set_parameter_uint(function, name, value) \
1736 _will_set_parameter(#function, \
1741 assign_uint_to_cmocka_value(value), \
1780#define will_set_parameter_float(function, name, value) \
1781 _will_set_parameter(#function, \
1786 assign_float_to_cmocka_value(value), \
1826#define will_set_parameter_double(function, name, value) \
1827 _will_set_parameter(#function, \
1832 assign_double_to_cmocka_value(value), \
1858#define will_set_parameter_int_count(function, name, value, count) \
1859 _will_set_parameter(#function, \
1864 assign_int_to_cmocka_value(value), \
1893#define will_set_parameter_uint_count(function, name, value, count) \
1894 _will_set_parameter(#function, \
1899 assign_uint_to_cmocka_value(value), \
1925#define will_set_parameter_float_count(function, name, value, count) \
1926 _will_set_parameter(#function, \
1931 assign_float_to_cmocka_value(value), \
1957#define will_set_parameter_double_count(function, name, value, count) \
1958 _will_set_parameter(#function, \
1963 assign_double_to_cmocka_value(value), \
1974#define will_set_parameter_count(function, name, value, count) \
1976 CMOCKA_DEPRECATION_WARNING( \
1977 "will_set_parameter_count: use will_set_parameter_int_count or " \
1978 "will_set_parameter_uint_count instead") \
1979 _will_set_parameter(cmocka_tostring(function), \
1984 cast_int_to_cmocka_value(value), \
2011#define will_set_parameter_int_always(function, name, value) \
2012 will_set_parameter_int_count(function, name, (value), WILL_RETURN_ALWAYS)
2037#define will_set_parameter_uint_always(function, name, value) \
2038 will_set_parameter_uint_count(function, name, (value), WILL_RETURN_ALWAYS)
2063#define will_set_parameter_float_always(function, name, value) \
2064 will_set_parameter_float_count(function, name, (value), WILL_RETURN_ALWAYS)
2089#define will_set_parameter_double_always(function, name, value) \
2090 will_set_parameter_double_count(function, name, (value), WILL_RETURN_ALWAYS)
2100#define will_set_parameter_always(function, name, value) \
2102 CMOCKA_DEPRECATION_WARNING( \
2103 "will_set_parameter_always: use will_set_parameter_int_always or " \
2104 "will_set_parameter_uint_always instead") \
2105 will_set_parameter_count(function, name, (value), WILL_RETURN_ALWAYS); \
2132#define will_set_parameter_int_maybe(function, name, value) \
2133 will_set_parameter_int_count(function, name, (value), WILL_RETURN_ONCE)
2159#define will_set_parameter_uint_maybe(function, name, value) \
2160 will_set_parameter_uint_count(function, name, (value), WILL_RETURN_ONCE)
2186#define will_set_parameter_float_maybe(function, name, value) \
2187 will_set_parameter_float_count(function, name, (value), WILL_RETURN_ONCE)
2213#define will_set_parameter_double_maybe(function, name, value) \
2214 will_set_parameter_double_count(function, name, (value), WILL_RETURN_ONCE)
2224#define will_set_parameter_maybe(function, name, value) \
2226 CMOCKA_DEPRECATION_WARNING( \
2227 "will_set_parameter_maybe: use will_set_parameter_int_maybe or " \
2228 "will_set_parameter_uint_maybe instead") \
2229 will_set_parameter_count(function, name, (value), WILL_RETURN_ONCE); \
2264#define will_set_parameter_ptr(function, name, value) \
2265 _will_set_parameter(#function, \
2270 cast_ptr_to_cmocka_value(value), \
2310#define will_set_parameter_ptr_type(function, name, value, type) \
2311 _will_set_parameter(#function, \
2316 cast_ptr_to_cmocka_value(value), \
2361#define will_set_parameter_ptr_count(function, name, value, count) \
2362 _will_set_parameter(#function, \
2367 cast_ptr_to_cmocka_value(value), \
2400#define will_set_parameter_ptr_always(function, name, value) \
2401 will_set_parameter_ptr_count(function, name, (value), WILL_RETURN_ALWAYS)
2435#define will_set_parameter_ptr_maybe(function, name, value) \
2436 will_set_parameter_ptr_count(function, name, (value), WILL_RETURN_ONCE)
2466#define will_set_errno(function, value) \
2467 _will_set_parameter(#function, \
2472 assign_int_to_cmocka_value(value), \
2517#define will_set_errno_count(function, value, count) \
2518 _will_set_parameter(#function, \
2523 assign_int_to_cmocka_value(value), \
2552#define will_set_errno_always(function, value) \
2553 will_set_errno_count(function, (value), WILL_RETURN_ALWAYS);
2581#define will_set_errno_maybe(function, value) \
2582 will_set_errno_count(function, (value), WILL_RETURN_ONCE);
2640 const void *check_data);
2642#define expect_check(function, parameter, check_function, check_data) \
2644 CMOCKA_DEPRECATION_WARNING( \
2645 "expect_check: use expect_check_data instead") \
2646 _expect_check(cmocka_tostring(function), \
2647 cmocka_tostring(parameter), \
2651 cast_to_uintmax_type(check_data), \
2665 const void *check_data,
2668#define expect_check_count( \
2669 function, parameter, check_function, check_data, count) \
2671 CMOCKA_DEPRECATION_WARNING( \
2672 "expect_check_count: use expect_check_data_count instead") \
2673 _expect_check(cmocka_tostring(function), \
2674 cmocka_tostring(parameter), \
2678 cast_to_uintmax_type(check_data), \
2845#define expect_check_data(function, parameter, check_function, check_data) \
2846 _expect_check_data(cmocka_tostring(function), \
2847 cmocka_tostring(parameter), \
2927#define expect_check_data_count(function, \
2932 _expect_check_data(cmocka_tostring(function), \
2933 cmocka_tostring(parameter), \
2948#define expect_in_set(function, parameter, value_array) \
2950 CMOCKA_DEPRECATION_WARNING("expect_in_set: use expect_int_in_set or " \
2951 "expect_uint_in_set instead") \
2952 expect_in_set_count(function, parameter, value_array, 1); \
2973#define expect_int_in_set(function, parameter, value_array) \
2974 expect_int_in_set_count(function, parameter, value_array, 1)
2992void expect_in_set(#function, #parameter, intmax_t value_array[]);
2994#define expect_uint_in_set(function, parameter, value_array) \
2995 expect_uint_in_set_count(function, parameter, value_array, 1)
3004#define expect_in_set_count(function, parameter, value_array, count) \
3006 CMOCKA_DEPRECATION_WARNING( \
3007 "expect_in_set_count: use expect_int_in_set_count or " \
3008 "expect_uint_in_set_count instead") \
3009 _expect_uint_in_set(cmocka_tostring(function), \
3010 cmocka_tostring(parameter), \
3014 sizeof(value_array) / sizeof((value_array)[0]), \
3040#define expect_int_in_set_count(function, parameter, value_array, count) \
3041 _expect_int_in_set(cmocka_tostring(function), \
3042 cmocka_tostring(parameter), \
3046 sizeof(value_array) / sizeof((value_array)[0]), \
3071#define expect_uint_in_set_count(function, parameter, value_array, count) \
3072 _expect_uint_in_set(cmocka_tostring(function), \
3073 cmocka_tostring(parameter), \
3077 sizeof(value_array) / sizeof((value_array)[0]), \
3087#define expect_not_in_set(function, parameter, value_array) \
3089 CMOCKA_DEPRECATION_WARNING( \
3090 "expect_not_in_set: use expect_int_not_in_set or " \
3091 "expect_uint_not_in_set instead") \
3092 expect_not_in_set_count(function, parameter, value_array, 1); \
3102#define expect_not_in_set_count(function, parameter, value_array, count) \
3104 CMOCKA_DEPRECATION_WARNING( \
3105 "expect_not_in_set_count: use expect_int_not_in_set_count or " \
3106 "expect_uint_not_in_set_count instead") \
3107 _expect_not_in_set(cmocka_tostring(function), \
3108 cmocka_tostring(parameter), \
3112 sizeof(value_array) / sizeof((value_array)[0]), \
3134#define expect_int_not_in_set(function, parameter, value_array) \
3135 expect_int_not_in_set_count(function, parameter, value_array, 1)
3159 intmax_t value_array[],
3162#define expect_int_not_in_set_count(function, parameter, value_array, count) \
3163 _expect_int_not_in_set(cmocka_tostring(function), \
3164 cmocka_tostring(parameter), \
3168 sizeof(value_array) / sizeof((value_array)[0]), \
3189#define expect_uint_not_in_set(function, parameter, value_array) \
3190 expect_uint_not_in_set_count(function, parameter, value_array, 1)
3214 uintmax_t value_array[],
3217#define expect_uint_not_in_set_count(function, parameter, value_array, count) \
3218 _expect_uint_not_in_set(cmocka_tostring(function), \
3219 cmocka_tostring(parameter), \
3223 sizeof(value_array) / sizeof((value_array)[0]), \
3246#define expect_float_in_set(function, parameter, value_array, epsilon) \
3247 expect_float_in_set_count(function, parameter, value_array, epsilon, 1)
3273#define expect_float_in_set_count(function, parameter, value_array, epsilon, count) \
3274 _expect_float_in_set(cmocka_tostring(function), \
3275 cmocka_tostring(parameter), \
3279 sizeof(value_array) / sizeof((value_array)[0]), \
3303#define expect_float_not_in_set(function, parameter, value_array, epsilon) \
3304 expect_float_not_in_set_count(function, parameter, value_array, epsilon, 1)
3330#define expect_float_not_in_set_count(function, parameter, value_array, epsilon, count) \
3331 _expect_float_not_in_set(cmocka_tostring(function), \
3332 cmocka_tostring(parameter), \
3336 sizeof(value_array) / sizeof((value_array)[0]), \
3348#define expect_in_range(function, parameter, minimum, maximum) \
3350 CMOCKA_DEPRECATION_WARNING( \
3351 "expect_in_range: use expect_int_in_range or " \
3352 "expect_uint_in_range instead") \
3353 expect_in_range_count(function, parameter, minimum, maximum, 1); \
3363#define expect_in_range_count(function, parameter, minimum, maximum, count) \
3365 CMOCKA_DEPRECATION_WARNING( \
3366 "expect_in_range_count: use expect_int_in_range_count or " \
3367 "expect_uint_in_range_count instead") \
3368 _expect_in_range(cmocka_tostring(function), \
3369 cmocka_tostring(parameter), \
3400#define expect_int_in_range(function, parameter, minimum, maximum) \
3401 expect_int_in_range_count(function, parameter, minimum, maximum, 1)
3431#define expect_int_in_range_count( \
3432 function, parameter, minimum, maximum, count) \
3433 _expect_int_in_range(cmocka_tostring(function), \
3434 cmocka_tostring(parameter), \
3464#define expect_uint_in_range(function, parameter, minimum, maximum) \
3465 expect_uint_in_range_count(function, parameter, minimum, maximum, 1)
3496#define expect_uint_in_range_count( \
3497 function, parameter, minimum, maximum, count) \
3498 _expect_uint_in_range(cmocka_tostring(function), \
3499 cmocka_tostring(parameter), \
3526#define expect_not_in_range(function, parameter, minimum, maximum) \
3527 expect_not_in_range_count(function, parameter, minimum, maximum, 1)
3553#define expect_not_in_range_count(function, parameter, minimum, maximum, \
3555 _expect_not_in_range(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
3556 minimum, maximum, count)
3581#define expect_int_not_in_range(function, parameter, minimum, maximum) \
3582 expect_int_not_in_range_count(function, parameter, minimum, maximum, 1)
3612#define expect_int_not_in_range_count( \
3613 function, parameter, minimum, maximum, count) \
3614 _expect_int_not_in_range(cmocka_tostring(function), \
3615 cmocka_tostring(parameter), \
3645#define expect_uint_not_in_range(function, parameter, minimum, maximum) \
3646 expect_uint_not_in_range_count(function, parameter, minimum, maximum, 1)
3677#define expect_uint_not_in_range_count( \
3678 function, parameter, minimum, maximum, count) \
3679 _expect_uint_not_in_range(cmocka_tostring(function), \
3680 cmocka_tostring(parameter), \
3709#define expect_float_in_range(function, parameter, minimum, maximum, epsilon) \
3710 expect_float_in_range_count(function, parameter, minimum, maximum, epsilon, 1)
3738#define expect_float_in_range_count(function, parameter, minimum, maximum, epsilon, count) \
3739 _expect_float_in_range(cmocka_tostring(function), \
3740 cmocka_tostring(parameter), \
3743 cast_to_double_type(minimum), \
3744 cast_to_double_type(maximum), \
3745 cast_to_double_type(epsilon), \
3770#define expect_float_not_in_range(function, parameter, minimum, maximum, epsilon) \
3771 expect_float_not_in_range_count(function, parameter, minimum, maximum, epsilon, 1)
3799#define expect_float_not_in_range_count(function, parameter, minimum, maximum, \
3801 _expect_float_not_in_range(cmocka_tostring(function), \
3802 cmocka_tostring(parameter), \
3805 cast_to_double_type(minimum), \
3806 cast_to_double_type(maximum), \
3807 cast_to_double_type(epsilon), \
3817#define expect_value(function, parameter, value) \
3819 CMOCKA_DEPRECATION_WARNING("expect_value: use expect_int_value or " \
3820 "expect_uint_value instead") \
3821 expect_value_count(function, parameter, value, 1); \
3831#define expect_value_count(function, parameter, value, count) \
3833 CMOCKA_DEPRECATION_WARNING( \
3834 "expect_value_count: use expect_int_value_count or " \
3835 "expect_uint_value_count instead") \
3836 _expect_value(cmocka_tostring(function), \
3837 cmocka_tostring(parameter), \
3840 cast_to_uintmax_type(value), \
3861#define expect_int_value(function, parameter, value) \
3862 expect_int_value_count(function, parameter, value, 1)
3889#define expect_int_value_count(function, parameter, value, count) \
3890 _expect_int_value(cmocka_tostring(function), \
3891 cmocka_tostring(parameter), \
3915#define expect_uint_value(function, parameter, value) \
3916 expect_uint_value_count(function, parameter, value, 1)
3943#define expect_uint_value_count(function, parameter, value, count) \
3944 _expect_uint_value(cmocka_tostring(function), \
3945 cmocka_tostring(parameter), \
3968#define expect_int_not_value(function, parameter, value) \
3969 expect_int_not_value_count(function, parameter, value, 1)
3996#define expect_int_not_value_count(function, parameter, value, count) \
3997 _expect_int_not_value(cmocka_tostring(function), \
3998 cmocka_tostring(parameter), \
4021#define expect_uint_not_value(function, parameter, value) \
4022 expect_uint_not_value_count(function, parameter, value, 1)
4049#define expect_uint_not_value_count(function, parameter, value, count) \
4050 _expect_uint_not_value(cmocka_tostring(function), \
4051 cmocka_tostring(parameter), \
4064#define expect_not_value(function, parameter, value) \
4066 CMOCKA_DEPRECATION_WARNING( \
4067 "expect_not_value: use expect_int_not_value or " \
4068 "expect_uint_not_value instead") \
4069 expect_not_value_count(function, parameter, value, 1); \
4079#define expect_not_value_count(function, parameter, value, count) \
4081 CMOCKA_DEPRECATION_WARNING( \
4082 "expect_not_value_count: use expect_int_not_value_count or " \
4083 "expect_uint_not_value_count instead") \
4084 _expect_not_value(cmocka_tostring(function), \
4085 cmocka_tostring(parameter), \
4088 cast_to_uintmax_type(value), \
4114#define expect_float(function, parameter, value, epsilon) \
4115 expect_float_count(function, parameter, cast_to_double_type(value), \
4116 cast_to_double_type(epsilon), 1)
4144#define expect_float_count(function, parameter, value, epsilon, count) \
4145 _expect_float(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4146 cast_to_double_type(value), cast_to_double_type(epsilon), count)
4171#define expect_not_float(function, parameter, value, epsilon) \
4172 expect_not_float_count(function, \
4174 cast_to_float_type(value), \
4175 cast_to_float_type(epsilon), \
4204#define expect_not_float_count(function, parameter, value, epsilon, count) \
4205 _expect_not_float(cmocka_tostring(function), \
4206 cmocka_tostring(parameter), \
4209 cast_to_float_type(value), \
4210 cast_to_float_type(epsilon), \
4234#define expect_double(function, parameter, value, epsilon) \
4235 expect_double_count(function, \
4237 cast_to_double_type(value), \
4238 cast_to_double_type(epsilon), \
4270#define expect_double_count(function, parameter, value, epsilon, count) \
4271 _expect_double(cmocka_tostring(function), \
4272 cmocka_tostring(parameter), \
4275 cast_to_double_type(value), \
4276 cast_to_double_type(epsilon), \
4300#define expect_not_double(function, parameter, value, epsilon) \
4301 expect_not_double_count(function, \
4303 cast_to_double_type(value), \
4304 cast_to_double_type(epsilon), \
4336#define expect_not_double_count(function, parameter, value, epsilon, count) \
4337 _expect_not_double(cmocka_tostring(function), \
4338 cmocka_tostring(parameter), \
4341 cast_to_double_type(value), \
4342 cast_to_double_type(epsilon), \
4363#define expect_string(function, parameter, string) \
4364 expect_string_count(function, parameter, string, 1)
4388#define expect_string_count(function, parameter, string, count) \
4389 _expect_string(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4390 (const char*)(string), count)
4410#define expect_not_string(function, parameter, string) \
4411 expect_not_string_count(function, parameter, string, 1)
4435#define expect_not_string_count(function, parameter, string, count) \
4436 _expect_not_string(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4437 (const char*)(string), count)
4458#define expect_memory(function, parameter, memory, size) \
4459 expect_memory_count(function, parameter, memory, size, 1)
4485#define expect_memory_count(function, parameter, memory, size, count) \
4486 _expect_memory(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4487 (const void*)(memory), size, count)
4509#define expect_not_memory(function, parameter, memory, size) \
4510 expect_not_memory_count(function, parameter, memory, size, 1)
4536#define expect_not_memory_count(function, parameter, memory, size, count) \
4537 _expect_not_memory(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4538 (const void*)(memory), size, count)
4556#define expect_any(function, parameter) \
4557 expect_any_count(function, parameter, 1)
4574#define expect_any_always(function, parameter) \
4575 expect_any_count(function, parameter, WILL_RETURN_ALWAYS)
4597#define expect_any_count(function, parameter, count) \
4598 _expect_any(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, count)
4608#define check_expected(parameter) \
4610 CMOCKA_DEPRECATION_WARNING( \
4611 "check_expected: use check_expected_int or " \
4612 "check_expected_uint instead") \
4613 _check_expected(__func__, \
4617 cast_int_to_cmocka_value(parameter)); \
4651#define check_expected_any(parameter) \
4652 _check_expected(__func__, #parameter, __FILE__, __LINE__, \
4653 cast_ptr_to_cmocka_value(&(parameter)))
4669#define check_expected_ptr(parameter) \
4670 _check_expected(__func__, #parameter, __FILE__, __LINE__, \
4671 cast_ptr_to_cmocka_value(parameter))
4687#define check_expected_int(parameter) \
4688 _check_expected(__func__, \
4692 assign_int_to_cmocka_value(parameter))
4708#define check_expected_uint(parameter) \
4709 _check_expected(__func__, \
4713 assign_uint_to_cmocka_value(parameter))
4734#define check_expected_float(parameter) \
4735 _check_expected(__func__, \
4739 assign_float_to_cmocka_value(parameter))
4760#define check_expected_double(parameter) \
4761 _check_expected(__func__, \
4765 assign_double_to_cmocka_value(parameter))
4808#define assert_true(c) _assert_true(cast_to_uintmax_type(c), #c, \
4826#define assert_false(c) _assert_false(cast_to_uintmax_type(c), #c, \
4845#define assert_return_code(rc, error) \
4846 _assert_return_code((rc), \
4848 #rc, __FILE__, __LINE__)
4864#define assert_non_null(c) assert_ptr_not_equal((c), NULL)
4882#define assert_non_null_msg(c, msg) assert_ptr_not_equal_msg((c), NULL, (msg))
4898#define assert_null(c) assert_ptr_equal((c), NULL)
4916#define assert_null_msg(c, msg) assert_ptr_equal_msg((c), NULL, (msg))
4932#define assert_ptr_equal(a, b) assert_ptr_equal_msg((a), (b), NULL)
4950#define assert_ptr_equal_msg(a, b, msg) \
4951 _assert_ptr_equal_msg(cast_to_void_pointer(a), \
4952 cast_to_void_pointer(b), \
4953 __FILE__, __LINE__, (msg))
4969#define assert_ptr_not_equal(a, b) \
4970 assert_ptr_not_equal_msg((a), (b), NULL)
4989#if defined(__has_builtin)
4991#if __has_builtin(__builtin_unreachable)
4992#define assert_ptr_not_equal_msg(a, b, msg) \
4994 const void *cmocka_p1 = cast_to_void_pointer(a), \
4995 *cmocka_p2 = cast_to_void_pointer(b); \
4996 _assert_ptr_not_equal_msg( \
4997 cmocka_p1, cmocka_p2, __FILE__, __LINE__, (msg)); \
4998 if (cmocka_p1 == cmocka_p2) { \
4999 __builtin_unreachable(); \
5003#define assert_ptr_not_equal_msg(a, b, msg) \
5004_assert_ptr_not_equal_msg(cast_to_void_pointer(a), \
5005 cast_to_void_pointer(b), \
5012#define assert_ptr_not_equal_msg(a, b, msg) \
5013_assert_ptr_not_equal_msg(cast_to_void_pointer(a), \
5014 cast_to_void_pointer(b), \
5035#define assert_int_equal(a, b) \
5036 _assert_int_equal(cast_to_intmax_type(a), \
5037 cast_to_intmax_type(b), \
5054#define assert_uint_equal(a, b) \
5055 _assert_uint_equal(cast_to_uintmax_type(a), \
5056 cast_to_uintmax_type(b), \
5075#define assert_int_not_equal(a, b) \
5076 _assert_int_not_equal(cast_to_intmax_type(a), \
5077 cast_to_intmax_type(b), \
5094#define assert_uint_not_equal(a, b) \
5095 _assert_uint_not_equal(cast_to_uintmax_type(a), \
5096 cast_to_uintmax_type(b), \
5115#define assert_float_equal(a, b, epsilon) \
5116 _assert_float_equal((float)a, \
5137#define assert_float_not_equal(a, b, epsilon) \
5138 _assert_float_not_equal((float)a, \
5159#define assert_double_equal(a, b, epsilon) \
5160 _assert_double_equal((double)a, \
5181#define assert_double_not_equal(a, b, epsilon) \
5182 _assert_double_not_equal((double)a, \
5204#define assert_string_equal(a, b) \
5205 _assert_string_equal((a), (b), __FILE__, __LINE__)
5223#define assert_string_not_equal(a, b) \
5224 _assert_string_not_equal((a), (b), __FILE__, __LINE__)
5244#define assert_memory_equal(a, b, size) \
5245 _assert_memory_equal((const void*)(a), (const void*)(b), size, __FILE__, \
5266#define assert_memory_not_equal(a, b, size) \
5267 _assert_memory_not_equal((const void*)(a), (const void*)(b), size, \
5287#define assert_int_in_range(value, minimum, maximum) \
5288 _assert_int_in_range( \
5289 cast_to_intmax_type(value), \
5290 cast_to_intmax_type(minimum), \
5291 cast_to_intmax_type(maximum), __FILE__, __LINE__)
5310#define assert_uint_in_range(value, minimum, maximum) \
5311 _assert_uint_in_range( \
5312 cast_to_uintmax_type(value), \
5313 cast_to_uintmax_type(minimum), \
5314 cast_to_uintmax_type(maximum), __FILE__, __LINE__)
5338#define assert_int_not_in_range(value, minimum, maximum) \
5339 _assert_int_not_in_range(cast_to_intmax_type(value), \
5340 cast_to_intmax_type(minimum), \
5341 cast_to_intmax_type(maximum), \
5367#define assert_uint_not_in_range(value, minimum, maximum) \
5368 _assert_uint_not_in_range(cast_to_uintmax_type(value), \
5369 cast_to_uintmax_type(minimum), \
5370 cast_to_uintmax_type(maximum), \
5381#define assert_in_range(value, minimum, maximum) \
5383 CMOCKA_DEPRECATION_WARNING( \
5384 "assert_in_range: use assert_int_in_range or " \
5385 "assert_uint_in_range instead") \
5386 _assert_uint_in_range(cast_to_uintmax_type(value), \
5387 cast_to_uintmax_type(minimum), \
5388 cast_to_uintmax_type(maximum), \
5400#define assert_not_in_range(value, minimum, maximum) \
5402 CMOCKA_DEPRECATION_WARNING( \
5403 "assert_not_in_range: use assert_int_not_in_range or " \
5404 "assert_uint_not_in_range instead") \
5405 _assert_uint_not_in_range(cast_to_uintmax_type(value), \
5406 cast_to_uintmax_type(minimum), \
5407 cast_to_uintmax_type(maximum), \
5434#define assert_float_not_in_range(value, minimum, maximum, epsilon) \
5435 _assert_float_not_in_range(cast_to_double_type(value), \
5436 cast_to_double_type(minimum), \
5437 cast_to_double_type(maximum), \
5438 cast_to_double_type(epsilon), \
5461#define assert_float_in_range(value, minimum, maximum, epsilon) \
5462 _assert_float_in_range( \
5463 cast_to_double_type(value), \
5464 cast_to_double_type(minimum), \
5465 cast_to_double_type(maximum), \
5466 cast_to_double_type(epsilon), __FILE__, __LINE__)
5475#define assert_in_set(value, values, number_of_values) \
5477 CMOCKA_DEPRECATION_WARNING("assert_in_set: use assert_int_in_set or " \
5478 "assert_uint_in_set instead") \
5479 _assert_uint_in_set( \
5480 value, values, number_of_values, __FILE__, __LINE__); \
5499#define assert_not_in_set(value, values, number_of_values) \
5500 _assert_not_in_set(value, values, number_of_values, __FILE__, __LINE__)
5518#define assert_int_in_set(value, values, number_of_values) \
5519 if (number_of_values > 0) { \
5520 intmax_t _cmocka_set[number_of_values]; \
5521 for (size_t _i = 0; _i < number_of_values; _i++) { \
5522 _cmocka_set[_i] = values[_i]; \
5524 _assert_int_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5543#define assert_int_not_in_set(value, values, number_of_values) \
5544 if (number_of_values > 0) { \
5545 intmax_t _cmocka_set[number_of_values]; \
5546 for (size_t _i = 0; _i < number_of_values; _i++) { \
5547 _cmocka_set[_i] = values[_i]; \
5549 _assert_int_not_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5568#define assert_uint_in_set(value, values, number_of_values) \
5569 if (number_of_values > 0) { \
5570 uintmax_t _cmocka_set[number_of_values]; \
5571 for (size_t _i = 0; _i < number_of_values; _i++) { \
5572 _cmocka_set[_i] = values[_i]; \
5574 _assert_uint_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5593#define assert_uint_not_in_set(value, values, number_of_values) \
5594 if (number_of_values > 0) { \
5595 uintmax_t _cmocka_set[number_of_values]; \
5596 for (size_t _i = 0; _i < number_of_values; _i++) { \
5597 _cmocka_set[_i] = values[_i]; \
5599 _assert_uint_not_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5620#define assert_float_in_set(value, values, number_of_values, epsilon) \
5621 if (number_of_values > 0) { \
5622 double _cmocka_set[number_of_values]; \
5623 for (size_t _i = 0; _i < number_of_values; _i++) { \
5624 _cmocka_set[_i] = values[_i]; \
5626 _assert_float_in_set(value, _cmocka_set, number_of_values, epsilon, __FILE__, __LINE__); \
5647#define assert_float_not_in_set(value, values, number_of_values, epsilon) \
5648 if (number_of_values > 0) { \
5649 double _cmocka_set[number_of_values]; \
5650 for (size_t _i = 0; _i < number_of_values; _i++) { \
5651 _cmocka_set[_i] = values[_i]; \
5653 _assert_float_not_in_set(value, _cmocka_set, number_of_values, epsilon, __FILE__, __LINE__); \
5732#define function_called() _function_called(__func__, __FILE__, __LINE__)
5748#define expect_function_calls(function, times) \
5749 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, times)
5763#define expect_function_call(function) \
5764 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, 1)
5777#define expect_function_call_any(function) \
5778 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, -1)
5791#define ignore_function_calls(function) \
5792 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, -2)
5835#define fail() _fail(__FILE__, __LINE__)
5844#define skip() _skip(__FILE__, __LINE__)
5858#define stop() _stop()
5878#define fail_msg(msg, ...) do { \
5879 cmocka_print_error("ERROR: " msg "\n" CMOCKA_VA_ARGS(__VA_ARGS__)); \
5884static inline void _unit_test_dummy(
void **state) {
5892#define unit_test(f) \
5893 (CMOCKA_DEPRECATION_WARNING("unit_test: use cmocka_unit_test instead")( \
5894 UnitTest){#f, f, UNIT_TEST_FUNCTION_TYPE_TEST})
5897#define _unit_test_setup(test, setup) \
5898 { #test "_" #setup, setup, UNIT_TEST_FUNCTION_TYPE_SETUP }
5905#define unit_test_setup(test, setup) \
5906 CMOCKA_DEPRECATION_WARNING( \
5907 "unit_test_setup: use cmocka_unit_test_setup instead") \
5908 _unit_test_setup(test, setup), unit_test(test), \
5909 _unit_test_teardown(test, _unit_test_dummy)
5912#define _unit_test_teardown(test, teardown) \
5913 { #test "_" #teardown, teardown, UNIT_TEST_FUNCTION_TYPE_TEARDOWN }
5920#define unit_test_teardown(test, teardown) \
5921 CMOCKA_DEPRECATION_WARNING( \
5922 "unit_test_teardown: use cmocka_unit_test_teardown instead") \
5923 _unit_test_setup(test, _unit_test_dummy), unit_test(test), \
5924 _unit_test_teardown(test, teardown)
5930#define group_test_setup(setup) \
5931 (CMOCKA_DEPRECATION_WARNING( \
5932 "group_test_setup: use cmocka_run_group_tests instead")(UnitTest){ \
5933 "group_" #setup, setup, UNIT_TEST_FUNCTION_TYPE_GROUP_SETUP})
5939#define group_test_teardown(teardown) \
5940 (CMOCKA_DEPRECATION_WARNING( \
5941 "group_test_teardown: use cmocka_run_group_tests instead")(UnitTest){ \
5942 "group_" #teardown, teardown, UNIT_TEST_FUNCTION_TYPE_GROUP_TEARDOWN})
5951#define unit_test_setup_teardown(test, setup, teardown) \
5952 CMOCKA_DEPRECATION_WARNING("unit_test_setup_teardown: use " \
5953 "cmocka_unit_test_setup_teardown instead") \
5954 _unit_test_setup(test, setup), unit_test(test), \
5955 _unit_test_teardown(test, teardown)
5958#define cmocka_unit_test(f) { #f, f, NULL, NULL, NULL }
5961#define cmocka_unit_test_setup(f, setup) { #f, f, setup, NULL, NULL }
5964#define cmocka_unit_test_teardown(f, teardown) { #f, f, NULL, teardown, NULL }
5970#define cmocka_unit_test_setup_teardown(f, setup, teardown) { #f, f, setup, teardown, NULL }
5979#define cmocka_unit_test_prestate(f, state) { #f, f, NULL, NULL, state }
5988#define cmocka_unit_test_prestate_setup_teardown(f, setup, teardown, state) { #f, f, setup, teardown, state }
6051# define cmocka_run_group_tests(group_tests, group_setup, group_teardown) \
6052 _cmocka_run_group_tests(#group_tests, group_tests, sizeof(group_tests) / sizeof((group_tests)[0]), group_setup, group_teardown)
6120# define cmocka_run_group_tests_name(group_name, group_tests, group_setup, group_teardown) \
6121 _cmocka_run_group_tests(group_name, group_tests, sizeof(group_tests) / sizeof((group_tests)[0]), group_setup, group_teardown)
6211#define test_malloc(size) _test_malloc(size, __FILE__, __LINE__)
6230#define test_calloc(num, size) _test_calloc(num, size, __FILE__, __LINE__)
6246#define test_realloc(ptr, size) _test_realloc(ptr, size, __FILE__, __LINE__)
6259#define test_free(ptr) _test_free(ptr, __FILE__, __LINE__)
6262#if defined(UNIT_TESTING) && defined(ALLOCATION_TESTING)
6263#define malloc test_malloc
6264#define realloc test_realloc
6265#define calloc test_calloc
6266#define free test_free
6322void mock_assert(
const int result,
const char*
const expression,
6323 const char *
const file,
const size_t line);
6350#define expect_assert_failure(function_call) \
6352 global_expecting_assert = 1; \
6353 if (setjmp(global_expect_assert_env) != 0) { \
6354 print_message("Expected assertion %s occurred\n", \
6355 global_last_failed_assert); \
6356 global_expecting_assert = 0; \
6359 global_expecting_assert = 0; \
6360 print_error("Expected assert in %s\n", #function_call); \
6361 _fail(__FILE__, __LINE__); \
6392 void *(*func)(void);
6400#define LargestIntegralType uintmax_t
6405#if defined(__GNUC__)
6406#define cast_ptr_to_largest_integral_type(value) \
6408 CMOCKA_DEPRECATION_WARNING( \
6409 "cast_ptr_to_largest_integral_type: " \
6410 "use cast_ptr_to_uintmax_type instead"); \
6411 cast_ptr_to_uintmax_type(value); \
6414#define cast_ptr_to_largest_integral_type(value) \
6415 cast_ptr_to_uintmax_type(value)
6432 const uintmax_t check_value_data);
6448 const intmax_t check_value_data);
6456 const uintmax_t check_value_data);
6464 UNIT_TEST_FUNCTION_TYPE_TEST = 0,
6465 UNIT_TEST_FUNCTION_TYPE_SETUP,
6466 UNIT_TEST_FUNCTION_TYPE_TEARDOWN,
6467 UNIT_TEST_FUNCTION_TYPE_GROUP_SETUP,
6468 UNIT_TEST_FUNCTION_TYPE_GROUP_TEARDOWN,
6491 const size_t number_of_tests;
6516 void *initial_state;
6536 const char *parameter_name;
6538 uintmax_t check_value_data;
6548 const char *parameter_name;
6568void print_message(
const char*
const format, ...) CMOCKA_PRINTF_ATTRIBUTE(1, 2);
6569void print_error(const
char* const format, ...) CMOCKA_PRINTF_ATTRIBUTE(1, 2);
6570void vprint_message(const
char* const format, va_list args) CMOCKA_PRINTF_ATTRIBUTE(1, 0);
6571void vprint_error(const
char* const format, va_list args) CMOCKA_PRINTF_ATTRIBUTE(1, 0);
6642#define cm_print_error(format, ...) \
6644 CMOCKA_DEPRECATION_WARNING( \
6645 "cm_print_error: use cmocka_print_error instead") \
6646 cmocka_print_error(format CMOCKA_VA_ARGS(__VA_ARGS__)); \
6662void cmocka_print_error(
const char*
const format, ...) CMOCKA_PRINTF_ATTRIBUTE(1, 2);
6730CMOCKA_DLLEXTERN extern
int global_expecting_assert;
6731CMOCKA_DLLEXTERN extern jmp_buf global_expect_assert_env;
6732CMOCKA_DLLEXTERN extern const
char * global_last_failed_assert;
6736 const
char *const file,
6742 const
char *const file,
6746bool _has_mock(const
char *const function);
6748void _expect_function_call(
6749 const
char * const function_name,
6750 const
char * const file,
6754void _function_called(const
char * const function, const
char* const file,
6759 const
char* const function, const
char* const parameter,
6760 const
char* const file, const
size_t line,
6763 const
int count) CMOCKA_DEPRECATED;
6766void _expect_check_data(
6767 const
char* const function, const
char* const parameter,
6768 const
char* const file, const
size_t line,
6773void _expect_int_in_set(const
char *const function,
6774 const
char *const parameter,
6775 const
char *const file,
6777 const intmax_t values[],
6778 const
size_t number_of_values,
6779 const intmax_t count);
6780void _expect_uint_in_set(const
char *const function,
6781 const
char *const parameter,
6782 const
char *const file,
6784 const uintmax_t values[],
6785 const
size_t number_of_values,
6786 const intmax_t count);
6788void _expect_float_in_set(const
char *const function,
6789 const
char *const parameter,
6790 const
char *const file,
6792 const
double values[],
6793 const
size_t number_of_values,
6794 const
double epsilon,
6795 const intmax_t count);
6797void _expect_not_in_set(
6798 const
char* const function, const
char* const parameter,
6799 const
char* const file, const
size_t line, const uintmax_t values[],
6800 const
size_t number_of_values, const
int count);
6801void _expect_int_not_in_set(const
char *const function,
6802 const
char *const parameter,
6803 const
char *const file,
6805 const intmax_t values[],
6806 const
size_t number_of_values,
6807 const intmax_t count);
6808void _expect_uint_not_in_set(const
char *const function,
6809 const
char *const parameter,
6810 const
char *const file,
6812 const uintmax_t values[],
6813 const
size_t number_of_values,
6814 const intmax_t count);
6816void _expect_float_not_in_set(
6817 const
char* const function, const
char* const parameter,
6818 const
char* const file, const
size_t line, const
double values[],
6819 const
size_t number_of_values, const
double epsilon, const intmax_t count);
6821void _expect_in_range(const
char *const function,
6822 const
char *const parameter,
6823 const
char *const file,
6825 const uintmax_t minimum,
6826 const uintmax_t maximum,
6827 const
int count) CMOCKA_DEPRECATED;
6828void _expect_int_in_range(const
char *const function,
6829 const
char *const parameter,
6830 const
char *const file,
6832 const intmax_t minimum,
6833 const intmax_t maximum,
6834 const intmax_t count);
6835void _expect_uint_in_range(const
char *const function,
6836 const
char *const parameter,
6837 const
char *const file,
6839 const uintmax_t minimum,
6840 const uintmax_t maximum,
6841 const intmax_t count);
6842void _expect_not_in_range(
6843 const
char* const function, const
char* const parameter,
6844 const
char* const file, const
size_t line,
6845 const uintmax_t minimum,
6846 const uintmax_t maximum, const
int count);
6847void _expect_int_not_in_range(const
char *const function,
6848 const
char *const parameter,
6849 const
char *const file,
6851 const intmax_t minimum,
6852 const intmax_t maximum,
6853 const intmax_t count);
6854void _expect_uint_not_in_range(const
char *const function,
6855 const
char *const parameter,
6856 const
char *const file,
6858 const uintmax_t minimum,
6859 const uintmax_t maximum,
6860 const intmax_t count);
6861void _expect_float_in_range(
6862 const
char* const function, const
char* const parameter,
6863 const
char* const file, const
size_t line,
6864 const
double minimum, const
double maximum, const
double epsilon,
6866void _expect_float_not_in_range(
6867 const
char* const function, const
char* const parameter,
6868 const
char* const file, const
size_t line,
6869 const
double minimum, const
double maximum, const
double epsilon,
6873 const
char* const function, const
char* const parameter,
6874 const
char* const file, const
size_t line, const uintmax_t value,
6876void _expect_int_value(const
char *const function,
6877 const
char *const parameter,
6878 const
char *const file,
6880 const intmax_t value,
6881 const intmax_t count);
6882void _expect_uint_value(const
char *const function,
6883 const
char *const parameter,
6884 const
char *const file,
6886 const uintmax_t value,
6887 const intmax_t count);
6888void _expect_int_not_value(const
char *const function,
6889 const
char *const parameter,
6890 const
char *const file,
6892 const intmax_t value,
6893 const intmax_t count);
6894void _expect_uint_not_value(const
char *const function,
6895 const
char *const parameter,
6896 const
char *const file,
6898 const uintmax_t value,
6899 const intmax_t count);
6900void _expect_not_value(
6901 const
char* const function, const
char* const parameter,
6902 const
char* const file, const
size_t line, const uintmax_t value,
6906 const
char* const function, const
char* const parameter,
6907 const
char* const file, const
size_t line, const
double value,
6908 const
double epsilon, const
int count);
6909void _expect_not_float(
6910 const
char* const function, const
char* const parameter,
6911 const
char* const file, const
size_t line, const
double value,
6912 const
double epsilon, const
int count);
6914void _expect_double(const
char *const function,
6915 const
char *const parameter,
6916 const
char *const file,
6919 const
double epsilon,
6921void _expect_not_double(const
char *const function,
6922 const
char *const parameter,
6923 const
char *const file,
6926 const
double epsilon,
6930 const
char* const function, const
char* const parameter,
6931 const
char* const file, const
size_t line, const
char*
string,
6933void _expect_not_string(
6934 const
char* const function, const
char* const parameter,
6935 const
char* const file, const
size_t line, const
char*
string,
6939 const
char* const function, const
char* const parameter,
6940 const
char* const file, const
size_t line, const
void* const memory,
6941 const
size_t size, const
int count);
6942void _expect_not_memory(
6943 const
char* const function, const
char* const parameter,
6944 const
char* const file, const
size_t line, const
void* const memory,
6945 const
size_t size, const
int count);
6948 const
char* const function, const
char* const parameter,
6949 const
char* const file, const
size_t line, const
int count);
6951void _check_expected(
6952 const
char * const function_name, const
char * const parameter_name,
6955void _will_return(const
char *const function_name,
6956 const
char *const file,
6961void _will_set_parameter(const
char *const function_name,
6963 const
char *const file,
6968void _assert_true(const uintmax_t result,
6969 const
char* const expression,
6970 const
char * const file, const
size_t line);
6971void _assert_false(const uintmax_t result,
6972 const
char * const expression,
6973 const
char * const file, const
size_t line);
6974void _assert_return_code(const intmax_t result,
6975 const int32_t error,
6976 const
char * const expression,
6977 const
char * const file,
6979void _assert_float_equal(const
float a, const
float n,
6980 const
float epsilon, const
char* const file,
6982void _assert_float_not_equal(const
float a, const
float n,
6983 const
float epsilon, const
char* const file,
6985void _assert_double_equal(const
double a, const
double n,
6986 const
double epsilon, const
char* const file,
6988void _assert_double_not_equal(const
double a, const
double n,
6989 const
double epsilon, const
char* const file,
6991void _assert_int_equal(const intmax_t a,
6993 const
char * const file,
6995void _assert_int_not_equal(const intmax_t a,
6997 const
char * const file,
6999void _assert_uint_equal(const uintmax_t a,
7001 const
char * const file,
7003void _assert_uint_not_equal(const uintmax_t a,
7005 const
char * const file,
7007CMOCKA_NO_ACCESS_ATTRIBUTE
7008void _assert_ptr_equal_msg(const
void *a,
7010 const
char *const file,
7012 const
char *const msg);
7013CMOCKA_NO_ACCESS_ATTRIBUTE
7014void _assert_ptr_not_equal_msg(const
void *a,
7016 const
char *const file,
7018 const
char *const msg);
7019void _assert_string_equal(const
char * const a, const
char * const b,
7020 const
char * const file, const
size_t line);
7021void _assert_string_not_equal(const
char * const a, const
char * const b,
7022 const
char *file, const
size_t line);
7023void _assert_memory_equal(const
void * const a, const
void * const b,
7024 const
size_t size, const
char* const file,
7026void _assert_memory_not_equal(const
void * const a, const
void * const b,
7027 const
size_t size, const
char* const file,
7029void _assert_int_in_range(const intmax_t value,
7030 const intmax_t minimum,
7031 const intmax_t maximum,
7032 const
char* const file,
7034void _assert_int_not_in_range(const intmax_t value,
7035 const intmax_t minimum,
7036 const intmax_t maximum,
7037 const
char *const file,
7039void _assert_uint_in_range(const uintmax_t value,
7040 const uintmax_t minimum,
7041 const uintmax_t maximum,
7042 const
char* const file,
7044void _assert_uint_not_in_range(const uintmax_t value,
7045 const uintmax_t minimum,
7046 const uintmax_t maximum,
7047 const
char* const file,
7049void _assert_float_in_range(const
double value,
7050 const
double minimum,
7051 const
double maximum,
7052 const
double epsilon,
7053 const
char* const file,
7055void _assert_float_not_in_range(const
double value,
7056 const
double minimum,
7057 const
double maximum,
7058 const
double epsilon,
7059 const
char* const file,
7061void _assert_not_in_set(
7062 const uintmax_t value, const uintmax_t values[],
7063 const
size_t number_of_values, const
char* const file, const
size_t line);
7064void _assert_int_in_set(const intmax_t value,
7065 const intmax_t values[],
7066 const
size_t number_of_values,
7067 const
char *const file,
7069void _assert_int_not_in_set(const intmax_t value,
7070 const intmax_t values[],
7071 const
size_t number_of_values,
7072 const
char *const file,
7074void _assert_uint_in_set(const uintmax_t value,
7075 const uintmax_t values[],
7076 const
size_t number_of_values,
7077 const
char *const file,
7079void _assert_uint_not_in_set(const uintmax_t value,
7080 const uintmax_t values[],
7081 const
size_t number_of_values,
7082 const
char *const file,
7084void _assert_float_in_set(const
double value,
7085 const
double values[],
7086 const
size_t number_of_values,
7087 const
double epsilon,
7088 const
char *const file,
7090void _assert_float_not_in_set(const
double value,
7091 const
double values[],
7092 const
size_t number_of_values,
7093 const
double epsilon,
7094 const
char *const file,
7097void* _test_malloc(const
size_t size, const
char* file, const
size_t line);
7098void* _test_realloc(
void *ptr, const
size_t size, const
char* file, const
size_t line);
7099void* _test_calloc(const
size_t number_of_elements, const
size_t size,
7100 const
char* file, const
size_t line);
7101void _test_free(
void* const ptr, const
char* file, const
size_t line);
7103CMOCKA_NORETURN
void _fail(const
char * const file, const
size_t line);
7105CMOCKA_NORETURN
void _skip(const
char * const file, const
size_t line);
7107CMOCKA_NORETURN
void _stop(
void);
7110int _cmocka_run_group_tests(const
char *group_name,
7112 const
size_t num_tests,
void * test_realloc(void *ptr, size_t size)
Test function overriding realloc which detects buffer overruns and memory leaks.
void test_free(void *ptr)
Test function overriding free(3).
void * test_calloc(size_t nmemb, size_t size)
Test function overriding calloc.
void * test_malloc(size_t size)
Test function overriding malloc.
void assert_in_set(uintmax_t value, uintmax_t values[], intmax_t count)
void assert_ptr_equal(void *a, void *b)
Assert that the two given pointers are equal.
void assert_int_equal(intmax_t a, intmax_t b)
Assert that the two given integers are equal.
void assert_string_equal(const char *a, const char *b)
Assert that the two given strings are equal.
void assert_uint_in_set(uintmax_t value, uintmax_t values[], intmax_t count)
Assert that the specified unsigned integer value is within a set.
void assert_null(void *pointer)
Assert that the given pointer is NULL.
void assert_float_not_in_set(double value, double values[], intmax_t count, double epsilon)
Assert that the specified float value is not within a set.
void assert_not_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum)
void assert_float_not_in_range(double value, double minimum, double maximum, double epsilon)
Assert that the specified float value is smaller than the minimum or greater than the maximum.
void assert_memory_not_equal(const void *a, const void *b, size_t size)
Assert that the two given areas of memory are not equal.
void assert_ptr_not_equal(void *a, void *b)
Assert that the two given pointers are not equal.
void assert_double_equal(double a, double b, double epsilon)
Assert that the two given double are equal given an epsilon.
void assert_ptr_not_equal_msg(void *a, void *b, const char *const msg)
Assert that the two given pointers are not equal.
void assert_int_in_set(intmax_t value, intmax_t values[], intmax_t count)
Assert that the specified integer value is within a set.
void assert_float_in_range(double value, double minimum, double maximum, double epsilon)
Assert that the specified float value is not smaller than the minimum and and not greater than the ma...
void assert_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum)
void assert_uint_equal(uintmax_t a, uintmax_t b)
Assert that the two given unsigned integers are equal.
void assert_int_not_in_set(intmax_t value, intmax_t values[], intmax_t count)
Assert that the specified value is not within a set.
void assert_non_null(void *pointer)
Assert that the given pointer is non-NULL.
void assert_null_msg(void *pointer, const char *const message)
Assert that the given pointer is NULL.
void assert_uint_not_in_set(uintmax_t value, uintmax_t values[], intmax_t count)
Assert that the specified unsigned integer value is not within a set.
void assert_float_in_set(double value, double values[], intmax_t count, double epsilon)
Assert that the specified float value is within a set.
void assert_true(scalar expression)
Assert that the given expression is true.
void assert_ptr_equal_msg(void *a, void *b, const char *const msg)
Assert that the two given pointers are equal.
void assert_false(scalar expression)
Assert that the given expression is false.
void assert_int_in_range(intmax_t value, intmax_t minimum, intmax_t maximum)
Assert that the specified integer value is not smaller than the minimum and and not greater than the ...
void assert_uint_not_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum)
Assert that the specified value is smaller than the minimum or greater than the maximum.
void assert_int_not_equal(intmax_t a, intmax_t b)
Assert that the two given integers are not equal.
void assert_uint_not_equal(uintmax_t a, uintmax_t b)
Assert that the two given unsigned integers are not equal.
void assert_memory_equal(const void *a, const void *b, size_t size)
Assert that the two given areas of memory are equal, otherwise fail.
void assert_float_equal(float a, float b, float epsilon)
Assert that the two given float are equal given an epsilon.
void assert_double_not_equal(double a, double b, double epsilon)
Assert that the two given double are not equal given an epsilon.
void assert_string_not_equal(const char *a, const char *b)
Assert that the two given strings are not equal.
void assert_int_not_in_range(intmax_t value, intmax_t minimum, intmax_t maximum)
Assert that the specified value is smaller than the minimum or greater than the maximum.
void assert_not_in_set(uintmax_t value, uintmax_t values[], intmax_t count)
Assert that the specified value is not within a set.
void assert_float_not_equal(float a, float b, float epsilon)
Assert that the two given float are not equal given an epsilon.
void assert_non_null_msg(void *pointer, const char *const message)
Assert that the given pointer is non-NULL.
void assert_uint_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum)
Assert that the specified unsigned integer value is not smaller than the minimum and and not greater ...
void assert_return_code(intmax_t rc, int32_t error)
Assert that the return_code is greater than or equal to 0.
void ignore_function_calls(#function)
Ignores function_called() invocations from given mock function.
void expect_function_call_any(#function)
Expects function_called() from given mock at least once.
void expect_function_call(#function)
Store expected single call to a mock to be checked by function_called() later.
void function_called(void)
Check that current mocked function is being called in the expected order.
void expect_function_calls(#function, const int times)
Store expected call(s) to a mock to be checked by function_called() later.
void cmocka_set_message_output(uint32_t output)
Function to set the output format for a test.
Definition cmocka.c:4818
void cm_print_error(const char *const format,...)
void cmocka_set_callbacks(const struct CMCallbacks *f_callbacks)
Set callback functions for CMocka.
Definition cmocka.c:154
cm_message_output
Output format options for test results.
Definition cmocka.h:6623
void cmocka_set_skip_filter(const char *pattern)
Set a pattern to skip tests matching the pattern.
Definition cmocka.c:4878
void cmocka_set_test_filter(const char *pattern)
Set a pattern to only run the test matching the pattern.
Definition cmocka.c:4861
@ CM_OUTPUT_TAP
Definition cmocka.h:6631
@ CM_OUTPUT_STDOUT
Definition cmocka.h:6627
@ CM_OUTPUT_SUBUNIT
Definition cmocka.h:6629
@ CM_OUTPUT_STANDARD
Definition cmocka.h:6625
@ CM_OUTPUT_XML
Definition cmocka.h:6633
void(*) CMUnitTestFunction(void **state)
Definition cmocka.h:6499
int(*) CMFixtureFunction(void **state)
Definition cmocka.h:6506
int cmocka_run_group_tests(const struct CMUnitTest group_tests[], CMFixtureFunction group_setup, CMFixtureFunction group_teardown)
Run tests specified by an array of CMUnitTest structures.
void fail(void)
Forces the test to fail immediately and quit.
void stop(void)
Forces the test to be stopped immediately.
void(*) UnitTestFunction(void **state)
Definition cmocka.h:6424
UnitTestFunctionType
Definition cmocka.h:6463
void fail_msg(const char *msg,...)
Forces the test to fail immediately and quit, printing the reason.
int cmocka_run_group_tests_name(const char *group_name, const struct CMUnitTest group_tests[], CMFixtureFunction group_setup, CMFixtureFunction group_teardown)
Run tests specified by an array of CMUnitTest structures and specify a name.
void skip(void)
Forces the test to not be executed, but marked as skipped.
void mock_assert(const int result, const char *const expression, const char *const file, const size_t line)
Function to replace assert(3) in tested code.
Definition cmocka.c:3468
void expect_assert_failure(function fn_call)
Ensure that mock_assert() is called.
void will_return_int(#function, intmax_t value)
Store an integer value to be returned by mock() later.
void will_set_parameter_float_always(#function, #name, float value)
Store a named float value that will always be returned by mock_parameter_float().
uintmax_t mock_parameter(#name)
Retrieve a named value for the current function.
void will_return_float_maybe(#function, float value)
Store a float value that may always be returned by mock_float().
void will_set_parameter_int(#function, #name, intmax_t value)
Store a named integer value to be returned by mock_parameter() later.
intmax_t mock_int()
Retrieve an integer return value of the current function.
void will_return_float_always(#function, float value)
Store a float value that will always be returned by mock_float().
void will_set_parameter_int_count(#function, #name, intmax_t value, int count)
Store a named integer value to be returned a specified number of times by mock_parameter_int() later.
void will_return_double_count(#function, double value, int count)
Store a double precision floating point value to be returned a specified number of times by mock() la...
void will_set_parameter_double_count(#function, #name, double value, int count)
Store a named double value to be returned a specified number of times by mock_parameter_double() late...
void will_set_parameter_uint(#function, #name, uintmax_t value)
Store a named unsigned integer value to be returned by mock_parameter() later.
void will_set_parameter_float_maybe(#function, #name, float value)
Store a named float value that may always be returned by mock_parameter_float().
void * mock_parameter_ptr(#name)
Retrieve a named pointer for the current function.
void will_return_count(#function, uintmax_t value, int count)
void will_set_parameter(#function, #name, uintmax_t value)
Store a named value to be returned by mock_parameter() later.
void will_return_int_maybe(#function, intmax_t value)
Store an integer value that may always be returned by mock_int().
void will_set_parameter_ptr_type(#function, #name, void *value, #type)
Store a named pointer value to be returned by mock_parameter() later.
void will_set_parameter_ptr(#function, #name, void *value)
Store a named pointer value to be returned by mock_parameter() later.
void will_return(#function, uintmax_t value)
Store a value to be returned by mock() later.
void will_return_ptr_type(#function, void *value, type)
Store a pointer value to be returned by mock_ptr_type_checked() later.
void will_return_double_always(#function, double value)
Store a double value that will always be returned by mock_double().
void will_set_errno_always(#function, intmax_t value)
Store an integer value to set errno to by mock_errno() later, for a specified number of times.
type mock_parameter_ptr_type(#name, #type)
Retrieve a named pointer for the current function.
double mock_double(void)
Retrieve a double precision floating point return value of the current function.
void will_return_uint_maybe(#function, uintmax_t value)
Store an unsigned integer value that may always be returned by mock_uint().
void will_return_uint_always(#function, uintmax_t value)
Store an unsigned integer value that will always be returned by mock_uint().
void will_set_parameter_double_maybe(#function, #name, double value)
Store a named double value that may always be returned by mock_parameter_double().
void will_set_parameter_int_maybe(#function, #name, intmax_t value)
Store a named integer value that may always be returned by mock_parameter_int().
void will_set_errno_maybe(#function, intmax_t value)
Store an integer value to set errno to by mock_errno() later, for a specified number of times.
void will_return_uint_count(#function, uintmax_t value, int count)
Store an unsigned integer value to be returned a specified number of times by mock() later.
void will_return_double_maybe(#function, double value)
Store a double value that may always be returned by mock_double().
uintmax_t mock_uint(void)
Retrieve an unsigned integer return value of the current function.
void will_set_parameter_double(#function, #name, double value)
Store a named double precision floating point value to be returned by mock_parameter() later.
void will_set_parameter_ptr_always(#function, #name, void *value)
Store a named pointer value that will be always returned by mock_parameter_ptr().
void will_return_always(#function, uintmax_t value)
void will_return_ptr(#function, void *value)
Store a pointer value to be returned by mock_ptr_type() later.
void will_return_ptr_always(#function, void *value)
Store a value that will be always returned by mock_ptr_type().
void will_return_int_always(#function, intmax_t value)
Store an integer value that will always be returned by mock_int().
type mock_type(#type)
Retrieve a value of the current function and cast it to given type.
void will_set_errno_count(#function, intmax_t value, intmax_t count)
Store an integer value to always set errno to by mock_errno().
void will_set_parameter_float(#function, #name, float value)
Store a named float value to be returned by mock_parameter() later.
void will_set_parameter_double_always(#function, #name, double value)
Store a named double value that will always be returned by mock_parameter_double().
bool has_mock(void)
Check if data is available for the current mock function.
float mock_parameter_float(#name)
Retrieve a named float value for the current function.
void will_set_parameter_uint_maybe(#function, #name, uintmax_t value)
Store a named unsigned integer value that may always be returned by mock_parameter_uint().
void will_set_parameter_int_always(#function, #name, intmax_t value)
Store a named integer value that will always be returned by mock_parameter_int().
void will_return_maybe(#function, uintmax_t value)
void will_set_parameter_always(#function, #name, uintmax_t value)
void will_set_parameter_count(#function, #name, uintmax_t value, int count)
void will_return_int_count(#function, intmax_t value, int count)
Store an integer value to be returned a specified number of times by mock() later.
void will_set_parameter_float_count(#function, #name, float value, int count)
Store a named float value to be returned a specified number of times by mock_parameter_float() later.
void will_return_ptr_count(#function, void *value, int count)
Store a pointer value to be returned by mock_ptr_type() later.
void will_set_parameter_uint_always(#function, #name, uintmax_t value)
Store a named unsigned integer value that will always be returned by mock_parameter_uint().
void will_set_parameter_maybe(#function, #name, uintmax_t value)
uintmax_t mock_parameter_uint(#name)
Retrieve an unsigned integer return value of the current function.
void will_return_uint(#function, uintmax_t value)
Store a unsigned integer value to be returned by mock() later.
void will_return_float(#function, float value)
Store a float value to be returned by mock() later.
void will_set_errno(#function, intmax_t value)
Store an integer value to set errno to by mock_errno() later.
void will_return_float_count(#function, float value, int count)
Store a float value to be returned a specified number of times by mock() later.
type mock_ptr_type(#type)
Retrieve a typed return value of the current function.
void will_set_parameter_ptr_count(#function, #name, void *value, int count)
Store a named pointer value to be returned a specified number of times by mock_parameter_ptr() later.
float mock_float(void)
Retrieve a float return value of the current function.
uintmax_t mock(void)
Retrieve a return value of the current function.
void mock_errno(void)
set errno for the current function.
intmax_t mock_parameter_int(#name)
Retrieve a named value for the current function and cast it to given type.
void will_return_double(#function, double value)
Store a double precision floating point value to be returned by mock() later.
void will_set_parameter_ptr_maybe(#function, #name, void *value)
Store a named pointer value that may be always returned by mock_parameter_ptr().
void will_return_ptr_maybe(#function, void *value)
Store a value that may be always returned by mock_ptr_type().
void will_set_parameter_uint_count(#function, uintmax_t value, int count)
Store a named unsigned integer value to be returned a specified number of times by mock_parameter_uin...
double mock_parameter_double(#name)
Retrieve a named double precision floating point value for the current function.
type mock_ptr_type_checked(#type)
Retrieve a typed return value of the current function with type checking.
void expect_float_not_in_set(#function, #parameter, double value_array[], double epsilon)
Add an event to check if the float parameter value is not part of the provided array.
void expect_uint_in_range_count(#function, uintmax_t minimum, uintmax_t maximum, intmax_t count)
Add an event to repeatedly check an unsigned integer parameter is inside a numerical range....
void expect_uint_value_count(#function, uintmax_t value, intmax_t count)
Add an event to repeatedly check if an unsigned integer parameter is the given value.
void expect_uint_not_in_set_count(#function, uintmax_t value_array[], intmax_t count)
Add an event to check if the unsigned integer parameter value is not part of the provided unsigned in...
int(*) CheckUintParameterValue(const uintmax_t value, const uintmax_t check_value_data)
Definition cmocka.h:6455
void expect_uint_not_in_range(#function, uintmax_t minimum, uintmax_t maximum)
Add an event to check an unsigned integer parameter is outside a numerical range. The check would suc...
void expect_not_double_count(#function, double value, double epsilon, intmax_t count)
Add an event to repeatedly check if a parameter isn't the double precision floating point value.
void expect_int_in_range_count(#function, intmax_t minimum, intmax_t maximum, intmax_t count)
Add an event to repeatedly check an integer parameter is inside a numerical range....
void expect_not_memory_count(#function, #parameter, void *memory, size_t size, intmax_t count)
Add an event to repeatedly check if the parameter doesn't match an area of memory.
void expect_not_string(#function, #parameter, const char *string)
Add an event to check if the parameter value isn't equal to the provided string.
void check_expected_ptr(#parameter)
Determine whether a function parameter is correct.
void expect_float_not_in_range_count(#function, #parameter, double minimum, double maximum, double epsilon, intmax_t count)
Add an event to repeatedly check a parameter is outside a numerical range. The check would succeed if...
void expect_int_not_in_set_count(#function, intmax_t value_array[], intmax_t count)
Add an event to check if the integer parameter value is not part of the provided integer array.
void check_expected(#parameter)
void expect_value_count(#function, #parameter, uintmax_t value, intmax_t count)
void expect_int_not_value_count(#function, intmax_t value, intmax_t count)
Add an event to repeatedly check if a parameter (int) isn't the given value.
void expect_double_count(#function, double value, double epsilon, intmax_t count)
Add an event to repeatedly check if a parameter is the given double precision floating point value.
void expect_not_in_range_count(#function, #parameter, uintmax_t minimum, uintmax_t maximum, intmax_t count)
Add an event to repeatedly check a parameter is outside a numerical range. The check would succeed if...
void expect_check_data(function, parameter, CheckParameterValueData check_function, CMockaValueData check_data)
Add a custom parameter checking function using CMockaValueData (new API).
void expect_uint_in_set_count(#function, #parameter, uintmax_t value_array[], intmax_t count)
Add an event to check if the parameter value is part of the provided unsigned integer array.
void expect_in_range(#function, #parameter, uintmax_t minimum, uintmax_t maximum)
void expect_uint_not_value_count(#function, uintmax_t value, intmax_t count)
Add an event to repeatedly check if a parameter (uint) isn't the given value.
void expect_float(#function, #parameter, double value, double epsilon)
Add an event to check if a parameter is the given floating point value.
void expect_memory_count(#function, #parameter, void *memory, size_t size, intmax_t count)
Add an event to repeatedly check if the parameter does match an area of memory.
void expect_float_in_range_count(#function, #parameter, double minimum, double maximum, double epsilon, intmax_t count)
Add an event to repeatedly check a parameter is inside a numerical range. The check would succeed if ...
void check_expected_float(#parameter)
Determine whether a function parameter is correct.
void expect_float_in_range(#function, #parameter, double minimum, double maximum, double epsilon)
Add an event to check a parameter is inside a numerical range. The check would succeed if minimum <= ...
void expect_double(#function, #parameter, double value, double epsilon)
Add an event to check if a parameter is the given double precision floating point value.
void expect_string(#function, #parameter, const char *string)
Add an event to check if the parameter value is equal to the provided string.
void expect_in_range_count(#function, #parameter, uintmax_t minimum, uintmax_t maximum, intmax_t count)
void expect_not_string_count(#function, #parameter, const char *string, intmax_t count)
Add an event to check if the parameter value isn't equal to the provided string.
void expect_int_value(#function, #parameter, intmax_t value)
Add an event to check if an integer parameter is the given value.
void expect_int_not_in_set(#function, #parameter, intmax_t value_array[])
Add an event to check if the integer parameter value is not part of the provided integer array.
int(*) CheckParameterValue(const uintmax_t value, const uintmax_t check_value_data)
Definition cmocka.h:6431
void expect_any_always(#function, #parameter)
Add an event to always check if a parameter (of any value) has been passed.
void expect_uint_in_range(#function, uintmax_t minimum, uintmax_t maximum)
Add an event to check an unsigned integer parameter is inside a numerical range. The check would succ...
void expect_not_memory(#function, #parameter, void *memory, size_t size)
Add an event to check if the parameter doesn't match an area of memory.
void expect_not_in_range(#function, #parameter, uintmax_t minimum, uintmax_t maximum)
Add an event to check a parameter is outside a numerical range. The check would succeed if minimum > ...
void expect_check_count(function, parameter, CheckParameterValue check_function, const void *check_data, intmax_t count)
void expect_uint_value(#function, #parameter, uintmax_t value)
Add an event to check if an unsigned integer parameter is the given value.
void check_expected_int(#parameter)
Determine whether a function parameter is correct.
void expect_string_count(#function, #parameter, const char *string, intmax_t count)
Add an event to check if the parameter value is equal to the provided string.
void expect_any_count(#function, #parameter, intmax_t count)
Add an event to repeatedly check if a parameter (of any value) has been passed.
void expect_int_in_set_count(#function, #parameter, intmax_t value_array[], intmax_t count)
Add an event to check if the parameter value is part of the provided integer array.
void check_expected_double(#parameter)
Determine whether a function parameter is correct.
void expect_check_data_count(function, parameter, CheckParameterValueData check_function, CMockaValueData check_data, intmax_t count)
Add a custom parameter checking function using CMockaValueData with count (new API).
void expect_not_value(#function, #parameter, uintmax_t value)
void expect_memory(#function, #parameter, void *memory, size_t size)
Add an event to check if the parameter does match an area of memory.
void expect_int_in_range(#function, intmax_t minimum, intmax_t maximum)
Add an event to check an integer parameter is inside a numerical range. The check would succeed if mi...
void expect_not_float(#function, #parameter, double value, double epsilon)
Add an event to check if a parameter isn't the given floating point value.
void check_expected_uint(#parameter)
Determine whether a function parameter is correct.
void expect_float_count(#function, #parameter, double value, double epsilon, intmax_t count)
Add an event to repeatedly check if a parameter is the given floating point value.
void expect_not_value_count(#function, #parameter, uintmax_t value, intmax_t count)
void expect_in_set_count(#function, #parameter, uintmax_t value_array[], intmax_t count)
void expect_any(#function, #parameter)
Add an event to check if a parameter (of any value) has been passed.
void expect_float_in_set(#function, #parameter, double value_array[], double epsilon)
Add an event to check if the float parameter value is part of the provided array.
void expect_not_in_set(#function, #parameter, uintmax_t value_array[])
void expect_float_in_set_count(#function, #parameter, double value_array[], double epsilon, intmax_t count)
Add an event to check if the float parameter value is part of the provided integer array.
void expect_float_not_in_range(#function, #parameter, double minimum, double maximum, double epsilon)
Add an event to check a parameter is outside a numerical range. The check would succeed if minimum > ...
void expect_not_in_set_count(#function, #parameter, uintmax_t value_array[], intmax_t count)
void check_expected_any(#parameter)
Check that any parameter value matches the next value in the queue.
void expect_int_not_in_range_count(#function, intmax_t minimum, intmax_t maximum, intmax_t count)
Add an event to repeatedly check an integer parameter is outside a numerical range....
void expect_value(#function, #parameter, uintmax_t value)
int(*) CheckIntParameterValue(const intmax_t value, const intmax_t check_value_data)
Definition cmocka.h:6447
void expect_not_float_count(#function, #parameter, double value, double epsilon, intmax_t count)
Add an event to repeatedly check if a parameter isn't the floating point value.
void expect_check(function, parameter, CheckParameterValue check_function, const void *check_data)
void expect_uint_not_in_range_count(#function, uintmax_t minimum, uintmax_t maximum, intmax_t count)
Add an event to repeatedly check an unsigned integer parameter is outside a numerical range....
void expect_not_double(#function, #parameter, double value, double epsilon)
Add an event to check if a parameter isn't the given double precision floating point value.
void expect_uint_not_value(#function, #parameter, uintmax_t value)
Add an event to check if a parameter (uint) isn't the given value.
void expect_int_not_value(#function, #parameter, intmax_t value)
Add an event to check if a parameter (int) isn't the given value.
void expect_in_set(#function, #parameter, uintmax_t value_array[])
int(*) CheckParameterValueData(const CMockaValueData value, const CMockaValueData check_value_data)
Definition cmocka.h:6439
void expect_uint_not_in_set(#function, #parameter, uintmax_t value_array[])
Add an event to check if the unsigned integer parameter value is not part of the provided unsigned in...
void expect_float_not_in_set_count(#function, #parameter, double value_array[], double epsilon, intmax_t count)
Add an event to check if the float parameter value is not part of the provided integer array.
void expect_int_value_count(#function, intmax_t value, intmax_t count)
Add an event to repeatedly check if an integer parameter is the given value.
void expect_int_not_in_range(#function, intmax_t minimum, intmax_t maximum)
Add an event to check an integer parameter is outside a numerical range. The check would succeed if m...
void(*) vprint_message(const char *const format, va_list args)
Definition cmocka.h:6587
void(*) vprint_error(const char *const format, va_list args)
Definition cmocka.h:6596
double real_val
Definition cmocka.h:6384
float float_val
Definition cmocka.h:6382
const void * const_ptr
Definition cmocka.h:6388
void * ptr
Definition cmocka.h:6386
intmax_t int_val
Definition cmocka.h:6378
uintmax_t uint_val
Definition cmocka.h:6380