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) \
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)
203#define CMOCKA_DEPRECATED __attribute__ ((deprecated))
208#define CMOCKA_DEPRECATED
212#if defined(__GNUC__) || defined(__clang__)
216#define CMOCKA_DEPRECATION_WARNING(msg) \
218 typedef int cmocka_macro __attribute__((deprecated(msg))); \
219 cmocka_macro cmocka_deprecated_var __attribute__((unused)) = 0; \
220 (void)sizeof(cmocka_deprecated_var); \
222#elif defined(_MSC_VER)
223#define CMOCKA_DEPRECATION_WARNING(msg) __pragma(message("warning: " msg))
225#define CMOCKA_DEPRECATION_WARNING(msg)
229#define CMOCKA_NORETURN __attribute__ ((noreturn))
230#elif defined(_MSC_VER)
231#define CMOCKA_NORETURN __declspec(noreturn)
233#define CMOCKA_NORETURN
245#ifdef __has_attribute
246#if __has_attribute(access)
247#define CMOCKA_NO_ACCESS_ATTRIBUTE \
248 __attribute__((access(none, 1), access(none, 2)))
251#ifndef CMOCKA_NO_ACCESS_ATTRIBUTE
252#define CMOCKA_NO_ACCESS_ATTRIBUTE
322#define WILL_RETURN_ALWAYS -1
335#define WILL_RETURN_ONCE -2
346#define EXPECT_ALWAYS -1
357#define EXPECT_MAYBE -2
369#define mock() (_mock(__func__, __FILE__, __LINE__, NULL)).uint_val
396#define mock_type(type) ((type) mock())
427#define has_mock() _has_mock(__func__)
447#define mock_int() (_mock(__func__, __FILE__, __LINE__, NULL)).int_val
467#define mock_uint() (_mock(__func__, __FILE__, __LINE__, "uintmax_t")).uint_val
481#define mock_float() (_mock(__func__, __FILE__, __LINE__, NULL)).float_val
495#define mock_double() (_mock(__func__, __FILE__, __LINE__, NULL)).real_val
521#define mock_ptr_type(type) \
522 ((type)(_mock(__func__, __FILE__, __LINE__, NULL)).ptr)
549#define mock_ptr_type_checked(type) \
550 ((type)(_mock(__func__, __FILE__, __LINE__, #type)).ptr)
589#define mock_parameter(name) \
590 (_mock_parameter(__func__, #name, __FILE__, __LINE__, NULL)).uint_val
616#type mock_parameter_type(#name, #type);
618#define mock_parameter_type(name, type) ((type) mock_parameter(#name))
641#define mock_parameter_int(name) \
642 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "intmax_t")).int_val
665#define mock_parameter_uint(name) \
666 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "uintmax_t")).uint_val
689#define mock_parameter_float(name) \
690 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "float")).float_val
713#define mock_parameter_double(name) \
714 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "double")).real_val
736#define mock_parameter_ptr(name) \
737 ((_mock_parameter(__func__, #name, __FILE__, __LINE__, NULL)).ptr)
763#define mock_parameter_ptr_type(name, type) \
764 ((type)(_mock_parameter(__func__, #name, __FILE__, __LINE__, #type)).ptr)
777#define mock_errno() \
779 intmax_t err = (_mock_parameter( \
827#define will_return(function, value) \
828 _will_return(cmocka_tostring(function), \
832 cast_int_to_cmocka_value(value), \
862#define will_return_int(function, value) \
863 _will_return(#function, \
867 assign_int_to_cmocka_value(value), \
907#define will_return_int_count(function, value, count) \
908 _will_return(#function, \
912 assign_int_to_cmocka_value(value), \
943#define will_return_uint(function, value) \
944 _will_return(#function, \
948 assign_uint_to_cmocka_value(value), \
988#define will_return_uint_count(function, value, count) \
989 _will_return(#function, \
993 assign_uint_to_cmocka_value(value), \
1024#define will_return_float(function, value) \
1025 _will_return(#function, \
1029 assign_float_to_cmocka_value(value), \
1069#define will_return_float_count(function, value, count) \
1070 _will_return(#function, \
1074 assign_float_to_cmocka_value(value), \
1105#define will_return_double(function, value) \
1106 _will_return(#function, \
1110 assign_double_to_cmocka_value(value), \
1150#define will_return_double_count(function, value, count) \
1151 _will_return(#function, \
1155 assign_double_to_cmocka_value(value), \
1177#define will_return_int_always(function, value) \
1178 will_return_int_count(function, (value), WILL_RETURN_ALWAYS)
1200#define will_return_uint_always(function, value) \
1201 will_return_uint_count(function, (value), WILL_RETURN_ALWAYS)
1222#define will_return_float_always(function, value) \
1223 will_return_float_count(function, (value), WILL_RETURN_ALWAYS)
1244#define will_return_double_always(function, value) \
1245 will_return_double_count(function, (value), WILL_RETURN_ALWAYS)
1254#define will_return_count(function, value, count) \
1256 CMOCKA_DEPRECATION_WARNING( \
1257 "will_return_count: use will_return_int_count or " \
1258 "will_return_uint_count instead") \
1259 _will_return(cmocka_tostring(function), \
1263 cast_int_to_cmocka_value(value), \
1274#define will_return_always(function, value) \
1276 CMOCKA_DEPRECATION_WARNING( \
1277 "will_return_always: use will_return_int_always or " \
1278 "will_return_uint_always instead") \
1279 will_return_count(function, (value), WILL_RETURN_ALWAYS); \
1307#define will_return_int_maybe(function, value) \
1308 will_return_int_count(function, (value), WILL_RETURN_ONCE)
1336#define will_return_uint_maybe(function, value) \
1337 will_return_uint_count(function, (value), WILL_RETURN_ONCE)
1364#define will_return_float_maybe(function, value) \
1365 will_return_float_count(function, (value), WILL_RETURN_ONCE)
1392#define will_return_double_maybe(function, value) \
1393 will_return_double_count(function, (value), WILL_RETURN_ONCE)
1402#define will_return_maybe(function, value) \
1404 CMOCKA_DEPRECATION_WARNING( \
1405 "will_return_maybe: use will_return_int_maybe or " \
1406 "will_return_uint_maybe instead") \
1407 will_return_count(function, (value), WILL_RETURN_ONCE); \
1438#define will_return_ptr(function, value) \
1439 _will_return(#function, \
1443 cast_ptr_to_cmocka_value(value), \
1478#define will_return_ptr_type(function, value, type) \
1479 _will_return(#function, \
1483 cast_ptr_to_cmocka_value(value), \
1505#define will_return_ptr_count(function, value, count) \
1506 _will_return(#function, \
1510 cast_ptr_to_cmocka_value(value), \
1532#define will_return_ptr_always(function, value) \
1533 will_return_ptr_count(function, (value), WILL_RETURN_ALWAYS)
1560#define will_return_ptr_maybe(function, value) \
1561 will_return_ptr_count(function, (value), WILL_RETURN_ONCE)
1611#define will_set_parameter(function, name, value) \
1612 _will_set_parameter(cmocka_tostring(function), \
1617 cast_int_to_cmocka_value(value), \
1655#define will_set_parameter_int(function, name, value) \
1656 _will_set_parameter(#function, \
1661 assign_int_to_cmocka_value(value), \
1701#define will_set_parameter_uint(function, name, value) \
1702 _will_set_parameter(#function, \
1707 assign_uint_to_cmocka_value(value), \
1746#define will_set_parameter_float(function, name, value) \
1747 _will_set_parameter(#function, \
1752 assign_float_to_cmocka_value(value), \
1792#define will_set_parameter_double(function, name, value) \
1793 _will_set_parameter(#function, \
1798 assign_double_to_cmocka_value(value), \
1824#define will_set_parameter_int_count(function, name, value, count) \
1825 _will_set_parameter(#function, \
1830 assign_int_to_cmocka_value(value), \
1859#define will_set_parameter_uint_count(function, name, value, count) \
1860 _will_set_parameter(#function, \
1865 assign_uint_to_cmocka_value(value), \
1891#define will_set_parameter_float_count(function, name, value, count) \
1892 _will_set_parameter(#function, \
1897 assign_float_to_cmocka_value(value), \
1923#define will_set_parameter_double_count(function, name, value, count) \
1924 _will_set_parameter(#function, \
1929 assign_double_to_cmocka_value(value), \
1940#define will_set_parameter_count(function, name, value, count) \
1942 CMOCKA_DEPRECATION_WARNING( \
1943 "will_set_parameter_count: use will_set_parameter_int_count or " \
1944 "will_set_parameter_uint_count instead") \
1945 _will_set_parameter(cmocka_tostring(function), \
1950 cast_int_to_cmocka_value(value), \
1977#define will_set_parameter_int_always(function, name, value) \
1978 will_set_parameter_int_count(function, name, (value), WILL_RETURN_ALWAYS)
2003#define will_set_parameter_uint_always(function, name, value) \
2004 will_set_parameter_uint_count(function, name, (value), WILL_RETURN_ALWAYS)
2029#define will_set_parameter_float_always(function, name, value) \
2030 will_set_parameter_float_count(function, name, (value), WILL_RETURN_ALWAYS)
2055#define will_set_parameter_double_always(function, name, value) \
2056 will_set_parameter_double_count(function, name, (value), WILL_RETURN_ALWAYS)
2066#define will_set_parameter_always(function, name, value) \
2068 CMOCKA_DEPRECATION_WARNING( \
2069 "will_set_parameter_always: use will_set_parameter_int_always or " \
2070 "will_set_parameter_uint_always instead") \
2071 will_set_parameter_count(function, name, (value), WILL_RETURN_ALWAYS); \
2098#define will_set_parameter_int_maybe(function, name, value) \
2099 will_set_parameter_int_count(function, name, (value), WILL_RETURN_ONCE)
2125#define will_set_parameter_uint_maybe(function, name, value) \
2126 will_set_parameter_uint_count(function, name, (value), WILL_RETURN_ONCE)
2152#define will_set_parameter_float_maybe(function, name, value) \
2153 will_set_parameter_float_count(function, name, (value), WILL_RETURN_ONCE)
2179#define will_set_parameter_double_maybe(function, name, value) \
2180 will_set_parameter_double_count(function, name, (value), WILL_RETURN_ONCE)
2190#define will_set_parameter_maybe(function, name, value) \
2192 CMOCKA_DEPRECATION_WARNING( \
2193 "will_set_parameter_maybe: use will_set_parameter_int_maybe or " \
2194 "will_set_parameter_uint_maybe instead") \
2195 will_set_parameter_count(function, name, (value), WILL_RETURN_ONCE); \
2230#define will_set_parameter_ptr(function, name, value) \
2231 _will_set_parameter(#function, \
2236 cast_ptr_to_cmocka_value(value), \
2276#define will_set_parameter_ptr_type(function, name, value, type) \
2277 _will_set_parameter(#function, \
2282 cast_ptr_to_cmocka_value(value), \
2327#define will_set_parameter_ptr_count(function, name, value, count) \
2328 _will_set_parameter(#function, \
2333 cast_ptr_to_cmocka_value(value), \
2366#define will_set_parameter_ptr_always(function, name, value) \
2367 will_set_parameter_ptr_count(function, name, (value), WILL_RETURN_ALWAYS)
2401#define will_set_parameter_ptr_maybe(function, name, value) \
2402 will_set_parameter_ptr_count(function, name, (value), WILL_RETURN_ONCE)
2432#define will_set_errno(function, value) \
2433 _will_set_parameter(#function, \
2438 assign_int_to_cmocka_value(value), \
2483#define will_set_errno_count(function, value, count) \
2484 _will_set_parameter(#function, \
2489 assign_int_to_cmocka_value(value), \
2518#define will_set_errno_always(function, value) \
2519 will_set_errno_count(function, (value), WILL_RETURN_ALWAYS);
2547#define will_set_errno_maybe(function, value) \
2548 will_set_errno_count(function, (value), WILL_RETURN_ONCE);
2606 const void *check_data);
2608#define expect_check(function, parameter, check_function, check_data) \
2610 CMOCKA_DEPRECATION_WARNING( \
2611 "expect_check: use expect_check_data instead") \
2612 _expect_check(cmocka_tostring(function), \
2613 cmocka_tostring(parameter), \
2617 cast_to_uintmax_type(check_data), \
2631 const void *check_data,
2634#define expect_check_count( \
2635 function, parameter, check_function, check_data, count) \
2637 CMOCKA_DEPRECATION_WARNING( \
2638 "expect_check_count: use expect_check_data_count instead") \
2639 _expect_check(cmocka_tostring(function), \
2640 cmocka_tostring(parameter), \
2644 cast_to_uintmax_type(check_data), \
2811#define expect_check_data(function, parameter, check_function, check_data) \
2812 _expect_check_data(cmocka_tostring(function), \
2813 cmocka_tostring(parameter), \
2893#define expect_check_data_count(function, \
2898 _expect_check_data(cmocka_tostring(function), \
2899 cmocka_tostring(parameter), \
2914#define expect_in_set(function, parameter, value_array) \
2916 CMOCKA_DEPRECATION_WARNING("expect_in_set: use expect_int_in_set or " \
2917 "expect_uint_in_set instead") \
2918 expect_in_set_count(function, parameter, value_array, 1); \
2939#define expect_int_in_set(function, parameter, value_array) \
2940 expect_int_in_set_count(function, parameter, value_array, 1)
2958void expect_in_set(#function, #parameter, intmax_t value_array[]);
2960#define expect_uint_in_set(function, parameter, value_array) \
2961 expect_uint_in_set_count(function, parameter, value_array, 1)
2970#define expect_in_set_count(function, parameter, value_array, count) \
2972 CMOCKA_DEPRECATION_WARNING( \
2973 "expect_in_set_count: use expect_int_in_set_count or " \
2974 "expect_uint_in_set_count instead") \
2975 _expect_uint_in_set(cmocka_tostring(function), \
2976 cmocka_tostring(parameter), \
2980 sizeof(value_array) / sizeof((value_array)[0]), \
3006#define expect_int_in_set_count(function, parameter, value_array, count) \
3007 _expect_int_in_set(cmocka_tostring(function), \
3008 cmocka_tostring(parameter), \
3012 sizeof(value_array) / sizeof((value_array)[0]), \
3037#define expect_uint_in_set_count(function, parameter, value_array, count) \
3038 _expect_uint_in_set(cmocka_tostring(function), \
3039 cmocka_tostring(parameter), \
3043 sizeof(value_array) / sizeof((value_array)[0]), \
3053#define expect_not_in_set(function, parameter, value_array) \
3055 CMOCKA_DEPRECATION_WARNING( \
3056 "expect_not_in_set: use expect_int_not_in_set or " \
3057 "expect_uint_not_in_set instead") \
3058 expect_not_in_set_count(function, parameter, value_array, 1); \
3068#define expect_not_in_set_count(function, parameter, value_array, count) \
3070 CMOCKA_DEPRECATION_WARNING( \
3071 "expect_not_in_set_count: use expect_int_not_in_set_count or " \
3072 "expect_uint_not_in_set_count instead") \
3073 _expect_not_in_set(cmocka_tostring(function), \
3074 cmocka_tostring(parameter), \
3078 sizeof(value_array) / sizeof((value_array)[0]), \
3100#define expect_int_not_in_set(function, parameter, value_array) \
3101 expect_int_not_in_set_count(function, parameter, value_array, 1)
3125 intmax_t value_array[],
3128#define expect_int_not_in_set_count(function, parameter, value_array, count) \
3129 _expect_int_not_in_set(cmocka_tostring(function), \
3130 cmocka_tostring(parameter), \
3134 sizeof(value_array) / sizeof((value_array)[0]), \
3155#define expect_uint_not_in_set(function, parameter, value_array) \
3156 expect_uint_not_in_set_count(function, parameter, value_array, 1)
3180 uintmax_t value_array[],
3183#define expect_uint_not_in_set_count(function, parameter, value_array, count) \
3184 _expect_uint_not_in_set(cmocka_tostring(function), \
3185 cmocka_tostring(parameter), \
3189 sizeof(value_array) / sizeof((value_array)[0]), \
3212#define expect_float_in_set(function, parameter, value_array, epsilon) \
3213 expect_float_in_set_count(function, parameter, value_array, epsilon, 1)
3239#define expect_float_in_set_count(function, parameter, value_array, epsilon, count) \
3240 _expect_float_in_set(cmocka_tostring(function), \
3241 cmocka_tostring(parameter), \
3245 sizeof(value_array) / sizeof((value_array)[0]), \
3269#define expect_float_not_in_set(function, parameter, value_array, epsilon) \
3270 expect_float_not_in_set_count(function, parameter, value_array, epsilon, 1)
3296#define expect_float_not_in_set_count(function, parameter, value_array, epsilon, count) \
3297 _expect_float_not_in_set(cmocka_tostring(function), \
3298 cmocka_tostring(parameter), \
3302 sizeof(value_array) / sizeof((value_array)[0]), \
3314#define expect_in_range(function, parameter, minimum, maximum) \
3316 CMOCKA_DEPRECATION_WARNING( \
3317 "expect_in_range: use expect_int_in_range or " \
3318 "expect_uint_in_range instead") \
3319 expect_in_range_count(function, parameter, minimum, maximum, 1); \
3329#define expect_in_range_count(function, parameter, minimum, maximum, count) \
3331 CMOCKA_DEPRECATION_WARNING( \
3332 "expect_in_range_count: use expect_int_in_range_count or " \
3333 "expect_uint_in_range_count instead") \
3334 _expect_in_range(cmocka_tostring(function), \
3335 cmocka_tostring(parameter), \
3366#define expect_int_in_range(function, parameter, minimum, maximum) \
3367 expect_int_in_range_count(function, parameter, minimum, maximum, 1)
3397#define expect_int_in_range_count( \
3398 function, parameter, minimum, maximum, count) \
3399 _expect_int_in_range(cmocka_tostring(function), \
3400 cmocka_tostring(parameter), \
3430#define expect_uint_in_range(function, parameter, minimum, maximum) \
3431 expect_uint_in_range_count(function, parameter, minimum, maximum, 1)
3462#define expect_uint_in_range_count( \
3463 function, parameter, minimum, maximum, count) \
3464 _expect_uint_in_range(cmocka_tostring(function), \
3465 cmocka_tostring(parameter), \
3492#define expect_not_in_range(function, parameter, minimum, maximum) \
3493 expect_not_in_range_count(function, parameter, minimum, maximum, 1)
3519#define expect_not_in_range_count(function, parameter, minimum, maximum, \
3521 _expect_not_in_range(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
3522 minimum, maximum, count)
3547#define expect_int_not_in_range(function, parameter, minimum, maximum) \
3548 expect_int_not_in_range_count(function, parameter, minimum, maximum, 1)
3578#define expect_int_not_in_range_count( \
3579 function, parameter, minimum, maximum, count) \
3580 _expect_int_not_in_range(cmocka_tostring(function), \
3581 cmocka_tostring(parameter), \
3611#define expect_uint_not_in_range(function, parameter, minimum, maximum) \
3612 expect_uint_not_in_range_count(function, parameter, minimum, maximum, 1)
3643#define expect_uint_not_in_range_count( \
3644 function, parameter, minimum, maximum, count) \
3645 _expect_uint_not_in_range(cmocka_tostring(function), \
3646 cmocka_tostring(parameter), \
3675#define expect_float_in_range(function, parameter, minimum, maximum, epsilon) \
3676 expect_float_in_range_count(function, parameter, minimum, maximum, epsilon, 1)
3704#define expect_float_in_range_count(function, parameter, minimum, maximum, epsilon, count) \
3705 _expect_float_in_range(cmocka_tostring(function), \
3706 cmocka_tostring(parameter), \
3709 cast_to_double_type(minimum), \
3710 cast_to_double_type(maximum), \
3711 cast_to_double_type(epsilon), \
3736#define expect_float_not_in_range(function, parameter, minimum, maximum, epsilon) \
3737 expect_float_not_in_range_count(function, parameter, minimum, maximum, epsilon, 1)
3765#define expect_float_not_in_range_count(function, parameter, minimum, maximum, \
3767 _expect_float_not_in_range(cmocka_tostring(function), \
3768 cmocka_tostring(parameter), \
3771 cast_to_double_type(minimum), \
3772 cast_to_double_type(maximum), \
3773 cast_to_double_type(epsilon), \
3783#define expect_value(function, parameter, value) \
3785 CMOCKA_DEPRECATION_WARNING("expect_value: use expect_int_value or " \
3786 "expect_uint_value instead") \
3787 expect_value_count(function, parameter, value, 1); \
3797#define expect_value_count(function, parameter, value, count) \
3799 CMOCKA_DEPRECATION_WARNING( \
3800 "expect_value_count: use expect_int_value_count or " \
3801 "expect_uint_value_count instead") \
3802 _expect_value(cmocka_tostring(function), \
3803 cmocka_tostring(parameter), \
3806 cast_to_uintmax_type(value), \
3827#define expect_int_value(function, parameter, value) \
3828 expect_int_value_count(function, parameter, value, 1)
3855#define expect_int_value_count(function, parameter, value, count) \
3856 _expect_int_value(cmocka_tostring(function), \
3857 cmocka_tostring(parameter), \
3881#define expect_uint_value(function, parameter, value) \
3882 expect_uint_value_count(function, parameter, value, 1)
3909#define expect_uint_value_count(function, parameter, value, count) \
3910 _expect_uint_value(cmocka_tostring(function), \
3911 cmocka_tostring(parameter), \
3934#define expect_int_not_value(function, parameter, value) \
3935 expect_int_not_value_count(function, parameter, value, 1)
3962#define expect_int_not_value_count(function, parameter, value, count) \
3963 _expect_int_not_value(cmocka_tostring(function), \
3964 cmocka_tostring(parameter), \
3987#define expect_uint_not_value(function, parameter, value) \
3988 expect_uint_not_value_count(function, parameter, value, 1)
4015#define expect_uint_not_value_count(function, parameter, value, count) \
4016 _expect_uint_not_value(cmocka_tostring(function), \
4017 cmocka_tostring(parameter), \
4030#define expect_not_value(function, parameter, value) \
4032 CMOCKA_DEPRECATION_WARNING( \
4033 "expect_not_value: use expect_int_not_value or " \
4034 "expect_uint_not_value instead") \
4035 expect_not_value_count(function, parameter, value, 1); \
4045#define expect_not_value_count(function, parameter, value, count) \
4047 CMOCKA_DEPRECATION_WARNING( \
4048 "expect_not_value_count: use expect_int_not_value_count or " \
4049 "expect_uint_not_value_count instead") \
4050 _expect_not_value(cmocka_tostring(function), \
4051 cmocka_tostring(parameter), \
4054 cast_to_uintmax_type(value), \
4080#define expect_float(function, parameter, value, epsilon) \
4081 expect_float_count(function, parameter, cast_to_double_type(value), \
4082 cast_to_double_type(epsilon), 1)
4110#define expect_float_count(function, parameter, value, epsilon, count) \
4111 _expect_float(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4112 cast_to_double_type(value), cast_to_double_type(epsilon), count)
4137#define expect_not_float(function, parameter, value, epsilon) \
4138 expect_not_float_count(function, \
4140 cast_to_float_type(value), \
4141 cast_to_float_type(epsilon), \
4170#define expect_not_float_count(function, parameter, value, epsilon, count) \
4171 _expect_not_float(cmocka_tostring(function), \
4172 cmocka_tostring(parameter), \
4175 cast_to_float_type(value), \
4176 cast_to_float_type(epsilon), \
4200#define expect_double(function, parameter, value, epsilon) \
4201 expect_double_count(function, \
4203 cast_to_double_type(value), \
4204 cast_to_double_type(epsilon), \
4236#define expect_double_count(function, parameter, value, epsilon, count) \
4237 _expect_double(cmocka_tostring(function), \
4238 cmocka_tostring(parameter), \
4241 cast_to_double_type(value), \
4242 cast_to_double_type(epsilon), \
4266#define expect_not_double(function, parameter, value, epsilon) \
4267 expect_not_double_count(function, \
4269 cast_to_double_type(value), \
4270 cast_to_double_type(epsilon), \
4302#define expect_not_double_count(function, parameter, value, epsilon, count) \
4303 _expect_not_double(cmocka_tostring(function), \
4304 cmocka_tostring(parameter), \
4307 cast_to_double_type(value), \
4308 cast_to_double_type(epsilon), \
4329#define expect_string(function, parameter, string) \
4330 expect_string_count(function, parameter, string, 1)
4354#define expect_string_count(function, parameter, string, count) \
4355 _expect_string(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4356 (const char*)(string), count)
4376#define expect_not_string(function, parameter, string) \
4377 expect_not_string_count(function, parameter, string, 1)
4401#define expect_not_string_count(function, parameter, string, count) \
4402 _expect_not_string(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4403 (const char*)(string), count)
4424#define expect_memory(function, parameter, memory, size) \
4425 expect_memory_count(function, parameter, memory, size, 1)
4451#define expect_memory_count(function, parameter, memory, size, count) \
4452 _expect_memory(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4453 (const void*)(memory), size, count)
4475#define expect_not_memory(function, parameter, memory, size) \
4476 expect_not_memory_count(function, parameter, memory, size, 1)
4502#define expect_not_memory_count(function, parameter, memory, size, count) \
4503 _expect_not_memory(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4504 (const void*)(memory), size, count)
4522#define expect_any(function, parameter) \
4523 expect_any_count(function, parameter, 1)
4540#define expect_any_always(function, parameter) \
4541 expect_any_count(function, parameter, WILL_RETURN_ALWAYS)
4563#define expect_any_count(function, parameter, count) \
4564 _expect_any(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, count)
4574#define check_expected(parameter) \
4576 CMOCKA_DEPRECATION_WARNING( \
4577 "check_expected: use check_expected_int or " \
4578 "check_expected_uint instead") \
4579 _check_expected(__func__, \
4583 cast_int_to_cmocka_value(parameter)); \
4617#define check_expected_any(parameter) \
4618 _check_expected(__func__, #parameter, __FILE__, __LINE__, \
4619 cast_ptr_to_cmocka_value(&(parameter)))
4635#define check_expected_ptr(parameter) \
4636 _check_expected(__func__, #parameter, __FILE__, __LINE__, \
4637 cast_ptr_to_cmocka_value(parameter))
4653#define check_expected_int(parameter) \
4654 _check_expected(__func__, \
4658 assign_int_to_cmocka_value(parameter))
4674#define check_expected_uint(parameter) \
4675 _check_expected(__func__, \
4679 assign_uint_to_cmocka_value(parameter))
4700#define check_expected_float(parameter) \
4701 _check_expected(__func__, \
4705 assign_float_to_cmocka_value(parameter))
4726#define check_expected_double(parameter) \
4727 _check_expected(__func__, \
4731 assign_double_to_cmocka_value(parameter))
4774#define assert_true(c) _assert_true(cast_to_uintmax_type(c), #c, \
4792#define assert_false(c) _assert_false(cast_to_uintmax_type(c), #c, \
4811#define assert_return_code(rc, error) \
4812 _assert_return_code((rc), \
4814 #rc, __FILE__, __LINE__)
4830#define assert_non_null(c) assert_ptr_not_equal((c), NULL)
4848#define assert_non_null_msg(c, msg) assert_ptr_not_equal_msg((c), NULL, (msg))
4864#define assert_null(c) assert_ptr_equal((c), NULL)
4882#define assert_null_msg(c, msg) assert_ptr_equal_msg((c), NULL, (msg))
4898#define assert_ptr_equal(a, b) assert_ptr_equal_msg((a), (b), NULL)
4916#define assert_ptr_equal_msg(a, b, msg) \
4917 _assert_ptr_equal_msg(cast_to_void_pointer(a), \
4918 cast_to_void_pointer(b), \
4919 __FILE__, __LINE__, (msg))
4935#define assert_ptr_not_equal(a, b) \
4936 assert_ptr_not_equal_msg((a), (b), NULL)
4955#if defined(__has_builtin)
4957#if __has_builtin(__builtin_unreachable)
4958#define assert_ptr_not_equal_msg(a, b, msg) \
4960 const void *cmocka_p1 = cast_to_void_pointer(a), \
4961 *cmocka_p2 = cast_to_void_pointer(b); \
4962 _assert_ptr_not_equal_msg( \
4963 cmocka_p1, cmocka_p2, __FILE__, __LINE__, (msg)); \
4964 if (cmocka_p1 == cmocka_p2) { \
4965 __builtin_unreachable(); \
4969#define assert_ptr_not_equal_msg(a, b, msg) \
4970_assert_ptr_not_equal_msg(cast_to_void_pointer(a), \
4971 cast_to_void_pointer(b), \
4978#define assert_ptr_not_equal_msg(a, b, msg) \
4979_assert_ptr_not_equal_msg(cast_to_void_pointer(a), \
4980 cast_to_void_pointer(b), \
5001#define assert_int_equal(a, b) \
5002 _assert_int_equal(cast_to_intmax_type(a), \
5003 cast_to_intmax_type(b), \
5020#define assert_uint_equal(a, b) \
5021 _assert_uint_equal(cast_to_uintmax_type(a), \
5022 cast_to_uintmax_type(b), \
5041#define assert_int_not_equal(a, b) \
5042 _assert_int_not_equal(cast_to_intmax_type(a), \
5043 cast_to_intmax_type(b), \
5060#define assert_uint_not_equal(a, b) \
5061 _assert_uint_not_equal(cast_to_uintmax_type(a), \
5062 cast_to_uintmax_type(b), \
5081#define assert_float_equal(a, b, epsilon) \
5082 _assert_float_equal((float)a, \
5103#define assert_float_not_equal(a, b, epsilon) \
5104 _assert_float_not_equal((float)a, \
5125#define assert_double_equal(a, b, epsilon) \
5126 _assert_double_equal((double)a, \
5147#define assert_double_not_equal(a, b, epsilon) \
5148 _assert_double_not_equal((double)a, \
5168#define assert_string_equal(a, b) \
5169 _assert_string_equal((a), (b), __FILE__, __LINE__)
5185#define assert_string_not_equal(a, b) \
5186 _assert_string_not_equal((a), (b), __FILE__, __LINE__)
5206#define assert_memory_equal(a, b, size) \
5207 _assert_memory_equal((const void*)(a), (const void*)(b), size, __FILE__, \
5228#define assert_memory_not_equal(a, b, size) \
5229 _assert_memory_not_equal((const void*)(a), (const void*)(b), size, \
5249#define assert_int_in_range(value, minimum, maximum) \
5250 _assert_int_in_range( \
5251 cast_to_intmax_type(value), \
5252 cast_to_intmax_type(minimum), \
5253 cast_to_intmax_type(maximum), __FILE__, __LINE__)
5272#define assert_uint_in_range(value, minimum, maximum) \
5273 _assert_uint_in_range( \
5274 cast_to_intmax_type(value), \
5275 cast_to_intmax_type(minimum), \
5276 cast_to_intmax_type(maximum), __FILE__, __LINE__)
5300#define assert_int_not_in_range(value, minimum, maximum) \
5301 _assert_int_not_in_range(cast_to_intmax_type(value), \
5302 cast_to_intmax_type(minimum), \
5303 cast_to_intmax_type(maximum), \
5329#define assert_uint_not_in_range(value, minimum, maximum) \
5330 _assert_uint_not_in_range(cast_to_uintmax_type(value), \
5331 cast_to_uintmax_type(minimum), \
5332 cast_to_uintmax_type(maximum), \
5343#define assert_in_range(value, minimum, maximum) \
5345 CMOCKA_DEPRECATION_WARNING( \
5346 "assert_in_range: use assert_int_in_range or " \
5347 "assert_uint_in_range instead") \
5348 _assert_uint_in_range(cast_to_uintmax_type(value), \
5349 cast_to_uintmax_type(minimum), \
5350 cast_to_uintmax_type(maximum), \
5362#define assert_not_in_range(value, minimum, maximum) \
5364 CMOCKA_DEPRECATION_WARNING( \
5365 "assert_not_in_range: use assert_int_not_in_range or " \
5366 "assert_uint_not_in_range instead") \
5367 _assert_uint_not_in_range(cast_to_uintmax_type(value), \
5368 cast_to_uintmax_type(minimum), \
5369 cast_to_uintmax_type(maximum), \
5396#define assert_float_not_in_range(value, minimum, maximum, epsilon) \
5397 _assert_float_not_in_range(cast_to_double_type(value), \
5398 cast_to_double_type(minimum), \
5399 cast_to_double_type(maximum), \
5400 cast_to_double_type(epsilon), \
5423#define assert_float_in_range(value, minimum, maximum, epsilon) \
5424 _assert_float_in_range( \
5425 cast_to_double_type(value), \
5426 cast_to_double_type(minimum), \
5427 cast_to_double_type(maximum), \
5428 cast_to_double_type(epsilon), __FILE__, __LINE__)
5437#define assert_in_set(value, values, number_of_values) \
5439 CMOCKA_DEPRECATION_WARNING("assert_in_set: use assert_int_in_set or " \
5440 "assert_uint_in_set instead") \
5441 _assert_uint_in_set( \
5442 value, values, number_of_values, __FILE__, __LINE__); \
5461#define assert_not_in_set(value, values, number_of_values) \
5462 _assert_not_in_set(value, values, number_of_values, __FILE__, __LINE__)
5480#define assert_int_in_set(value, values, number_of_values) \
5481 if (number_of_values > 0) { \
5482 intmax_t _cmocka_set[number_of_values]; \
5483 for (size_t _i = 0; _i < number_of_values; _i++) { \
5484 _cmocka_set[_i] = values[_i]; \
5486 _assert_int_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5505#define assert_int_not_in_set(value, values, number_of_values) \
5506 if (number_of_values > 0) { \
5507 intmax_t _cmocka_set[number_of_values]; \
5508 for (size_t _i = 0; _i < number_of_values; _i++) { \
5509 _cmocka_set[_i] = values[_i]; \
5511 _assert_int_not_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5530#define assert_uint_in_set(value, values, number_of_values) \
5531 if (number_of_values > 0) { \
5532 uintmax_t _cmocka_set[number_of_values]; \
5533 for (size_t _i = 0; _i < number_of_values; _i++) { \
5534 _cmocka_set[_i] = values[_i]; \
5536 _assert_uint_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5555#define assert_uint_not_in_set(value, values, number_of_values) \
5556 if (number_of_values > 0) { \
5557 uintmax_t _cmocka_set[number_of_values]; \
5558 for (size_t _i = 0; _i < number_of_values; _i++) { \
5559 _cmocka_set[_i] = values[_i]; \
5561 _assert_uint_not_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5582#define assert_float_in_set(value, values, number_of_values, epsilon) \
5583 if (number_of_values > 0) { \
5584 double _cmocka_set[number_of_values]; \
5585 for (size_t _i = 0; _i < number_of_values; _i++) { \
5586 _cmocka_set[_i] = values[_i]; \
5588 _assert_float_in_set(value, _cmocka_set, number_of_values, epsilon, __FILE__, __LINE__); \
5609#define assert_float_not_in_set(value, values, number_of_values, epsilon) \
5610 if (number_of_values > 0) { \
5611 double _cmocka_set[number_of_values]; \
5612 for (size_t _i = 0; _i < number_of_values; _i++) { \
5613 _cmocka_set[_i] = values[_i]; \
5615 _assert_float_not_in_set(value, _cmocka_set, number_of_values, epsilon, __FILE__, __LINE__); \
5694#define function_called() _function_called(__func__, __FILE__, __LINE__)
5710#define expect_function_calls(function, times) \
5711 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, times)
5725#define expect_function_call(function) \
5726 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, 1)
5739#define expect_function_call_any(function) \
5740 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, -1)
5753#define ignore_function_calls(function) \
5754 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, -2)
5797#define fail() _fail(__FILE__, __LINE__)
5806#define skip() _skip(__FILE__, __LINE__)
5820#define stop() _stop()
5840#define fail_msg(msg, ...) do { \
5841 cmocka_print_error("ERROR: " msg "\n", ##__VA_ARGS__); \
5846static inline void _unit_test_dummy(
void **state) {
5854#define unit_test(f) \
5855 (CMOCKA_DEPRECATION_WARNING("unit_test: use cmocka_unit_test instead")( \
5856 UnitTest){#f, f, UNIT_TEST_FUNCTION_TYPE_TEST})
5859#define _unit_test_setup(test, setup) \
5860 { #test "_" #setup, setup, UNIT_TEST_FUNCTION_TYPE_SETUP }
5867#define unit_test_setup(test, setup) \
5868 CMOCKA_DEPRECATION_WARNING( \
5869 "unit_test_setup: use cmocka_unit_test_setup instead") \
5870 _unit_test_setup(test, setup), unit_test(test), \
5871 _unit_test_teardown(test, _unit_test_dummy)
5874#define _unit_test_teardown(test, teardown) \
5875 { #test "_" #teardown, teardown, UNIT_TEST_FUNCTION_TYPE_TEARDOWN }
5882#define unit_test_teardown(test, teardown) \
5883 CMOCKA_DEPRECATION_WARNING( \
5884 "unit_test_teardown: use cmocka_unit_test_teardown instead") \
5885 _unit_test_setup(test, _unit_test_dummy), unit_test(test), \
5886 _unit_test_teardown(test, teardown)
5892#define group_test_setup(setup) \
5893 (CMOCKA_DEPRECATION_WARNING( \
5894 "group_test_setup: use cmocka_run_group_tests instead")(UnitTest){ \
5895 "group_" #setup, setup, UNIT_TEST_FUNCTION_TYPE_GROUP_SETUP})
5901#define group_test_teardown(teardown) \
5902 (CMOCKA_DEPRECATION_WARNING( \
5903 "group_test_teardown: use cmocka_run_group_tests instead")(UnitTest){ \
5904 "group_" #teardown, teardown, UNIT_TEST_FUNCTION_TYPE_GROUP_TEARDOWN})
5913#define unit_test_setup_teardown(test, setup, teardown) \
5914 CMOCKA_DEPRECATION_WARNING("unit_test_setup_teardown: use " \
5915 "cmocka_unit_test_setup_teardown instead") \
5916 _unit_test_setup(test, setup), unit_test(test), \
5917 _unit_test_teardown(test, teardown)
5920#define cmocka_unit_test(f) { #f, f, NULL, NULL, NULL }
5923#define cmocka_unit_test_setup(f, setup) { #f, f, setup, NULL, NULL }
5926#define cmocka_unit_test_teardown(f, teardown) { #f, f, NULL, teardown, NULL }
5932#define cmocka_unit_test_setup_teardown(f, setup, teardown) { #f, f, setup, teardown, NULL }
5941#define cmocka_unit_test_prestate(f, state) { #f, f, NULL, NULL, state }
5950#define cmocka_unit_test_prestate_setup_teardown(f, setup, teardown, state) { #f, f, setup, teardown, state }
6013# define cmocka_run_group_tests(group_tests, group_setup, group_teardown) \
6014 _cmocka_run_group_tests(#group_tests, group_tests, sizeof(group_tests) / sizeof((group_tests)[0]), group_setup, group_teardown)
6082# define cmocka_run_group_tests_name(group_name, group_tests, group_setup, group_teardown) \
6083 _cmocka_run_group_tests(group_name, group_tests, sizeof(group_tests) / sizeof((group_tests)[0]), group_setup, group_teardown)
6173#define test_malloc(size) _test_malloc(size, __FILE__, __LINE__)
6192#define test_calloc(num, size) _test_calloc(num, size, __FILE__, __LINE__)
6208#define test_realloc(ptr, size) _test_realloc(ptr, size, __FILE__, __LINE__)
6221#define test_free(ptr) _test_free(ptr, __FILE__, __LINE__)
6224#if defined(UNIT_TESTING) && defined(ALLOCATION_TESTING)
6225#define malloc test_malloc
6226#define realloc test_realloc
6227#define calloc test_calloc
6228#define free test_free
6284void mock_assert(
const int result,
const char*
const expression,
6285 const char *
const file,
const int line);
6312#define expect_assert_failure(function_call) \
6314 global_expecting_assert = 1; \
6315 if (setjmp(global_expect_assert_env) != 0) { \
6316 print_message("Expected assertion %s occurred\n", \
6317 global_last_failed_assert); \
6318 global_expecting_assert = 0; \
6321 global_expecting_assert = 0; \
6322 print_error("Expected assert in %s\n", #function_call); \
6323 _fail(__FILE__, __LINE__); \
6352 void *(*func)(void);
6360#define LargestIntegralType uintmax_t
6365#if defined(__GNUC__)
6366#define cast_ptr_to_largest_integral_type(value) \
6368 CMOCKA_DEPRECATION_WARNING( \
6369 "cast_ptr_to_largest_integral_type: " \
6370 "use cast_ptr_to_uintmax_type instead"); \
6371 cast_ptr_to_uintmax_type(value); \
6374#define cast_ptr_to_largest_integral_type(value) \
6375 cast_ptr_to_uintmax_type(value)
6392 const uintmax_t check_value_data);
6408 const intmax_t check_value_data);
6416 const uintmax_t check_value_data);
6424 UNIT_TEST_FUNCTION_TYPE_TEST = 0,
6425 UNIT_TEST_FUNCTION_TYPE_SETUP,
6426 UNIT_TEST_FUNCTION_TYPE_TEARDOWN,
6427 UNIT_TEST_FUNCTION_TYPE_GROUP_SETUP,
6428 UNIT_TEST_FUNCTION_TYPE_GROUP_TEARDOWN,
6451 const size_t number_of_tests;
6476 void *initial_state;
6496 const char *parameter_name;
6498 uintmax_t check_value_data;
6508 const char *parameter_name;
6528void print_message(
const char*
const format, ...) CMOCKA_PRINTF_ATTRIBUTE(1, 2);
6529void print_error(const
char* const format, ...) CMOCKA_PRINTF_ATTRIBUTE(1, 2);
6530void vprint_message(const
char* const format, va_list args) CMOCKA_PRINTF_ATTRIBUTE(1, 0);
6531void vprint_error(const
char* const format, va_list args) CMOCKA_PRINTF_ATTRIBUTE(1, 0);
6602#define cm_print_error(format, ...) \
6604 CMOCKA_DEPRECATION_WARNING( \
6605 "cm_print_error: use cmocka_print_error instead") \
6606 cmocka_print_error(format, ##__VA_ARGS__); \
6690CMOCKA_DLLEXTERN extern
int global_expecting_assert;
6691CMOCKA_DLLEXTERN extern jmp_buf global_expect_assert_env;
6692CMOCKA_DLLEXTERN extern const
char * global_last_failed_assert;
6696 const
char *const file,
6702 const
char *const file,
6706bool _has_mock(const
char *const function);
6708void _expect_function_call(
6709 const
char * const function_name,
6710 const
char * const file,
6714void _function_called(const
char * const function, const
char* const file,
6719 const
char* const function, const
char* const parameter,
6720 const
char* const file, const
int line,
6723 const
int count) CMOCKA_DEPRECATED;
6726void _expect_check_data(
6727 const
char* const function, const
char* const parameter,
6728 const
char* const file, const
int line,
6733void _expect_int_in_set(const
char *const function,
6734 const
char *const parameter,
6735 const
char *const file,
6737 const intmax_t values[],
6738 const
size_t number_of_values,
6739 const
size_t count);
6740void _expect_uint_in_set(const
char *const function,
6741 const
char *const parameter,
6742 const
char *const file,
6744 const uintmax_t values[],
6745 const
size_t number_of_values,
6746 const
size_t count);
6748void _expect_float_in_set(const
char *const function,
6749 const
char *const parameter,
6750 const
char *const file,
6752 const
double values[],
6753 const
size_t number_of_values,
6754 const
double epsilon,
6755 const
size_t count);
6757void _expect_not_in_set(
6758 const
char* const function, const
char* const parameter,
6759 const
char* const file, const
int line, const uintmax_t values[],
6760 const
size_t number_of_values, const
int count);
6761void _expect_int_not_in_set(const
char *const function,
6762 const
char *const parameter,
6763 const
char *const file,
6765 const intmax_t values[],
6766 const
size_t number_of_values,
6767 const
size_t count);
6768void _expect_uint_not_in_set(const
char *const function,
6769 const
char *const parameter,
6770 const
char *const file,
6772 const uintmax_t values[],
6773 const
size_t number_of_values,
6774 const
size_t count);
6776void _expect_float_not_in_set(
6777 const
char* const function, const
char* const parameter,
6778 const
char* const file, const
size_t line, const
double values[],
6779 const
size_t number_of_values, const
double epsilon, const
size_t count);
6781void _expect_in_range(const
char *const function,
6782 const
char *const parameter,
6783 const
char *const file,
6785 const uintmax_t minimum,
6786 const uintmax_t maximum,
6787 const
int count) CMOCKA_DEPRECATED;
6788void _expect_int_in_range(const
char *const function,
6789 const
char *const parameter,
6790 const
char *const file,
6792 const intmax_t minimum,
6793 const intmax_t maximum,
6794 const
size_t count);
6795void _expect_uint_in_range(const
char *const function,
6796 const
char *const parameter,
6797 const
char *const file,
6799 const uintmax_t minimum,
6800 const uintmax_t maximum,
6801 const
size_t count);
6802void _expect_not_in_range(
6803 const
char* const function, const
char* const parameter,
6804 const
char* const file, const
int line,
6805 const uintmax_t minimum,
6806 const uintmax_t maximum, const
int count);
6807void _expect_int_not_in_range(const
char *const function,
6808 const
char *const parameter,
6809 const
char *const file,
6811 const intmax_t minimum,
6812 const intmax_t maximum,
6813 const
size_t count);
6814void _expect_uint_not_in_range(const
char *const function,
6815 const
char *const parameter,
6816 const
char *const file,
6818 const uintmax_t minimum,
6819 const uintmax_t maximum,
6820 const
size_t count);
6821void _expect_float_in_range(
6822 const
char* const function, const
char* const parameter,
6823 const
char* const file, const
int line,
6824 const
double minimum, const
double maximum, const
double epsilon,
6826void _expect_float_not_in_range(
6827 const
char* const function, const
char* const parameter,
6828 const
char* const file, const
int line,
6829 const
double minimum, const
double maximum, const
double epsilon,
6833 const
char* const function, const
char* const parameter,
6834 const
char* const file, const
int line, const uintmax_t value,
6836void _expect_int_value(const
char *const function,
6837 const
char *const parameter,
6838 const
char *const file,
6840 const intmax_t value,
6841 const
size_t count);
6842void _expect_uint_value(const
char *const function,
6843 const
char *const parameter,
6844 const
char *const file,
6846 const uintmax_t value,
6847 const
size_t count);
6848void _expect_int_not_value(const
char *const function,
6849 const
char *const parameter,
6850 const
char *const file,
6852 const intmax_t value,
6853 const
size_t count);
6854void _expect_uint_not_value(const
char *const function,
6855 const
char *const parameter,
6856 const
char *const file,
6858 const uintmax_t value,
6859 const
size_t count);
6860void _expect_not_value(
6861 const
char* const function, const
char* const parameter,
6862 const
char* const file, const
int line, const uintmax_t value,
6866 const
char* const function, const
char* const parameter,
6867 const
char* const file, const
int line, const
double value,
6868 const
double epsilon, const
int count);
6869void _expect_not_float(
6870 const
char* const function, const
char* const parameter,
6871 const
char* const file, const
int line, const
double value,
6872 const
double epsilon, const
int count);
6874void _expect_double(const
char *const function,
6875 const
char *const parameter,
6876 const
char *const file,
6879 const
double epsilon,
6881void _expect_not_double(const
char *const function,
6882 const
char *const parameter,
6883 const
char *const file,
6886 const
double epsilon,
6890 const
char* const function, const
char* const parameter,
6891 const
char* const file, const
int line, const
char*
string,
6893void _expect_not_string(
6894 const
char* const function, const
char* const parameter,
6895 const
char* const file, const
int line, const
char*
string,
6899 const
char* const function, const
char* const parameter,
6900 const
char* const file, const
int line, const
void* const memory,
6901 const
size_t size, const
int count);
6902void _expect_not_memory(
6903 const
char* const function, const
char* const parameter,
6904 const
char* const file, const
int line, const
void* const memory,
6905 const
size_t size, const
int count);
6908 const
char* const function, const
char* const parameter,
6909 const
char* const file, const
int line, const
int count);
6911void _check_expected(
6912 const
char * const function_name, const
char * const parameter_name,
6915void _will_return(const
char *const function_name,
6916 const
char *const file,
6921void _will_set_parameter(const
char *const function_name,
6923 const
char *const file,
6928void _assert_true(const uintmax_t result,
6929 const
char* const expression,
6930 const
char * const file, const
int line);
6931void _assert_false(const uintmax_t result,
6932 const
char * const expression,
6933 const
char * const file, const
int line);
6934void _assert_return_code(const intmax_t result,
6935 const int32_t error,
6936 const
char * const expression,
6937 const
char * const file,
6939void _assert_float_equal(const
float a, const
float n,
6940 const
float epsilon, const
char* const file,
6942void _assert_float_not_equal(const
float a, const
float n,
6943 const
float epsilon, const
char* const file,
6945void _assert_double_equal(const
double a, const
double n,
6946 const
double epsilon, const
char* const file,
6948void _assert_double_not_equal(const
double a, const
double n,
6949 const
double epsilon, const
char* const file,
6951void _assert_int_equal(const intmax_t a,
6953 const
char * const file,
6955void _assert_int_not_equal(const intmax_t a,
6957 const
char * const file,
6959void _assert_uint_equal(const uintmax_t a,
6961 const
char * const file,
6963void _assert_uint_not_equal(const uintmax_t a,
6965 const
char * const file,
6967CMOCKA_NO_ACCESS_ATTRIBUTE
6968void _assert_ptr_equal_msg(const
void *a,
6970 const
char *const file,
6972 const
char *const msg);
6973CMOCKA_NO_ACCESS_ATTRIBUTE
6974void _assert_ptr_not_equal_msg(const
void *a,
6976 const
char *const file,
6978 const
char *const msg);
6979void _assert_string_equal(const
char * const a, const
char * const b,
6980 const
char * const file, const
int line);
6981void _assert_string_not_equal(const
char * const a, const
char * const b,
6982 const
char *file, const
int line);
6983void _assert_memory_equal(const
void * const a, const
void * const b,
6984 const
size_t size, const
char* const file,
6986void _assert_memory_not_equal(const
void * const a, const
void * const b,
6987 const
size_t size, const
char* const file,
6989void _assert_int_in_range(const intmax_t value,
6990 const intmax_t minimum,
6991 const intmax_t maximum,
6992 const
char* const file,
6994void _assert_int_not_in_range(const intmax_t value,
6995 const intmax_t minimum,
6996 const intmax_t maximum,
6997 const
char *const file,
6999void _assert_uint_in_range(const uintmax_t value,
7000 const uintmax_t minimum,
7001 const uintmax_t maximum,
7002 const
char* const file,
7004void _assert_uint_not_in_range(const uintmax_t value,
7005 const uintmax_t minimum,
7006 const uintmax_t maximum,
7007 const
char* const file,
7009void _assert_float_in_range(const
double value,
7010 const
double minimum,
7011 const
double maximum,
7012 const
double epsilon,
7013 const
char* const file,
7015void _assert_float_not_in_range(const
double value,
7016 const
double minimum,
7017 const
double maximum,
7018 const
double epsilon,
7019 const
char* const file,
7021void _assert_not_in_set(
7022 const uintmax_t value, const uintmax_t values[],
7023 const
size_t number_of_values, const
char* const file, const
int line);
7024void _assert_int_in_set(const intmax_t value,
7025 const intmax_t values[],
7026 const
size_t number_of_values,
7027 const
char *const file,
7029void _assert_int_not_in_set(const intmax_t value,
7030 const intmax_t values[],
7031 const
size_t number_of_values,
7032 const
char *const file,
7034void _assert_uint_in_set(const uintmax_t value,
7035 const uintmax_t values[],
7036 const
size_t number_of_values,
7037 const
char *const file,
7039void _assert_uint_not_in_set(const uintmax_t value,
7040 const uintmax_t values[],
7041 const
size_t number_of_values,
7042 const
char *const file,
7044void _assert_float_in_set(const
double value,
7045 const
double values[],
7046 const
size_t number_of_values,
7047 const
double epsilon,
7048 const
char *const file,
7050void _assert_float_not_in_set(const
double value,
7051 const
double values[],
7052 const
size_t number_of_values,
7053 const
double epsilon,
7054 const
char *const file,
7057void* _test_malloc(const
size_t size, const
char* file, const
int line);
7058void* _test_realloc(
void *ptr, const
size_t size, const
char* file, const
int line);
7059void* _test_calloc(const
size_t number_of_elements, const
size_t size,
7060 const
char* file, const
int line);
7061void _test_free(
void* const ptr, const
char* file, const
int line);
7063CMOCKA_NORETURN
void _fail(const
char * const file, const
int line);
7065CMOCKA_NORETURN
void _skip(const
char * const file, const
int line);
7067CMOCKA_NORETURN
void _stop(
void);
7070int _cmocka_run_group_tests(const
char *group_name,
7072 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_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_int_in_set(intmax_t value, intmax_t values[], size_t count)
Assert that the specified integer value is within a set.
void assert_not_in_set(uintmax_t value, uintmax_t values[], size_t count)
Assert that the specified value is not within a set.
void assert_int_not_in_set(intmax_t value, intmax_t values[], size_t count)
Assert that the specified value is not within a set.
void assert_string_equal(const char *a, const char *b)
Assert that the two given strings are equal.
void assert_null(void *pointer)
Assert that the given pointer is NULL.
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_float_not_in_set(double value, double values[], size_t count, double epsilon)
Assert that the specified float value is not within a set.
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_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_float_in_set(double value, double values[], size_t count, double epsilon)
Assert that the specified float value is within a set.
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_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_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_in_set(uintmax_t value, uintmax_t values[], size_t count)
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_uint_not_in_set(uintmax_t value, uintmax_t values[], size_t count)
Assert that the specified unsigned integer value is not within a set.
void assert_uint_in_set(uintmax_t value, uintmax_t values[], size_t count)
Assert that the specified unsigned integer value is 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:4789
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
void cmocka_print_error(const char *const format,...) CMOCKA_PRINTF_ATTRIBUTE(1
Print error message using the cmocka output format.
cm_message_output
Output format options for test results.
Definition cmocka.h:6583
void cmocka_set_skip_filter(const char *pattern)
Set a pattern to skip tests matching the pattern.
Definition cmocka.c:4849
void cmocka_set_test_filter(const char *pattern)
Set a pattern to only run the test matching the pattern.
Definition cmocka.c:4832
@ CM_OUTPUT_TAP
Definition cmocka.h:6591
@ CM_OUTPUT_STDOUT
Definition cmocka.h:6587
@ CM_OUTPUT_SUBUNIT
Definition cmocka.h:6589
@ CM_OUTPUT_STANDARD
Definition cmocka.h:6585
@ CM_OUTPUT_XML
Definition cmocka.h:6593
void(* UnitTestFunction)(void **state)
Definition cmocka.h:6384
int(* CMFixtureFunction)(void **state)
Definition cmocka.h:6466
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.
UnitTestFunctionType
Definition cmocka.h:6423
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(* CMUnitTestFunction)(void **state)
Definition cmocka.h:6459
void mock_assert(const int result, const char *const expression, const char *const file, const int line)
Function to replace assert(3) in tested code.
Definition cmocka.c:3440
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_set_errno_count(#function, intmax_t value, size_t count)
Store an integer value to always set errno to by mock_errno().
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_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_not_in_range_count(#function, #parameter, uintmax_t minimum, uintmax_t maximum, size_t count)
Add an event to repeatedly check a parameter is outside a numerical range. The check would succeed if...
void expect_float_not_in_range_count(#function, #parameter, double minimum, double maximum, double epsilon, size_t count)
Add an event to repeatedly check a parameter is outside a numerical range. The check would succeed if...
void expect_uint_not_in_range_count(#function, uintmax_t minimum, uintmax_t maximum, size_t count)
Add an event to repeatedly check an unsigned integer parameter is outside a numerical range....
void expect_float_not_in_set_count(#function, #parameter, double value_array[], double epsilon, size_t count)
Add an event to check if the float parameter value is not part of the provided integer array.
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_any_count(#function, #parameter, size_t count)
Add an event to repeatedly check if a parameter (of any value) has been passed.
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_in_set_count(#function, #parameter, uintmax_t value_array[], size_t count)
void expect_not_in_set_count(#function, #parameter, uintmax_t value_array[], size_t count)
void check_expected(#parameter)
void expect_not_string_count(#function, #parameter, const char *string, size_t count)
Add an event to check if the parameter value isn't equal to the provided string.
void expect_in_range_count(#function, #parameter, uintmax_t minimum, uintmax_t maximum, size_t count)
void expect_not_memory_count(#function, #parameter, void *memory, size_t size, size_t count)
Add an event to repeatedly check if the parameter doesn't match an area of memory.
void expect_int_in_set_count(#function, #parameter, intmax_t value_array[], size_t count)
Add an event to check if the parameter value is part of the provided integer array.
void expect_check_data(function, parameter, CheckParameterValueData check_function, CMockaValueData check_data)
Add a custom parameter checking function using CMockaValueData (new API).
void expect_in_range(#function, #parameter, uintmax_t minimum, uintmax_t maximum)
void expect_float_in_set_count(#function, #parameter, double value_array[], double epsilon, size_t count)
Add an event to check if the float parameter value is part of the provided integer array.
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_uint_in_range_count(#function, uintmax_t minimum, uintmax_t maximum, size_t count)
Add an event to repeatedly check an unsigned integer parameter is inside a numerical range....
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_int_not_value_count(#function, intmax_t value, size_t count)
Add an event to repeatedly check if a parameter (int) isn't the given 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_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.
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_memory_count(#function, #parameter, void *memory, size_t size, size_t count)
Add an event to repeatedly check if the parameter does 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_float_in_range_count(#function, #parameter, double minimum, double maximum, double epsilon, size_t count)
Add an event to repeatedly check a parameter is inside a numerical range. The check would succeed if ...
void expect_int_value_count(#function, intmax_t value, size_t count)
Add an event to repeatedly check if an integer parameter is the given value.
int(* CheckParameterValue)(const uintmax_t value, const uintmax_t check_value_data)
Definition cmocka.h:6391
void expect_uint_value(#function, #parameter, uintmax_t value)
Add an event to check if an unsigned integer parameter is the given value.
void expect_uint_value_count(#function, uintmax_t value, size_t count)
Add an event to repeatedly check if an unsigned integer parameter is the given value.
void check_expected_int(#parameter)
Determine whether a function parameter is correct.
void expect_int_not_in_range_count(#function, intmax_t minimum, intmax_t maximum, size_t count)
Add an event to repeatedly check an integer parameter is outside a numerical range....
void check_expected_double(#parameter)
Determine whether a function parameter is correct.
int(* CheckIntParameterValue)(const intmax_t value, const intmax_t check_value_data)
Definition cmocka.h:6407
int(* CheckParameterValueData)(const CMockaValueData value, const CMockaValueData check_value_data)
Definition cmocka.h:6399
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_uint_not_value_count(#function, uintmax_t value, size_t count)
Add an event to repeatedly check if a parameter (uint) isn't the given value.
void expect_uint_not_in_set_count(#function, uintmax_t value_array[], size_t count)
Add an event to check if the unsigned integer parameter value is not part of the provided unsigned in...
void expect_check_data_count(function, parameter, CheckParameterValueData check_function, CMockaValueData check_data, size_t count)
Add a custom parameter checking function using CMockaValueData with count (new API).
void expect_any(#function, #parameter)
Add an event to check if a parameter (of any value) has been passed.
void expect_check_count(function, parameter, CheckParameterValue check_function, const void *check_data, size_t count)
void expect_int_in_range_count(#function, intmax_t minimum, intmax_t maximum, size_t count)
Add an event to repeatedly check an integer parameter is inside a numerical range....
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_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_float_count(#function, #parameter, double value, double epsilon, size_t count)
Add an event to repeatedly check if a parameter is the given floating point value.
int(* CheckUintParameterValue)(const uintmax_t value, const uintmax_t check_value_data)
Definition cmocka.h:6415
void check_expected_any(#parameter)
Check that any parameter value matches the next value in the queue.
void expect_value(#function, #parameter, uintmax_t value)
void expect_double_count(#function, double value, double epsilon, size_t count)
Add an event to repeatedly check if a parameter is the given double precision floating point value.
void expect_uint_in_set_count(#function, #parameter, uintmax_t value_array[], size_t count)
Add an event to check if the parameter value is part of the provided unsigned integer array.
void expect_check(function, parameter, CheckParameterValue check_function, const void *check_data)
void expect_string_count(#function, #parameter, const char *string, size_t count)
Add an event to check if the parameter value is equal to the provided string.
void expect_not_double_count(#function, double value, double epsilon, size_t count)
Add an event to repeatedly check if a parameter isn't the double precision floating point value.
void expect_not_float_count(#function, #parameter, double value, double epsilon, size_t count)
Add an event to repeatedly check if a parameter isn't the floating point value.
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_value_count(#function, #parameter, uintmax_t value, size_t count)
void expect_not_value_count(#function, #parameter, uintmax_t value, size_t count)
void expect_in_set(#function, #parameter, uintmax_t value_array[])
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_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 expect_int_not_in_set_count(#function, intmax_t value_array[], size_t count)
Add an event to check if the integer parameter value is not part of the provided integer array.
void(* vprint_message)(const char *const format, va_list args)
Definition cmocka.h:6547
void(* vprint_error)(const char *const format, va_list args)
Definition cmocka.h:6556
double real_val
Definition cmocka.h:6346
float float_val
Definition cmocka.h:6344
intmax_t int_val
Definition cmocka.h:6340
uintmax_t uint_val
Definition cmocka.h:6342
const void * ptr
Definition cmocka.h:6348