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#ifdef 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
253#ifdef __has_attribute
254#if __has_attribute(access)
255#define CMOCKA_NO_ACCESS_ATTRIBUTE \
256 __attribute__((access(none, 1), access(none, 2)))
259#ifndef CMOCKA_NO_ACCESS_ATTRIBUTE
260#define CMOCKA_NO_ACCESS_ATTRIBUTE
330#define WILL_RETURN_ALWAYS -1
343#define WILL_RETURN_ONCE -2
354#define EXPECT_ALWAYS -1
365#define EXPECT_MAYBE -2
377#define mock() (_mock(__func__, __FILE__, __LINE__, NULL)).uint_val
404#define mock_type(type) ((type) mock())
435#define has_mock() _has_mock(__func__)
455#define mock_int() (_mock(__func__, __FILE__, __LINE__, NULL)).int_val
475#define mock_uint() (_mock(__func__, __FILE__, __LINE__, "uintmax_t")).uint_val
489#define mock_float() (_mock(__func__, __FILE__, __LINE__, NULL)).float_val
503#define mock_double() (_mock(__func__, __FILE__, __LINE__, NULL)).real_val
529#define mock_ptr_type(type) \
530 ((type)(_mock(__func__, __FILE__, __LINE__, NULL)).ptr)
557#define mock_ptr_type_checked(type) \
558 ((type)(_mock(__func__, __FILE__, __LINE__, #type)).ptr)
597#define mock_parameter(name) \
598 (_mock_parameter(__func__, #name, __FILE__, __LINE__, NULL)).uint_val
624#type mock_parameter_type(#name, #type);
626#define mock_parameter_type(name, type) ((type) mock_parameter(#name))
649#define mock_parameter_int(name) \
650 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "intmax_t")).int_val
673#define mock_parameter_uint(name) \
674 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "uintmax_t")).uint_val
697#define mock_parameter_float(name) \
698 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "float")).float_val
721#define mock_parameter_double(name) \
722 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "double")).real_val
744#define mock_parameter_ptr(name) \
745 ((_mock_parameter(__func__, #name, __FILE__, __LINE__, NULL)).ptr)
771#define mock_parameter_ptr_type(name, type) \
772 ((type)(_mock_parameter(__func__, #name, __FILE__, __LINE__, #type)).ptr)
785#define mock_errno() \
787 intmax_t err = (_mock_parameter( \
835#define will_return(function, value) \
836 _will_return(cmocka_tostring(function), \
840 cast_int_to_cmocka_value(value), \
870#define will_return_int(function, value) \
871 _will_return(#function, \
875 assign_int_to_cmocka_value(value), \
915#define will_return_int_count(function, value, count) \
916 _will_return(#function, \
920 assign_int_to_cmocka_value(value), \
951#define will_return_uint(function, value) \
952 _will_return(#function, \
956 assign_uint_to_cmocka_value(value), \
996#define will_return_uint_count(function, value, count) \
997 _will_return(#function, \
1001 assign_uint_to_cmocka_value(value), \
1032#define will_return_float(function, value) \
1033 _will_return(#function, \
1037 assign_float_to_cmocka_value(value), \
1077#define will_return_float_count(function, value, count) \
1078 _will_return(#function, \
1082 assign_float_to_cmocka_value(value), \
1113#define will_return_double(function, value) \
1114 _will_return(#function, \
1118 assign_double_to_cmocka_value(value), \
1158#define will_return_double_count(function, value, count) \
1159 _will_return(#function, \
1163 assign_double_to_cmocka_value(value), \
1185#define will_return_int_always(function, value) \
1186 will_return_int_count(function, (value), WILL_RETURN_ALWAYS)
1208#define will_return_uint_always(function, value) \
1209 will_return_uint_count(function, (value), WILL_RETURN_ALWAYS)
1230#define will_return_float_always(function, value) \
1231 will_return_float_count(function, (value), WILL_RETURN_ALWAYS)
1252#define will_return_double_always(function, value) \
1253 will_return_double_count(function, (value), WILL_RETURN_ALWAYS)
1262#define will_return_count(function, value, count) \
1264 CMOCKA_DEPRECATION_WARNING( \
1265 "will_return_count: use will_return_int_count or " \
1266 "will_return_uint_count instead") \
1267 _will_return(cmocka_tostring(function), \
1271 cast_int_to_cmocka_value(value), \
1282#define will_return_always(function, value) \
1284 CMOCKA_DEPRECATION_WARNING( \
1285 "will_return_always: use will_return_int_always or " \
1286 "will_return_uint_always instead") \
1287 will_return_count(function, (value), WILL_RETURN_ALWAYS); \
1315#define will_return_int_maybe(function, value) \
1316 will_return_int_count(function, (value), WILL_RETURN_ONCE)
1344#define will_return_uint_maybe(function, value) \
1345 will_return_uint_count(function, (value), WILL_RETURN_ONCE)
1372#define will_return_float_maybe(function, value) \
1373 will_return_float_count(function, (value), WILL_RETURN_ONCE)
1400#define will_return_double_maybe(function, value) \
1401 will_return_double_count(function, (value), WILL_RETURN_ONCE)
1410#define will_return_maybe(function, value) \
1412 CMOCKA_DEPRECATION_WARNING( \
1413 "will_return_maybe: use will_return_int_maybe or " \
1414 "will_return_uint_maybe instead") \
1415 will_return_count(function, (value), WILL_RETURN_ONCE); \
1446#define will_return_ptr(function, value) \
1447 _will_return(#function, \
1451 cast_ptr_to_cmocka_value(value), \
1486#define will_return_ptr_type(function, value, type) \
1487 _will_return(#function, \
1491 cast_ptr_to_cmocka_value(value), \
1513#define will_return_ptr_count(function, value, count) \
1514 _will_return(#function, \
1518 cast_ptr_to_cmocka_value(value), \
1540#define will_return_ptr_always(function, value) \
1541 will_return_ptr_count(function, (value), WILL_RETURN_ALWAYS)
1568#define will_return_ptr_maybe(function, value) \
1569 will_return_ptr_count(function, (value), WILL_RETURN_ONCE)
1619#define will_set_parameter(function, name, value) \
1620 _will_set_parameter(cmocka_tostring(function), \
1625 cast_int_to_cmocka_value(value), \
1663#define will_set_parameter_int(function, name, value) \
1664 _will_set_parameter(#function, \
1669 assign_int_to_cmocka_value(value), \
1709#define will_set_parameter_uint(function, name, value) \
1710 _will_set_parameter(#function, \
1715 assign_uint_to_cmocka_value(value), \
1754#define will_set_parameter_float(function, name, value) \
1755 _will_set_parameter(#function, \
1760 assign_float_to_cmocka_value(value), \
1800#define will_set_parameter_double(function, name, value) \
1801 _will_set_parameter(#function, \
1806 assign_double_to_cmocka_value(value), \
1832#define will_set_parameter_int_count(function, name, value, count) \
1833 _will_set_parameter(#function, \
1838 assign_int_to_cmocka_value(value), \
1867#define will_set_parameter_uint_count(function, name, value, count) \
1868 _will_set_parameter(#function, \
1873 assign_uint_to_cmocka_value(value), \
1899#define will_set_parameter_float_count(function, name, value, count) \
1900 _will_set_parameter(#function, \
1905 assign_float_to_cmocka_value(value), \
1931#define will_set_parameter_double_count(function, name, value, count) \
1932 _will_set_parameter(#function, \
1937 assign_double_to_cmocka_value(value), \
1948#define will_set_parameter_count(function, name, value, count) \
1950 CMOCKA_DEPRECATION_WARNING( \
1951 "will_set_parameter_count: use will_set_parameter_int_count or " \
1952 "will_set_parameter_uint_count instead") \
1953 _will_set_parameter(cmocka_tostring(function), \
1958 cast_int_to_cmocka_value(value), \
1985#define will_set_parameter_int_always(function, name, value) \
1986 will_set_parameter_int_count(function, name, (value), WILL_RETURN_ALWAYS)
2011#define will_set_parameter_uint_always(function, name, value) \
2012 will_set_parameter_uint_count(function, name, (value), WILL_RETURN_ALWAYS)
2037#define will_set_parameter_float_always(function, name, value) \
2038 will_set_parameter_float_count(function, name, (value), WILL_RETURN_ALWAYS)
2063#define will_set_parameter_double_always(function, name, value) \
2064 will_set_parameter_double_count(function, name, (value), WILL_RETURN_ALWAYS)
2074#define will_set_parameter_always(function, name, value) \
2076 CMOCKA_DEPRECATION_WARNING( \
2077 "will_set_parameter_always: use will_set_parameter_int_always or " \
2078 "will_set_parameter_uint_always instead") \
2079 will_set_parameter_count(function, name, (value), WILL_RETURN_ALWAYS); \
2106#define will_set_parameter_int_maybe(function, name, value) \
2107 will_set_parameter_int_count(function, name, (value), WILL_RETURN_ONCE)
2133#define will_set_parameter_uint_maybe(function, name, value) \
2134 will_set_parameter_uint_count(function, name, (value), WILL_RETURN_ONCE)
2160#define will_set_parameter_float_maybe(function, name, value) \
2161 will_set_parameter_float_count(function, name, (value), WILL_RETURN_ONCE)
2187#define will_set_parameter_double_maybe(function, name, value) \
2188 will_set_parameter_double_count(function, name, (value), WILL_RETURN_ONCE)
2198#define will_set_parameter_maybe(function, name, value) \
2200 CMOCKA_DEPRECATION_WARNING( \
2201 "will_set_parameter_maybe: use will_set_parameter_int_maybe or " \
2202 "will_set_parameter_uint_maybe instead") \
2203 will_set_parameter_count(function, name, (value), WILL_RETURN_ONCE); \
2238#define will_set_parameter_ptr(function, name, value) \
2239 _will_set_parameter(#function, \
2244 cast_ptr_to_cmocka_value(value), \
2284#define will_set_parameter_ptr_type(function, name, value, type) \
2285 _will_set_parameter(#function, \
2290 cast_ptr_to_cmocka_value(value), \
2335#define will_set_parameter_ptr_count(function, name, value, count) \
2336 _will_set_parameter(#function, \
2341 cast_ptr_to_cmocka_value(value), \
2374#define will_set_parameter_ptr_always(function, name, value) \
2375 will_set_parameter_ptr_count(function, name, (value), WILL_RETURN_ALWAYS)
2409#define will_set_parameter_ptr_maybe(function, name, value) \
2410 will_set_parameter_ptr_count(function, name, (value), WILL_RETURN_ONCE)
2440#define will_set_errno(function, value) \
2441 _will_set_parameter(#function, \
2446 assign_int_to_cmocka_value(value), \
2491#define will_set_errno_count(function, value, count) \
2492 _will_set_parameter(#function, \
2497 assign_int_to_cmocka_value(value), \
2526#define will_set_errno_always(function, value) \
2527 will_set_errno_count(function, (value), WILL_RETURN_ALWAYS);
2555#define will_set_errno_maybe(function, value) \
2556 will_set_errno_count(function, (value), WILL_RETURN_ONCE);
2614 const void *check_data);
2616#define expect_check(function, parameter, check_function, check_data) \
2618 CMOCKA_DEPRECATION_WARNING( \
2619 "expect_check: use expect_check_data instead") \
2620 _expect_check(cmocka_tostring(function), \
2621 cmocka_tostring(parameter), \
2625 cast_to_uintmax_type(check_data), \
2639 const void *check_data,
2642#define expect_check_count( \
2643 function, parameter, check_function, check_data, count) \
2645 CMOCKA_DEPRECATION_WARNING( \
2646 "expect_check_count: use expect_check_data_count instead") \
2647 _expect_check(cmocka_tostring(function), \
2648 cmocka_tostring(parameter), \
2652 cast_to_uintmax_type(check_data), \
2819#define expect_check_data(function, parameter, check_function, check_data) \
2820 _expect_check_data(cmocka_tostring(function), \
2821 cmocka_tostring(parameter), \
2901#define expect_check_data_count(function, \
2906 _expect_check_data(cmocka_tostring(function), \
2907 cmocka_tostring(parameter), \
2922#define expect_in_set(function, parameter, value_array) \
2924 CMOCKA_DEPRECATION_WARNING("expect_in_set: use expect_int_in_set or " \
2925 "expect_uint_in_set instead") \
2926 expect_in_set_count(function, parameter, value_array, 1); \
2947#define expect_int_in_set(function, parameter, value_array) \
2948 expect_int_in_set_count(function, parameter, value_array, 1)
2966void expect_in_set(#function, #parameter, intmax_t value_array[]);
2968#define expect_uint_in_set(function, parameter, value_array) \
2969 expect_uint_in_set_count(function, parameter, value_array, 1)
2978#define expect_in_set_count(function, parameter, value_array, count) \
2980 CMOCKA_DEPRECATION_WARNING( \
2981 "expect_in_set_count: use expect_int_in_set_count or " \
2982 "expect_uint_in_set_count instead") \
2983 _expect_uint_in_set(cmocka_tostring(function), \
2984 cmocka_tostring(parameter), \
2988 sizeof(value_array) / sizeof((value_array)[0]), \
3014#define expect_int_in_set_count(function, parameter, value_array, count) \
3015 _expect_int_in_set(cmocka_tostring(function), \
3016 cmocka_tostring(parameter), \
3020 sizeof(value_array) / sizeof((value_array)[0]), \
3045#define expect_uint_in_set_count(function, parameter, value_array, count) \
3046 _expect_uint_in_set(cmocka_tostring(function), \
3047 cmocka_tostring(parameter), \
3051 sizeof(value_array) / sizeof((value_array)[0]), \
3061#define expect_not_in_set(function, parameter, value_array) \
3063 CMOCKA_DEPRECATION_WARNING( \
3064 "expect_not_in_set: use expect_int_not_in_set or " \
3065 "expect_uint_not_in_set instead") \
3066 expect_not_in_set_count(function, parameter, value_array, 1); \
3076#define expect_not_in_set_count(function, parameter, value_array, count) \
3078 CMOCKA_DEPRECATION_WARNING( \
3079 "expect_not_in_set_count: use expect_int_not_in_set_count or " \
3080 "expect_uint_not_in_set_count instead") \
3081 _expect_not_in_set(cmocka_tostring(function), \
3082 cmocka_tostring(parameter), \
3086 sizeof(value_array) / sizeof((value_array)[0]), \
3108#define expect_int_not_in_set(function, parameter, value_array) \
3109 expect_int_not_in_set_count(function, parameter, value_array, 1)
3133 intmax_t value_array[],
3136#define expect_int_not_in_set_count(function, parameter, value_array, count) \
3137 _expect_int_not_in_set(cmocka_tostring(function), \
3138 cmocka_tostring(parameter), \
3142 sizeof(value_array) / sizeof((value_array)[0]), \
3163#define expect_uint_not_in_set(function, parameter, value_array) \
3164 expect_uint_not_in_set_count(function, parameter, value_array, 1)
3188 uintmax_t value_array[],
3191#define expect_uint_not_in_set_count(function, parameter, value_array, count) \
3192 _expect_uint_not_in_set(cmocka_tostring(function), \
3193 cmocka_tostring(parameter), \
3197 sizeof(value_array) / sizeof((value_array)[0]), \
3220#define expect_float_in_set(function, parameter, value_array, epsilon) \
3221 expect_float_in_set_count(function, parameter, value_array, epsilon, 1)
3247#define expect_float_in_set_count(function, parameter, value_array, epsilon, count) \
3248 _expect_float_in_set(cmocka_tostring(function), \
3249 cmocka_tostring(parameter), \
3253 sizeof(value_array) / sizeof((value_array)[0]), \
3277#define expect_float_not_in_set(function, parameter, value_array, epsilon) \
3278 expect_float_not_in_set_count(function, parameter, value_array, epsilon, 1)
3304#define expect_float_not_in_set_count(function, parameter, value_array, epsilon, count) \
3305 _expect_float_not_in_set(cmocka_tostring(function), \
3306 cmocka_tostring(parameter), \
3310 sizeof(value_array) / sizeof((value_array)[0]), \
3322#define expect_in_range(function, parameter, minimum, maximum) \
3324 CMOCKA_DEPRECATION_WARNING( \
3325 "expect_in_range: use expect_int_in_range or " \
3326 "expect_uint_in_range instead") \
3327 expect_in_range_count(function, parameter, minimum, maximum, 1); \
3337#define expect_in_range_count(function, parameter, minimum, maximum, count) \
3339 CMOCKA_DEPRECATION_WARNING( \
3340 "expect_in_range_count: use expect_int_in_range_count or " \
3341 "expect_uint_in_range_count instead") \
3342 _expect_in_range(cmocka_tostring(function), \
3343 cmocka_tostring(parameter), \
3374#define expect_int_in_range(function, parameter, minimum, maximum) \
3375 expect_int_in_range_count(function, parameter, minimum, maximum, 1)
3405#define expect_int_in_range_count( \
3406 function, parameter, minimum, maximum, count) \
3407 _expect_int_in_range(cmocka_tostring(function), \
3408 cmocka_tostring(parameter), \
3438#define expect_uint_in_range(function, parameter, minimum, maximum) \
3439 expect_uint_in_range_count(function, parameter, minimum, maximum, 1)
3470#define expect_uint_in_range_count( \
3471 function, parameter, minimum, maximum, count) \
3472 _expect_uint_in_range(cmocka_tostring(function), \
3473 cmocka_tostring(parameter), \
3500#define expect_not_in_range(function, parameter, minimum, maximum) \
3501 expect_not_in_range_count(function, parameter, minimum, maximum, 1)
3527#define expect_not_in_range_count(function, parameter, minimum, maximum, \
3529 _expect_not_in_range(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
3530 minimum, maximum, count)
3555#define expect_int_not_in_range(function, parameter, minimum, maximum) \
3556 expect_int_not_in_range_count(function, parameter, minimum, maximum, 1)
3586#define expect_int_not_in_range_count( \
3587 function, parameter, minimum, maximum, count) \
3588 _expect_int_not_in_range(cmocka_tostring(function), \
3589 cmocka_tostring(parameter), \
3619#define expect_uint_not_in_range(function, parameter, minimum, maximum) \
3620 expect_uint_not_in_range_count(function, parameter, minimum, maximum, 1)
3651#define expect_uint_not_in_range_count( \
3652 function, parameter, minimum, maximum, count) \
3653 _expect_uint_not_in_range(cmocka_tostring(function), \
3654 cmocka_tostring(parameter), \
3683#define expect_float_in_range(function, parameter, minimum, maximum, epsilon) \
3684 expect_float_in_range_count(function, parameter, minimum, maximum, epsilon, 1)
3712#define expect_float_in_range_count(function, parameter, minimum, maximum, epsilon, count) \
3713 _expect_float_in_range(cmocka_tostring(function), \
3714 cmocka_tostring(parameter), \
3717 cast_to_double_type(minimum), \
3718 cast_to_double_type(maximum), \
3719 cast_to_double_type(epsilon), \
3744#define expect_float_not_in_range(function, parameter, minimum, maximum, epsilon) \
3745 expect_float_not_in_range_count(function, parameter, minimum, maximum, epsilon, 1)
3773#define expect_float_not_in_range_count(function, parameter, minimum, maximum, \
3775 _expect_float_not_in_range(cmocka_tostring(function), \
3776 cmocka_tostring(parameter), \
3779 cast_to_double_type(minimum), \
3780 cast_to_double_type(maximum), \
3781 cast_to_double_type(epsilon), \
3791#define expect_value(function, parameter, value) \
3793 CMOCKA_DEPRECATION_WARNING("expect_value: use expect_int_value or " \
3794 "expect_uint_value instead") \
3795 expect_value_count(function, parameter, value, 1); \
3805#define expect_value_count(function, parameter, value, count) \
3807 CMOCKA_DEPRECATION_WARNING( \
3808 "expect_value_count: use expect_int_value_count or " \
3809 "expect_uint_value_count instead") \
3810 _expect_value(cmocka_tostring(function), \
3811 cmocka_tostring(parameter), \
3814 cast_to_uintmax_type(value), \
3835#define expect_int_value(function, parameter, value) \
3836 expect_int_value_count(function, parameter, value, 1)
3863#define expect_int_value_count(function, parameter, value, count) \
3864 _expect_int_value(cmocka_tostring(function), \
3865 cmocka_tostring(parameter), \
3889#define expect_uint_value(function, parameter, value) \
3890 expect_uint_value_count(function, parameter, value, 1)
3917#define expect_uint_value_count(function, parameter, value, count) \
3918 _expect_uint_value(cmocka_tostring(function), \
3919 cmocka_tostring(parameter), \
3942#define expect_int_not_value(function, parameter, value) \
3943 expect_int_not_value_count(function, parameter, value, 1)
3970#define expect_int_not_value_count(function, parameter, value, count) \
3971 _expect_int_not_value(cmocka_tostring(function), \
3972 cmocka_tostring(parameter), \
3995#define expect_uint_not_value(function, parameter, value) \
3996 expect_uint_not_value_count(function, parameter, value, 1)
4023#define expect_uint_not_value_count(function, parameter, value, count) \
4024 _expect_uint_not_value(cmocka_tostring(function), \
4025 cmocka_tostring(parameter), \
4038#define expect_not_value(function, parameter, value) \
4040 CMOCKA_DEPRECATION_WARNING( \
4041 "expect_not_value: use expect_int_not_value or " \
4042 "expect_uint_not_value instead") \
4043 expect_not_value_count(function, parameter, value, 1); \
4053#define expect_not_value_count(function, parameter, value, count) \
4055 CMOCKA_DEPRECATION_WARNING( \
4056 "expect_not_value_count: use expect_int_not_value_count or " \
4057 "expect_uint_not_value_count instead") \
4058 _expect_not_value(cmocka_tostring(function), \
4059 cmocka_tostring(parameter), \
4062 cast_to_uintmax_type(value), \
4088#define expect_float(function, parameter, value, epsilon) \
4089 expect_float_count(function, parameter, cast_to_double_type(value), \
4090 cast_to_double_type(epsilon), 1)
4118#define expect_float_count(function, parameter, value, epsilon, count) \
4119 _expect_float(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4120 cast_to_double_type(value), cast_to_double_type(epsilon), count)
4145#define expect_not_float(function, parameter, value, epsilon) \
4146 expect_not_float_count(function, \
4148 cast_to_float_type(value), \
4149 cast_to_float_type(epsilon), \
4178#define expect_not_float_count(function, parameter, value, epsilon, count) \
4179 _expect_not_float(cmocka_tostring(function), \
4180 cmocka_tostring(parameter), \
4183 cast_to_float_type(value), \
4184 cast_to_float_type(epsilon), \
4208#define expect_double(function, parameter, value, epsilon) \
4209 expect_double_count(function, \
4211 cast_to_double_type(value), \
4212 cast_to_double_type(epsilon), \
4244#define expect_double_count(function, parameter, value, epsilon, count) \
4245 _expect_double(cmocka_tostring(function), \
4246 cmocka_tostring(parameter), \
4249 cast_to_double_type(value), \
4250 cast_to_double_type(epsilon), \
4274#define expect_not_double(function, parameter, value, epsilon) \
4275 expect_not_double_count(function, \
4277 cast_to_double_type(value), \
4278 cast_to_double_type(epsilon), \
4310#define expect_not_double_count(function, parameter, value, epsilon, count) \
4311 _expect_not_double(cmocka_tostring(function), \
4312 cmocka_tostring(parameter), \
4315 cast_to_double_type(value), \
4316 cast_to_double_type(epsilon), \
4337#define expect_string(function, parameter, string) \
4338 expect_string_count(function, parameter, string, 1)
4362#define expect_string_count(function, parameter, string, count) \
4363 _expect_string(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4364 (const char*)(string), count)
4384#define expect_not_string(function, parameter, string) \
4385 expect_not_string_count(function, parameter, string, 1)
4409#define expect_not_string_count(function, parameter, string, count) \
4410 _expect_not_string(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4411 (const char*)(string), count)
4432#define expect_memory(function, parameter, memory, size) \
4433 expect_memory_count(function, parameter, memory, size, 1)
4459#define expect_memory_count(function, parameter, memory, size, count) \
4460 _expect_memory(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4461 (const void*)(memory), size, count)
4483#define expect_not_memory(function, parameter, memory, size) \
4484 expect_not_memory_count(function, parameter, memory, size, 1)
4510#define expect_not_memory_count(function, parameter, memory, size, count) \
4511 _expect_not_memory(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4512 (const void*)(memory), size, count)
4530#define expect_any(function, parameter) \
4531 expect_any_count(function, parameter, 1)
4548#define expect_any_always(function, parameter) \
4549 expect_any_count(function, parameter, WILL_RETURN_ALWAYS)
4571#define expect_any_count(function, parameter, count) \
4572 _expect_any(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, count)
4582#define check_expected(parameter) \
4584 CMOCKA_DEPRECATION_WARNING( \
4585 "check_expected: use check_expected_int or " \
4586 "check_expected_uint instead") \
4587 _check_expected(__func__, \
4591 cast_int_to_cmocka_value(parameter)); \
4625#define check_expected_any(parameter) \
4626 _check_expected(__func__, #parameter, __FILE__, __LINE__, \
4627 cast_ptr_to_cmocka_value(&(parameter)))
4643#define check_expected_ptr(parameter) \
4644 _check_expected(__func__, #parameter, __FILE__, __LINE__, \
4645 cast_ptr_to_cmocka_value(parameter))
4661#define check_expected_int(parameter) \
4662 _check_expected(__func__, \
4666 assign_int_to_cmocka_value(parameter))
4682#define check_expected_uint(parameter) \
4683 _check_expected(__func__, \
4687 assign_uint_to_cmocka_value(parameter))
4708#define check_expected_float(parameter) \
4709 _check_expected(__func__, \
4713 assign_float_to_cmocka_value(parameter))
4734#define check_expected_double(parameter) \
4735 _check_expected(__func__, \
4739 assign_double_to_cmocka_value(parameter))
4782#define assert_true(c) _assert_true(cast_to_uintmax_type(c), #c, \
4800#define assert_false(c) _assert_false(cast_to_uintmax_type(c), #c, \
4819#define assert_return_code(rc, error) \
4820 _assert_return_code((rc), \
4822 #rc, __FILE__, __LINE__)
4838#define assert_non_null(c) assert_ptr_not_equal((c), NULL)
4856#define assert_non_null_msg(c, msg) assert_ptr_not_equal_msg((c), NULL, (msg))
4872#define assert_null(c) assert_ptr_equal((c), NULL)
4890#define assert_null_msg(c, msg) assert_ptr_equal_msg((c), NULL, (msg))
4906#define assert_ptr_equal(a, b) assert_ptr_equal_msg((a), (b), NULL)
4924#define assert_ptr_equal_msg(a, b, msg) \
4925 _assert_ptr_equal_msg(cast_to_void_pointer(a), \
4926 cast_to_void_pointer(b), \
4927 __FILE__, __LINE__, (msg))
4943#define assert_ptr_not_equal(a, b) \
4944 assert_ptr_not_equal_msg((a), (b), NULL)
4963#if defined(__has_builtin)
4965#if __has_builtin(__builtin_unreachable)
4966#define assert_ptr_not_equal_msg(a, b, msg) \
4968 const void *cmocka_p1 = cast_to_void_pointer(a), \
4969 *cmocka_p2 = cast_to_void_pointer(b); \
4970 _assert_ptr_not_equal_msg( \
4971 cmocka_p1, cmocka_p2, __FILE__, __LINE__, (msg)); \
4972 if (cmocka_p1 == cmocka_p2) { \
4973 __builtin_unreachable(); \
4977#define assert_ptr_not_equal_msg(a, b, msg) \
4978_assert_ptr_not_equal_msg(cast_to_void_pointer(a), \
4979 cast_to_void_pointer(b), \
4986#define assert_ptr_not_equal_msg(a, b, msg) \
4987_assert_ptr_not_equal_msg(cast_to_void_pointer(a), \
4988 cast_to_void_pointer(b), \
5009#define assert_int_equal(a, b) \
5010 _assert_int_equal(cast_to_intmax_type(a), \
5011 cast_to_intmax_type(b), \
5028#define assert_uint_equal(a, b) \
5029 _assert_uint_equal(cast_to_uintmax_type(a), \
5030 cast_to_uintmax_type(b), \
5049#define assert_int_not_equal(a, b) \
5050 _assert_int_not_equal(cast_to_intmax_type(a), \
5051 cast_to_intmax_type(b), \
5068#define assert_uint_not_equal(a, b) \
5069 _assert_uint_not_equal(cast_to_uintmax_type(a), \
5070 cast_to_uintmax_type(b), \
5089#define assert_float_equal(a, b, epsilon) \
5090 _assert_float_equal((float)a, \
5111#define assert_float_not_equal(a, b, epsilon) \
5112 _assert_float_not_equal((float)a, \
5133#define assert_double_equal(a, b, epsilon) \
5134 _assert_double_equal((double)a, \
5155#define assert_double_not_equal(a, b, epsilon) \
5156 _assert_double_not_equal((double)a, \
5176#define assert_string_equal(a, b) \
5177 _assert_string_equal((a), (b), __FILE__, __LINE__)
5193#define assert_string_not_equal(a, b) \
5194 _assert_string_not_equal((a), (b), __FILE__, __LINE__)
5214#define assert_memory_equal(a, b, size) \
5215 _assert_memory_equal((const void*)(a), (const void*)(b), size, __FILE__, \
5236#define assert_memory_not_equal(a, b, size) \
5237 _assert_memory_not_equal((const void*)(a), (const void*)(b), size, \
5257#define assert_int_in_range(value, minimum, maximum) \
5258 _assert_int_in_range( \
5259 cast_to_intmax_type(value), \
5260 cast_to_intmax_type(minimum), \
5261 cast_to_intmax_type(maximum), __FILE__, __LINE__)
5280#define assert_uint_in_range(value, minimum, maximum) \
5281 _assert_uint_in_range( \
5282 cast_to_intmax_type(value), \
5283 cast_to_intmax_type(minimum), \
5284 cast_to_intmax_type(maximum), __FILE__, __LINE__)
5308#define assert_int_not_in_range(value, minimum, maximum) \
5309 _assert_int_not_in_range(cast_to_intmax_type(value), \
5310 cast_to_intmax_type(minimum), \
5311 cast_to_intmax_type(maximum), \
5337#define assert_uint_not_in_range(value, minimum, maximum) \
5338 _assert_uint_not_in_range(cast_to_uintmax_type(value), \
5339 cast_to_uintmax_type(minimum), \
5340 cast_to_uintmax_type(maximum), \
5351#define assert_in_range(value, minimum, maximum) \
5353 CMOCKA_DEPRECATION_WARNING( \
5354 "assert_in_range: use assert_int_in_range or " \
5355 "assert_uint_in_range instead") \
5356 _assert_uint_in_range(cast_to_uintmax_type(value), \
5357 cast_to_uintmax_type(minimum), \
5358 cast_to_uintmax_type(maximum), \
5370#define assert_not_in_range(value, minimum, maximum) \
5372 CMOCKA_DEPRECATION_WARNING( \
5373 "assert_not_in_range: use assert_int_not_in_range or " \
5374 "assert_uint_not_in_range instead") \
5375 _assert_uint_not_in_range(cast_to_uintmax_type(value), \
5376 cast_to_uintmax_type(minimum), \
5377 cast_to_uintmax_type(maximum), \
5404#define assert_float_not_in_range(value, minimum, maximum, epsilon) \
5405 _assert_float_not_in_range(cast_to_double_type(value), \
5406 cast_to_double_type(minimum), \
5407 cast_to_double_type(maximum), \
5408 cast_to_double_type(epsilon), \
5431#define assert_float_in_range(value, minimum, maximum, epsilon) \
5432 _assert_float_in_range( \
5433 cast_to_double_type(value), \
5434 cast_to_double_type(minimum), \
5435 cast_to_double_type(maximum), \
5436 cast_to_double_type(epsilon), __FILE__, __LINE__)
5445#define assert_in_set(value, values, number_of_values) \
5447 CMOCKA_DEPRECATION_WARNING("assert_in_set: use assert_int_in_set or " \
5448 "assert_uint_in_set instead") \
5449 _assert_uint_in_set( \
5450 value, values, number_of_values, __FILE__, __LINE__); \
5469#define assert_not_in_set(value, values, number_of_values) \
5470 _assert_not_in_set(value, values, number_of_values, __FILE__, __LINE__)
5488#define assert_int_in_set(value, values, number_of_values) \
5489 if (number_of_values > 0) { \
5490 intmax_t _cmocka_set[number_of_values]; \
5491 for (size_t _i = 0; _i < number_of_values; _i++) { \
5492 _cmocka_set[_i] = values[_i]; \
5494 _assert_int_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5513#define assert_int_not_in_set(value, values, number_of_values) \
5514 if (number_of_values > 0) { \
5515 intmax_t _cmocka_set[number_of_values]; \
5516 for (size_t _i = 0; _i < number_of_values; _i++) { \
5517 _cmocka_set[_i] = values[_i]; \
5519 _assert_int_not_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5538#define assert_uint_in_set(value, values, number_of_values) \
5539 if (number_of_values > 0) { \
5540 uintmax_t _cmocka_set[number_of_values]; \
5541 for (size_t _i = 0; _i < number_of_values; _i++) { \
5542 _cmocka_set[_i] = values[_i]; \
5544 _assert_uint_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5563#define assert_uint_not_in_set(value, values, number_of_values) \
5564 if (number_of_values > 0) { \
5565 uintmax_t _cmocka_set[number_of_values]; \
5566 for (size_t _i = 0; _i < number_of_values; _i++) { \
5567 _cmocka_set[_i] = values[_i]; \
5569 _assert_uint_not_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5590#define assert_float_in_set(value, values, number_of_values, epsilon) \
5591 if (number_of_values > 0) { \
5592 double _cmocka_set[number_of_values]; \
5593 for (size_t _i = 0; _i < number_of_values; _i++) { \
5594 _cmocka_set[_i] = values[_i]; \
5596 _assert_float_in_set(value, _cmocka_set, number_of_values, epsilon, __FILE__, __LINE__); \
5617#define assert_float_not_in_set(value, values, number_of_values, epsilon) \
5618 if (number_of_values > 0) { \
5619 double _cmocka_set[number_of_values]; \
5620 for (size_t _i = 0; _i < number_of_values; _i++) { \
5621 _cmocka_set[_i] = values[_i]; \
5623 _assert_float_not_in_set(value, _cmocka_set, number_of_values, epsilon, __FILE__, __LINE__); \
5702#define function_called() _function_called(__func__, __FILE__, __LINE__)
5718#define expect_function_calls(function, times) \
5719 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, times)
5733#define expect_function_call(function) \
5734 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, 1)
5747#define expect_function_call_any(function) \
5748 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, -1)
5761#define ignore_function_calls(function) \
5762 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, -2)
5805#define fail() _fail(__FILE__, __LINE__)
5814#define skip() _skip(__FILE__, __LINE__)
5828#define stop() _stop()
5848#define fail_msg(msg, ...) do { \
5849 cmocka_print_error("ERROR: " msg "\n", ##__VA_ARGS__); \
5854static inline void _unit_test_dummy(
void **state) {
5862#define unit_test(f) \
5863 (CMOCKA_DEPRECATION_WARNING("unit_test: use cmocka_unit_test instead")( \
5864 UnitTest){#f, f, UNIT_TEST_FUNCTION_TYPE_TEST})
5867#define _unit_test_setup(test, setup) \
5868 { #test "_" #setup, setup, UNIT_TEST_FUNCTION_TYPE_SETUP }
5875#define unit_test_setup(test, setup) \
5876 CMOCKA_DEPRECATION_WARNING( \
5877 "unit_test_setup: use cmocka_unit_test_setup instead") \
5878 _unit_test_setup(test, setup), unit_test(test), \
5879 _unit_test_teardown(test, _unit_test_dummy)
5882#define _unit_test_teardown(test, teardown) \
5883 { #test "_" #teardown, teardown, UNIT_TEST_FUNCTION_TYPE_TEARDOWN }
5890#define unit_test_teardown(test, teardown) \
5891 CMOCKA_DEPRECATION_WARNING( \
5892 "unit_test_teardown: use cmocka_unit_test_teardown instead") \
5893 _unit_test_setup(test, _unit_test_dummy), unit_test(test), \
5894 _unit_test_teardown(test, teardown)
5900#define group_test_setup(setup) \
5901 (CMOCKA_DEPRECATION_WARNING( \
5902 "group_test_setup: use cmocka_run_group_tests instead")(UnitTest){ \
5903 "group_" #setup, setup, UNIT_TEST_FUNCTION_TYPE_GROUP_SETUP})
5909#define group_test_teardown(teardown) \
5910 (CMOCKA_DEPRECATION_WARNING( \
5911 "group_test_teardown: use cmocka_run_group_tests instead")(UnitTest){ \
5912 "group_" #teardown, teardown, UNIT_TEST_FUNCTION_TYPE_GROUP_TEARDOWN})
5921#define unit_test_setup_teardown(test, setup, teardown) \
5922 CMOCKA_DEPRECATION_WARNING("unit_test_setup_teardown: use " \
5923 "cmocka_unit_test_setup_teardown instead") \
5924 _unit_test_setup(test, setup), unit_test(test), \
5925 _unit_test_teardown(test, teardown)
5928#define cmocka_unit_test(f) { #f, f, NULL, NULL, NULL }
5931#define cmocka_unit_test_setup(f, setup) { #f, f, setup, NULL, NULL }
5934#define cmocka_unit_test_teardown(f, teardown) { #f, f, NULL, teardown, NULL }
5940#define cmocka_unit_test_setup_teardown(f, setup, teardown) { #f, f, setup, teardown, NULL }
5949#define cmocka_unit_test_prestate(f, state) { #f, f, NULL, NULL, state }
5958#define cmocka_unit_test_prestate_setup_teardown(f, setup, teardown, state) { #f, f, setup, teardown, state }
6021# define cmocka_run_group_tests(group_tests, group_setup, group_teardown) \
6022 _cmocka_run_group_tests(#group_tests, group_tests, sizeof(group_tests) / sizeof((group_tests)[0]), group_setup, group_teardown)
6090# define cmocka_run_group_tests_name(group_name, group_tests, group_setup, group_teardown) \
6091 _cmocka_run_group_tests(group_name, group_tests, sizeof(group_tests) / sizeof((group_tests)[0]), group_setup, group_teardown)
6181#define test_malloc(size) _test_malloc(size, __FILE__, __LINE__)
6200#define test_calloc(num, size) _test_calloc(num, size, __FILE__, __LINE__)
6216#define test_realloc(ptr, size) _test_realloc(ptr, size, __FILE__, __LINE__)
6229#define test_free(ptr) _test_free(ptr, __FILE__, __LINE__)
6232#if defined(UNIT_TESTING) && defined(ALLOCATION_TESTING)
6233#define malloc test_malloc
6234#define realloc test_realloc
6235#define calloc test_calloc
6236#define free test_free
6292void mock_assert(
const int result,
const char*
const expression,
6293 const char *
const file,
const int line);
6320#define expect_assert_failure(function_call) \
6322 global_expecting_assert = 1; \
6323 if (setjmp(global_expect_assert_env) != 0) { \
6324 print_message("Expected assertion %s occurred\n", \
6325 global_last_failed_assert); \
6326 global_expecting_assert = 0; \
6329 global_expecting_assert = 0; \
6330 print_error("Expected assert in %s\n", #function_call); \
6331 _fail(__FILE__, __LINE__); \
6362 void *(*func)(void);
6370#define LargestIntegralType uintmax_t
6375#if defined(__GNUC__)
6376#define cast_ptr_to_largest_integral_type(value) \
6378 CMOCKA_DEPRECATION_WARNING( \
6379 "cast_ptr_to_largest_integral_type: " \
6380 "use cast_ptr_to_uintmax_type instead"); \
6381 cast_ptr_to_uintmax_type(value); \
6384#define cast_ptr_to_largest_integral_type(value) \
6385 cast_ptr_to_uintmax_type(value)
6402 const uintmax_t check_value_data);
6418 const intmax_t check_value_data);
6426 const uintmax_t check_value_data);
6434 UNIT_TEST_FUNCTION_TYPE_TEST = 0,
6435 UNIT_TEST_FUNCTION_TYPE_SETUP,
6436 UNIT_TEST_FUNCTION_TYPE_TEARDOWN,
6437 UNIT_TEST_FUNCTION_TYPE_GROUP_SETUP,
6438 UNIT_TEST_FUNCTION_TYPE_GROUP_TEARDOWN,
6461 const size_t number_of_tests;
6486 void *initial_state;
6506 const char *parameter_name;
6508 uintmax_t check_value_data;
6518 const char *parameter_name;
6538void print_message(
const char*
const format, ...) CMOCKA_PRINTF_ATTRIBUTE(1, 2);
6539void print_error(const
char* const format, ...) CMOCKA_PRINTF_ATTRIBUTE(1, 2);
6540void vprint_message(const
char* const format, va_list args) CMOCKA_PRINTF_ATTRIBUTE(1, 0);
6541void vprint_error(const
char* const format, va_list args) CMOCKA_PRINTF_ATTRIBUTE(1, 0);
6612#define cm_print_error(format, ...) \
6614 CMOCKA_DEPRECATION_WARNING( \
6615 "cm_print_error: use cmocka_print_error instead") \
6616 cmocka_print_error(format, ##__VA_ARGS__); \
6700CMOCKA_DLLEXTERN extern
int global_expecting_assert;
6701CMOCKA_DLLEXTERN extern jmp_buf global_expect_assert_env;
6702CMOCKA_DLLEXTERN extern const
char * global_last_failed_assert;
6706 const
char *const file,
6712 const
char *const file,
6716bool _has_mock(const
char *const function);
6718void _expect_function_call(
6719 const
char * const function_name,
6720 const
char * const file,
6724void _function_called(const
char * const function, const
char* const file,
6729 const
char* const function, const
char* const parameter,
6730 const
char* const file, const
int line,
6733 const
int count) CMOCKA_DEPRECATED;
6736void _expect_check_data(
6737 const
char* const function, const
char* const parameter,
6738 const
char* const file, const
int line,
6743void _expect_int_in_set(const
char *const function,
6744 const
char *const parameter,
6745 const
char *const file,
6747 const intmax_t values[],
6748 const
size_t number_of_values,
6749 const
size_t count);
6750void _expect_uint_in_set(const
char *const function,
6751 const
char *const parameter,
6752 const
char *const file,
6754 const uintmax_t values[],
6755 const
size_t number_of_values,
6756 const
size_t count);
6758void _expect_float_in_set(const
char *const function,
6759 const
char *const parameter,
6760 const
char *const file,
6762 const
double values[],
6763 const
size_t number_of_values,
6764 const
double epsilon,
6765 const
size_t count);
6767void _expect_not_in_set(
6768 const
char* const function, const
char* const parameter,
6769 const
char* const file, const
int line, const uintmax_t values[],
6770 const
size_t number_of_values, const
int count);
6771void _expect_int_not_in_set(const
char *const function,
6772 const
char *const parameter,
6773 const
char *const file,
6775 const intmax_t values[],
6776 const
size_t number_of_values,
6777 const
size_t count);
6778void _expect_uint_not_in_set(const
char *const function,
6779 const
char *const parameter,
6780 const
char *const file,
6782 const uintmax_t values[],
6783 const
size_t number_of_values,
6784 const
size_t count);
6786void _expect_float_not_in_set(
6787 const
char* const function, const
char* const parameter,
6788 const
char* const file, const
size_t line, const
double values[],
6789 const
size_t number_of_values, const
double epsilon, const
size_t count);
6791void _expect_in_range(const
char *const function,
6792 const
char *const parameter,
6793 const
char *const file,
6795 const uintmax_t minimum,
6796 const uintmax_t maximum,
6797 const
int count) CMOCKA_DEPRECATED;
6798void _expect_int_in_range(const
char *const function,
6799 const
char *const parameter,
6800 const
char *const file,
6802 const intmax_t minimum,
6803 const intmax_t maximum,
6804 const
size_t count);
6805void _expect_uint_in_range(const
char *const function,
6806 const
char *const parameter,
6807 const
char *const file,
6809 const uintmax_t minimum,
6810 const uintmax_t maximum,
6811 const
size_t count);
6812void _expect_not_in_range(
6813 const
char* const function, const
char* const parameter,
6814 const
char* const file, const
int line,
6815 const uintmax_t minimum,
6816 const uintmax_t maximum, const
int count);
6817void _expect_int_not_in_range(const
char *const function,
6818 const
char *const parameter,
6819 const
char *const file,
6821 const intmax_t minimum,
6822 const intmax_t maximum,
6823 const
size_t count);
6824void _expect_uint_not_in_range(const
char *const function,
6825 const
char *const parameter,
6826 const
char *const file,
6828 const uintmax_t minimum,
6829 const uintmax_t maximum,
6830 const
size_t count);
6831void _expect_float_in_range(
6832 const
char* const function, const
char* const parameter,
6833 const
char* const file, const
int line,
6834 const
double minimum, const
double maximum, const
double epsilon,
6836void _expect_float_not_in_range(
6837 const
char* const function, const
char* const parameter,
6838 const
char* const file, const
int line,
6839 const
double minimum, const
double maximum, const
double epsilon,
6843 const
char* const function, const
char* const parameter,
6844 const
char* const file, const
int line, const uintmax_t value,
6846void _expect_int_value(const
char *const function,
6847 const
char *const parameter,
6848 const
char *const file,
6850 const intmax_t value,
6851 const
size_t count);
6852void _expect_uint_value(const
char *const function,
6853 const
char *const parameter,
6854 const
char *const file,
6856 const uintmax_t value,
6857 const
size_t count);
6858void _expect_int_not_value(const
char *const function,
6859 const
char *const parameter,
6860 const
char *const file,
6862 const intmax_t value,
6863 const
size_t count);
6864void _expect_uint_not_value(const
char *const function,
6865 const
char *const parameter,
6866 const
char *const file,
6868 const uintmax_t value,
6869 const
size_t count);
6870void _expect_not_value(
6871 const
char* const function, const
char* const parameter,
6872 const
char* const file, const
int line, const uintmax_t value,
6876 const
char* const function, const
char* const parameter,
6877 const
char* const file, const
int line, const
double value,
6878 const
double epsilon, const
int count);
6879void _expect_not_float(
6880 const
char* const function, const
char* const parameter,
6881 const
char* const file, const
int line, const
double value,
6882 const
double epsilon, const
int count);
6884void _expect_double(const
char *const function,
6885 const
char *const parameter,
6886 const
char *const file,
6889 const
double epsilon,
6891void _expect_not_double(const
char *const function,
6892 const
char *const parameter,
6893 const
char *const file,
6896 const
double epsilon,
6900 const
char* const function, const
char* const parameter,
6901 const
char* const file, const
int line, const
char*
string,
6903void _expect_not_string(
6904 const
char* const function, const
char* const parameter,
6905 const
char* const file, const
int line, const
char*
string,
6909 const
char* const function, const
char* const parameter,
6910 const
char* const file, const
int line, const
void* const memory,
6911 const
size_t size, const
int count);
6912void _expect_not_memory(
6913 const
char* const function, const
char* const parameter,
6914 const
char* const file, const
int line, const
void* const memory,
6915 const
size_t size, const
int count);
6918 const
char* const function, const
char* const parameter,
6919 const
char* const file, const
int line, const
int count);
6921void _check_expected(
6922 const
char * const function_name, const
char * const parameter_name,
6925void _will_return(const
char *const function_name,
6926 const
char *const file,
6931void _will_set_parameter(const
char *const function_name,
6933 const
char *const file,
6938void _assert_true(const uintmax_t result,
6939 const
char* const expression,
6940 const
char * const file, const
int line);
6941void _assert_false(const uintmax_t result,
6942 const
char * const expression,
6943 const
char * const file, const
int line);
6944void _assert_return_code(const intmax_t result,
6945 const int32_t error,
6946 const
char * const expression,
6947 const
char * const file,
6949void _assert_float_equal(const
float a, const
float n,
6950 const
float epsilon, const
char* const file,
6952void _assert_float_not_equal(const
float a, const
float n,
6953 const
float epsilon, const
char* const file,
6955void _assert_double_equal(const
double a, const
double n,
6956 const
double epsilon, const
char* const file,
6958void _assert_double_not_equal(const
double a, const
double n,
6959 const
double epsilon, const
char* const file,
6961void _assert_int_equal(const intmax_t a,
6963 const
char * const file,
6965void _assert_int_not_equal(const intmax_t a,
6967 const
char * const file,
6969void _assert_uint_equal(const uintmax_t a,
6971 const
char * const file,
6973void _assert_uint_not_equal(const uintmax_t a,
6975 const
char * const file,
6977CMOCKA_NO_ACCESS_ATTRIBUTE
6978void _assert_ptr_equal_msg(const
void *a,
6980 const
char *const file,
6982 const
char *const msg);
6983CMOCKA_NO_ACCESS_ATTRIBUTE
6984void _assert_ptr_not_equal_msg(const
void *a,
6986 const
char *const file,
6988 const
char *const msg);
6989void _assert_string_equal(const
char * const a, const
char * const b,
6990 const
char * const file, const
int line);
6991void _assert_string_not_equal(const
char * const a, const
char * const b,
6992 const
char *file, const
int line);
6993void _assert_memory_equal(const
void * const a, const
void * const b,
6994 const
size_t size, const
char* const file,
6996void _assert_memory_not_equal(const
void * const a, const
void * const b,
6997 const
size_t size, const
char* const file,
6999void _assert_int_in_range(const intmax_t value,
7000 const intmax_t minimum,
7001 const intmax_t maximum,
7002 const
char* const file,
7004void _assert_int_not_in_range(const intmax_t value,
7005 const intmax_t minimum,
7006 const intmax_t maximum,
7007 const
char *const file,
7009void _assert_uint_in_range(const uintmax_t value,
7010 const uintmax_t minimum,
7011 const uintmax_t maximum,
7012 const
char* const file,
7014void _assert_uint_not_in_range(const uintmax_t value,
7015 const uintmax_t minimum,
7016 const uintmax_t maximum,
7017 const
char* const file,
7019void _assert_float_in_range(const
double value,
7020 const
double minimum,
7021 const
double maximum,
7022 const
double epsilon,
7023 const
char* const file,
7025void _assert_float_not_in_range(const
double value,
7026 const
double minimum,
7027 const
double maximum,
7028 const
double epsilon,
7029 const
char* const file,
7031void _assert_not_in_set(
7032 const uintmax_t value, const uintmax_t values[],
7033 const
size_t number_of_values, const
char* const file, const
int line);
7034void _assert_int_in_set(const intmax_t value,
7035 const intmax_t values[],
7036 const
size_t number_of_values,
7037 const
char *const file,
7039void _assert_int_not_in_set(const intmax_t value,
7040 const intmax_t values[],
7041 const
size_t number_of_values,
7042 const
char *const file,
7044void _assert_uint_in_set(const uintmax_t value,
7045 const uintmax_t values[],
7046 const
size_t number_of_values,
7047 const
char *const file,
7049void _assert_uint_not_in_set(const uintmax_t value,
7050 const uintmax_t values[],
7051 const
size_t number_of_values,
7052 const
char *const file,
7054void _assert_float_in_set(const
double value,
7055 const
double values[],
7056 const
size_t number_of_values,
7057 const
double epsilon,
7058 const
char *const file,
7060void _assert_float_not_in_set(const
double value,
7061 const
double values[],
7062 const
size_t number_of_values,
7063 const
double epsilon,
7064 const
char *const file,
7067void* _test_malloc(const
size_t size, const
char* file, const
int line);
7068void* _test_realloc(
void *ptr, const
size_t size, const
char* file, const
int line);
7069void* _test_calloc(const
size_t number_of_elements, const
size_t size,
7070 const
char* file, const
int line);
7071void _test_free(
void* const ptr, const
char* file, const
int line);
7073CMOCKA_NORETURN
void _fail(const
char * const file, const
int line);
7075CMOCKA_NORETURN
void _skip(const
char * const file, const
int line);
7077CMOCKA_NORETURN
void _stop(
void);
7080int _cmocka_run_group_tests(const
char *group_name,
7082 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:4795
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:6593
void cmocka_set_skip_filter(const char *pattern)
Set a pattern to skip tests matching the pattern.
Definition cmocka.c:4855
void cmocka_set_test_filter(const char *pattern)
Set a pattern to only run the test matching the pattern.
Definition cmocka.c:4838
@ CM_OUTPUT_TAP
Definition cmocka.h:6601
@ CM_OUTPUT_STDOUT
Definition cmocka.h:6597
@ CM_OUTPUT_SUBUNIT
Definition cmocka.h:6599
@ CM_OUTPUT_STANDARD
Definition cmocka.h:6595
@ CM_OUTPUT_XML
Definition cmocka.h:6603
void(* UnitTestFunction)(void **state)
Definition cmocka.h:6394
int(* CMFixtureFunction)(void **state)
Definition cmocka.h:6476
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:6433
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:6469
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:3446
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:6401
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:6417
int(* CheckParameterValueData)(const CMockaValueData value, const CMockaValueData check_value_data)
Definition cmocka.h:6409
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:6425
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:6557
void(* vprint_error)(const char *const format, va_list args)
Definition cmocka.h:6566
double real_val
Definition cmocka.h:6354
float float_val
Definition cmocka.h:6352
const void * const_ptr
Definition cmocka.h:6358
void * ptr
Definition cmocka.h:6356
intmax_t int_val
Definition cmocka.h:6348
uintmax_t uint_val
Definition cmocka.h:6350