25#define CMOCKA_DLLEXTERN __declspec(dllexport)
27#define CMOCKA_DLLEXTERN __declspec(dllimport)
32#define __func__ __FUNCTION__
36#define inline __inline
50#ifndef CMOCKA_DLLEXTERN
51#define CMOCKA_DLLEXTERN
94#ifndef CMOCKA_NO_STANDARD_INCLUDES
113#define cast_to_intmax_type(value) \
117#define cast_to_uintmax_type(value) \
121#define cast_ptr_to_uintmax_type(value) \
122 ((uintmax_t)(uintptr_t)(value))
125#define cast_to_double_type(value) \
129#define cast_to_float_type(value) \
139#define cast_to_void_pointer(ptr) \
140 ((void *)(uintptr_t)(ptr))
149#define cast_int_to_cmocka_value(value) \
152 .uint_val = (uintmax_t)(value) \
156#define cast_ptr_to_cmocka_value(value) \
159 .const_ptr = (value) \
163#define assign_int_to_cmocka_value(value) \
170#define assign_uint_to_cmocka_value(value) \
173 .uint_val = (value) \
177#define assign_float_to_cmocka_value(value) \
180 .float_val = ((float)(value)) \
184#define assign_double_to_cmocka_value(value) \
187 .real_val = ((double)(value)) \
191#define cmocka_tostring(val) #val
196#define CMOCKA_PRINTF_ATTRIBUTE(a,b) \
197 __attribute__ ((__format__ (__printf__, a, b)))
199#define CMOCKA_PRINTF_ATTRIBUTE(a,b)
202#if defined(CMOCKA_DISABLE_DEPRECATION_WARNINGS) || defined(CMOCKA_DISABLE_DEPRECTATION_WARNINGS)
203#define CMOCKA_DEPRECATED
204#define CMOCKA_DEPRECATION_WARNING(msg)
209#define CMOCKA_DEPRECATED __attribute__ ((deprecated))
214#define CMOCKA_DEPRECATED
218#if defined(__GNUC__) || defined(__clang__)
222#define CMOCKA_DEPRECATION_WARNING(msg) \
224 typedef int cmocka_macro __attribute__((deprecated(msg))); \
225 cmocka_macro cmocka_deprecated_var __attribute__((unused)) = 0; \
226 (void)sizeof(cmocka_deprecated_var); \
228#elif defined(_MSC_VER)
229#define CMOCKA_DEPRECATION_WARNING(msg) __pragma(message("warning: " msg))
231#define CMOCKA_DEPRECATION_WARNING(msg)
237#define CMOCKA_NORETURN __attribute__ ((noreturn))
238#elif defined(_MSC_VER)
239#define CMOCKA_NORETURN __declspec(noreturn)
241#define CMOCKA_NORETURN
257#ifdef __has_attribute
258#if __has_attribute(access) && (defined(__clang__) || __GNUC__ >= 11)
259#define CMOCKA_NO_ACCESS_ATTRIBUTE \
260 __attribute__((access(none, 1), access(none, 2)))
263#ifndef CMOCKA_NO_ACCESS_ATTRIBUTE
264#define CMOCKA_NO_ACCESS_ATTRIBUTE
335#define WILL_RETURN_ALWAYS -1
348#define WILL_RETURN_ONCE -2
359#define EXPECT_ALWAYS -1
370#define EXPECT_MAYBE -2
382#define mock() (_mock(__func__, __FILE__, __LINE__, NULL)).uint_val
409#define mock_type(type) ((type) mock())
440#define has_mock() _has_mock(__func__)
460#define mock_int() (_mock(__func__, __FILE__, __LINE__, NULL)).int_val
480#define mock_uint() (_mock(__func__, __FILE__, __LINE__, "uintmax_t")).uint_val
494#define mock_float() (_mock(__func__, __FILE__, __LINE__, NULL)).float_val
508#define mock_double() (_mock(__func__, __FILE__, __LINE__, NULL)).real_val
534#define mock_ptr_type(type) \
535 ((type)(_mock(__func__, __FILE__, __LINE__, NULL)).ptr)
562#define mock_ptr_type_checked(type) \
563 ((type)(_mock(__func__, __FILE__, __LINE__, #type)).ptr)
602#define mock_parameter(name) \
603 (_mock_parameter(__func__, #name, __FILE__, __LINE__, NULL)).uint_val
629#type mock_parameter_type(#name, #type);
631#define mock_parameter_type(name, type) ((type) mock_parameter(#name))
654#define mock_parameter_int(name) \
655 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "intmax_t")).int_val
678#define mock_parameter_uint(name) \
679 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "uintmax_t")).uint_val
702#define mock_parameter_float(name) \
703 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "float")).float_val
726#define mock_parameter_double(name) \
727 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "double")).real_val
749#define mock_parameter_ptr(name) \
750 ((_mock_parameter(__func__, #name, __FILE__, __LINE__, NULL)).ptr)
776#define mock_parameter_ptr_type(name, type) \
777 ((type)(_mock_parameter(__func__, #name, __FILE__, __LINE__, #type)).ptr)
790#define mock_errno() \
792 intmax_t err = (_mock_parameter( \
840#define will_return(function, value) \
841 _will_return(cmocka_tostring(function), \
845 cast_int_to_cmocka_value(value), \
875#define will_return_int(function, value) \
876 _will_return(#function, \
880 assign_int_to_cmocka_value(value), \
920#define will_return_int_count(function, value, count) \
921 _will_return(#function, \
925 assign_int_to_cmocka_value(value), \
956#define will_return_uint(function, value) \
957 _will_return(#function, \
961 assign_uint_to_cmocka_value(value), \
1001#define will_return_uint_count(function, value, count) \
1002 _will_return(#function, \
1006 assign_uint_to_cmocka_value(value), \
1037#define will_return_float(function, value) \
1038 _will_return(#function, \
1042 assign_float_to_cmocka_value(value), \
1082#define will_return_float_count(function, value, count) \
1083 _will_return(#function, \
1087 assign_float_to_cmocka_value(value), \
1118#define will_return_double(function, value) \
1119 _will_return(#function, \
1123 assign_double_to_cmocka_value(value), \
1163#define will_return_double_count(function, value, count) \
1164 _will_return(#function, \
1168 assign_double_to_cmocka_value(value), \
1190#define will_return_int_always(function, value) \
1191 will_return_int_count(function, (value), WILL_RETURN_ALWAYS)
1213#define will_return_uint_always(function, value) \
1214 will_return_uint_count(function, (value), WILL_RETURN_ALWAYS)
1235#define will_return_float_always(function, value) \
1236 will_return_float_count(function, (value), WILL_RETURN_ALWAYS)
1257#define will_return_double_always(function, value) \
1258 will_return_double_count(function, (value), WILL_RETURN_ALWAYS)
1267#define will_return_count(function, value, count) \
1269 CMOCKA_DEPRECATION_WARNING( \
1270 "will_return_count: use will_return_int_count or " \
1271 "will_return_uint_count instead") \
1272 _will_return(cmocka_tostring(function), \
1276 cast_int_to_cmocka_value(value), \
1287#define will_return_always(function, value) \
1289 CMOCKA_DEPRECATION_WARNING( \
1290 "will_return_always: use will_return_int_always or " \
1291 "will_return_uint_always instead") \
1292 will_return_count(function, (value), WILL_RETURN_ALWAYS); \
1320#define will_return_int_maybe(function, value) \
1321 will_return_int_count(function, (value), WILL_RETURN_ONCE)
1349#define will_return_uint_maybe(function, value) \
1350 will_return_uint_count(function, (value), WILL_RETURN_ONCE)
1377#define will_return_float_maybe(function, value) \
1378 will_return_float_count(function, (value), WILL_RETURN_ONCE)
1405#define will_return_double_maybe(function, value) \
1406 will_return_double_count(function, (value), WILL_RETURN_ONCE)
1415#define will_return_maybe(function, value) \
1417 CMOCKA_DEPRECATION_WARNING( \
1418 "will_return_maybe: use will_return_int_maybe or " \
1419 "will_return_uint_maybe instead") \
1420 will_return_count(function, (value), WILL_RETURN_ONCE); \
1451#define will_return_ptr(function, value) \
1452 _will_return(#function, \
1456 cast_ptr_to_cmocka_value(value), \
1491#define will_return_ptr_type(function, value, type) \
1492 _will_return(#function, \
1496 cast_ptr_to_cmocka_value(value), \
1518#define will_return_ptr_count(function, value, count) \
1519 _will_return(#function, \
1523 cast_ptr_to_cmocka_value(value), \
1545#define will_return_ptr_always(function, value) \
1546 will_return_ptr_count(function, (value), WILL_RETURN_ALWAYS)
1573#define will_return_ptr_maybe(function, value) \
1574 will_return_ptr_count(function, (value), WILL_RETURN_ONCE)
1624#define will_set_parameter(function, name, value) \
1625 _will_set_parameter(cmocka_tostring(function), \
1630 cast_int_to_cmocka_value(value), \
1668#define will_set_parameter_int(function, name, value) \
1669 _will_set_parameter(#function, \
1674 assign_int_to_cmocka_value(value), \
1714#define will_set_parameter_uint(function, name, value) \
1715 _will_set_parameter(#function, \
1720 assign_uint_to_cmocka_value(value), \
1759#define will_set_parameter_float(function, name, value) \
1760 _will_set_parameter(#function, \
1765 assign_float_to_cmocka_value(value), \
1805#define will_set_parameter_double(function, name, value) \
1806 _will_set_parameter(#function, \
1811 assign_double_to_cmocka_value(value), \
1837#define will_set_parameter_int_count(function, name, value, count) \
1838 _will_set_parameter(#function, \
1843 assign_int_to_cmocka_value(value), \
1872#define will_set_parameter_uint_count(function, name, value, count) \
1873 _will_set_parameter(#function, \
1878 assign_uint_to_cmocka_value(value), \
1904#define will_set_parameter_float_count(function, name, value, count) \
1905 _will_set_parameter(#function, \
1910 assign_float_to_cmocka_value(value), \
1936#define will_set_parameter_double_count(function, name, value, count) \
1937 _will_set_parameter(#function, \
1942 assign_double_to_cmocka_value(value), \
1953#define will_set_parameter_count(function, name, value, count) \
1955 CMOCKA_DEPRECATION_WARNING( \
1956 "will_set_parameter_count: use will_set_parameter_int_count or " \
1957 "will_set_parameter_uint_count instead") \
1958 _will_set_parameter(cmocka_tostring(function), \
1963 cast_int_to_cmocka_value(value), \
1990#define will_set_parameter_int_always(function, name, value) \
1991 will_set_parameter_int_count(function, name, (value), WILL_RETURN_ALWAYS)
2016#define will_set_parameter_uint_always(function, name, value) \
2017 will_set_parameter_uint_count(function, name, (value), WILL_RETURN_ALWAYS)
2042#define will_set_parameter_float_always(function, name, value) \
2043 will_set_parameter_float_count(function, name, (value), WILL_RETURN_ALWAYS)
2068#define will_set_parameter_double_always(function, name, value) \
2069 will_set_parameter_double_count(function, name, (value), WILL_RETURN_ALWAYS)
2079#define will_set_parameter_always(function, name, value) \
2081 CMOCKA_DEPRECATION_WARNING( \
2082 "will_set_parameter_always: use will_set_parameter_int_always or " \
2083 "will_set_parameter_uint_always instead") \
2084 will_set_parameter_count(function, name, (value), WILL_RETURN_ALWAYS); \
2111#define will_set_parameter_int_maybe(function, name, value) \
2112 will_set_parameter_int_count(function, name, (value), WILL_RETURN_ONCE)
2138#define will_set_parameter_uint_maybe(function, name, value) \
2139 will_set_parameter_uint_count(function, name, (value), WILL_RETURN_ONCE)
2165#define will_set_parameter_float_maybe(function, name, value) \
2166 will_set_parameter_float_count(function, name, (value), WILL_RETURN_ONCE)
2192#define will_set_parameter_double_maybe(function, name, value) \
2193 will_set_parameter_double_count(function, name, (value), WILL_RETURN_ONCE)
2203#define will_set_parameter_maybe(function, name, value) \
2205 CMOCKA_DEPRECATION_WARNING( \
2206 "will_set_parameter_maybe: use will_set_parameter_int_maybe or " \
2207 "will_set_parameter_uint_maybe instead") \
2208 will_set_parameter_count(function, name, (value), WILL_RETURN_ONCE); \
2243#define will_set_parameter_ptr(function, name, value) \
2244 _will_set_parameter(#function, \
2249 cast_ptr_to_cmocka_value(value), \
2289#define will_set_parameter_ptr_type(function, name, value, type) \
2290 _will_set_parameter(#function, \
2295 cast_ptr_to_cmocka_value(value), \
2340#define will_set_parameter_ptr_count(function, name, value, count) \
2341 _will_set_parameter(#function, \
2346 cast_ptr_to_cmocka_value(value), \
2379#define will_set_parameter_ptr_always(function, name, value) \
2380 will_set_parameter_ptr_count(function, name, (value), WILL_RETURN_ALWAYS)
2414#define will_set_parameter_ptr_maybe(function, name, value) \
2415 will_set_parameter_ptr_count(function, name, (value), WILL_RETURN_ONCE)
2445#define will_set_errno(function, value) \
2446 _will_set_parameter(#function, \
2451 assign_int_to_cmocka_value(value), \
2496#define will_set_errno_count(function, value, count) \
2497 _will_set_parameter(#function, \
2502 assign_int_to_cmocka_value(value), \
2531#define will_set_errno_always(function, value) \
2532 will_set_errno_count(function, (value), WILL_RETURN_ALWAYS);
2560#define will_set_errno_maybe(function, value) \
2561 will_set_errno_count(function, (value), WILL_RETURN_ONCE);
2619 const void *check_data);
2621#define expect_check(function, parameter, check_function, check_data) \
2623 CMOCKA_DEPRECATION_WARNING( \
2624 "expect_check: use expect_check_data instead") \
2625 _expect_check(cmocka_tostring(function), \
2626 cmocka_tostring(parameter), \
2630 cast_to_uintmax_type(check_data), \
2644 const void *check_data,
2647#define expect_check_count( \
2648 function, parameter, check_function, check_data, count) \
2650 CMOCKA_DEPRECATION_WARNING( \
2651 "expect_check_count: use expect_check_data_count instead") \
2652 _expect_check(cmocka_tostring(function), \
2653 cmocka_tostring(parameter), \
2657 cast_to_uintmax_type(check_data), \
2824#define expect_check_data(function, parameter, check_function, check_data) \
2825 _expect_check_data(cmocka_tostring(function), \
2826 cmocka_tostring(parameter), \
2906#define expect_check_data_count(function, \
2911 _expect_check_data(cmocka_tostring(function), \
2912 cmocka_tostring(parameter), \
2927#define expect_in_set(function, parameter, value_array) \
2929 CMOCKA_DEPRECATION_WARNING("expect_in_set: use expect_int_in_set or " \
2930 "expect_uint_in_set instead") \
2931 expect_in_set_count(function, parameter, value_array, 1); \
2952#define expect_int_in_set(function, parameter, value_array) \
2953 expect_int_in_set_count(function, parameter, value_array, 1)
2971void expect_in_set(#function, #parameter, intmax_t value_array[]);
2973#define expect_uint_in_set(function, parameter, value_array) \
2974 expect_uint_in_set_count(function, parameter, value_array, 1)
2983#define expect_in_set_count(function, parameter, value_array, count) \
2985 CMOCKA_DEPRECATION_WARNING( \
2986 "expect_in_set_count: use expect_int_in_set_count or " \
2987 "expect_uint_in_set_count instead") \
2988 _expect_uint_in_set(cmocka_tostring(function), \
2989 cmocka_tostring(parameter), \
2993 sizeof(value_array) / sizeof((value_array)[0]), \
3019#define expect_int_in_set_count(function, parameter, value_array, count) \
3020 _expect_int_in_set(cmocka_tostring(function), \
3021 cmocka_tostring(parameter), \
3025 sizeof(value_array) / sizeof((value_array)[0]), \
3050#define expect_uint_in_set_count(function, parameter, value_array, count) \
3051 _expect_uint_in_set(cmocka_tostring(function), \
3052 cmocka_tostring(parameter), \
3056 sizeof(value_array) / sizeof((value_array)[0]), \
3066#define expect_not_in_set(function, parameter, value_array) \
3068 CMOCKA_DEPRECATION_WARNING( \
3069 "expect_not_in_set: use expect_int_not_in_set or " \
3070 "expect_uint_not_in_set instead") \
3071 expect_not_in_set_count(function, parameter, value_array, 1); \
3081#define expect_not_in_set_count(function, parameter, value_array, count) \
3083 CMOCKA_DEPRECATION_WARNING( \
3084 "expect_not_in_set_count: use expect_int_not_in_set_count or " \
3085 "expect_uint_not_in_set_count instead") \
3086 _expect_not_in_set(cmocka_tostring(function), \
3087 cmocka_tostring(parameter), \
3091 sizeof(value_array) / sizeof((value_array)[0]), \
3113#define expect_int_not_in_set(function, parameter, value_array) \
3114 expect_int_not_in_set_count(function, parameter, value_array, 1)
3138 intmax_t value_array[],
3141#define expect_int_not_in_set_count(function, parameter, value_array, count) \
3142 _expect_int_not_in_set(cmocka_tostring(function), \
3143 cmocka_tostring(parameter), \
3147 sizeof(value_array) / sizeof((value_array)[0]), \
3168#define expect_uint_not_in_set(function, parameter, value_array) \
3169 expect_uint_not_in_set_count(function, parameter, value_array, 1)
3193 uintmax_t value_array[],
3196#define expect_uint_not_in_set_count(function, parameter, value_array, count) \
3197 _expect_uint_not_in_set(cmocka_tostring(function), \
3198 cmocka_tostring(parameter), \
3202 sizeof(value_array) / sizeof((value_array)[0]), \
3225#define expect_float_in_set(function, parameter, value_array, epsilon) \
3226 expect_float_in_set_count(function, parameter, value_array, epsilon, 1)
3252#define expect_float_in_set_count(function, parameter, value_array, epsilon, count) \
3253 _expect_float_in_set(cmocka_tostring(function), \
3254 cmocka_tostring(parameter), \
3258 sizeof(value_array) / sizeof((value_array)[0]), \
3282#define expect_float_not_in_set(function, parameter, value_array, epsilon) \
3283 expect_float_not_in_set_count(function, parameter, value_array, epsilon, 1)
3309#define expect_float_not_in_set_count(function, parameter, value_array, epsilon, count) \
3310 _expect_float_not_in_set(cmocka_tostring(function), \
3311 cmocka_tostring(parameter), \
3315 sizeof(value_array) / sizeof((value_array)[0]), \
3327#define expect_in_range(function, parameter, minimum, maximum) \
3329 CMOCKA_DEPRECATION_WARNING( \
3330 "expect_in_range: use expect_int_in_range or " \
3331 "expect_uint_in_range instead") \
3332 expect_in_range_count(function, parameter, minimum, maximum, 1); \
3342#define expect_in_range_count(function, parameter, minimum, maximum, count) \
3344 CMOCKA_DEPRECATION_WARNING( \
3345 "expect_in_range_count: use expect_int_in_range_count or " \
3346 "expect_uint_in_range_count instead") \
3347 _expect_in_range(cmocka_tostring(function), \
3348 cmocka_tostring(parameter), \
3379#define expect_int_in_range(function, parameter, minimum, maximum) \
3380 expect_int_in_range_count(function, parameter, minimum, maximum, 1)
3410#define expect_int_in_range_count( \
3411 function, parameter, minimum, maximum, count) \
3412 _expect_int_in_range(cmocka_tostring(function), \
3413 cmocka_tostring(parameter), \
3443#define expect_uint_in_range(function, parameter, minimum, maximum) \
3444 expect_uint_in_range_count(function, parameter, minimum, maximum, 1)
3475#define expect_uint_in_range_count( \
3476 function, parameter, minimum, maximum, count) \
3477 _expect_uint_in_range(cmocka_tostring(function), \
3478 cmocka_tostring(parameter), \
3505#define expect_not_in_range(function, parameter, minimum, maximum) \
3506 expect_not_in_range_count(function, parameter, minimum, maximum, 1)
3532#define expect_not_in_range_count(function, parameter, minimum, maximum, \
3534 _expect_not_in_range(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
3535 minimum, maximum, count)
3560#define expect_int_not_in_range(function, parameter, minimum, maximum) \
3561 expect_int_not_in_range_count(function, parameter, minimum, maximum, 1)
3591#define expect_int_not_in_range_count( \
3592 function, parameter, minimum, maximum, count) \
3593 _expect_int_not_in_range(cmocka_tostring(function), \
3594 cmocka_tostring(parameter), \
3624#define expect_uint_not_in_range(function, parameter, minimum, maximum) \
3625 expect_uint_not_in_range_count(function, parameter, minimum, maximum, 1)
3656#define expect_uint_not_in_range_count( \
3657 function, parameter, minimum, maximum, count) \
3658 _expect_uint_not_in_range(cmocka_tostring(function), \
3659 cmocka_tostring(parameter), \
3688#define expect_float_in_range(function, parameter, minimum, maximum, epsilon) \
3689 expect_float_in_range_count(function, parameter, minimum, maximum, epsilon, 1)
3717#define expect_float_in_range_count(function, parameter, minimum, maximum, epsilon, count) \
3718 _expect_float_in_range(cmocka_tostring(function), \
3719 cmocka_tostring(parameter), \
3722 cast_to_double_type(minimum), \
3723 cast_to_double_type(maximum), \
3724 cast_to_double_type(epsilon), \
3749#define expect_float_not_in_range(function, parameter, minimum, maximum, epsilon) \
3750 expect_float_not_in_range_count(function, parameter, minimum, maximum, epsilon, 1)
3778#define expect_float_not_in_range_count(function, parameter, minimum, maximum, \
3780 _expect_float_not_in_range(cmocka_tostring(function), \
3781 cmocka_tostring(parameter), \
3784 cast_to_double_type(minimum), \
3785 cast_to_double_type(maximum), \
3786 cast_to_double_type(epsilon), \
3796#define expect_value(function, parameter, value) \
3798 CMOCKA_DEPRECATION_WARNING("expect_value: use expect_int_value or " \
3799 "expect_uint_value instead") \
3800 expect_value_count(function, parameter, value, 1); \
3810#define expect_value_count(function, parameter, value, count) \
3812 CMOCKA_DEPRECATION_WARNING( \
3813 "expect_value_count: use expect_int_value_count or " \
3814 "expect_uint_value_count instead") \
3815 _expect_value(cmocka_tostring(function), \
3816 cmocka_tostring(parameter), \
3819 cast_to_uintmax_type(value), \
3840#define expect_int_value(function, parameter, value) \
3841 expect_int_value_count(function, parameter, value, 1)
3868#define expect_int_value_count(function, parameter, value, count) \
3869 _expect_int_value(cmocka_tostring(function), \
3870 cmocka_tostring(parameter), \
3894#define expect_uint_value(function, parameter, value) \
3895 expect_uint_value_count(function, parameter, value, 1)
3922#define expect_uint_value_count(function, parameter, value, count) \
3923 _expect_uint_value(cmocka_tostring(function), \
3924 cmocka_tostring(parameter), \
3947#define expect_int_not_value(function, parameter, value) \
3948 expect_int_not_value_count(function, parameter, value, 1)
3975#define expect_int_not_value_count(function, parameter, value, count) \
3976 _expect_int_not_value(cmocka_tostring(function), \
3977 cmocka_tostring(parameter), \
4000#define expect_uint_not_value(function, parameter, value) \
4001 expect_uint_not_value_count(function, parameter, value, 1)
4028#define expect_uint_not_value_count(function, parameter, value, count) \
4029 _expect_uint_not_value(cmocka_tostring(function), \
4030 cmocka_tostring(parameter), \
4043#define expect_not_value(function, parameter, value) \
4045 CMOCKA_DEPRECATION_WARNING( \
4046 "expect_not_value: use expect_int_not_value or " \
4047 "expect_uint_not_value instead") \
4048 expect_not_value_count(function, parameter, value, 1); \
4058#define expect_not_value_count(function, parameter, value, count) \
4060 CMOCKA_DEPRECATION_WARNING( \
4061 "expect_not_value_count: use expect_int_not_value_count or " \
4062 "expect_uint_not_value_count instead") \
4063 _expect_not_value(cmocka_tostring(function), \
4064 cmocka_tostring(parameter), \
4067 cast_to_uintmax_type(value), \
4093#define expect_float(function, parameter, value, epsilon) \
4094 expect_float_count(function, parameter, cast_to_double_type(value), \
4095 cast_to_double_type(epsilon), 1)
4123#define expect_float_count(function, parameter, value, epsilon, count) \
4124 _expect_float(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4125 cast_to_double_type(value), cast_to_double_type(epsilon), count)
4150#define expect_not_float(function, parameter, value, epsilon) \
4151 expect_not_float_count(function, \
4153 cast_to_float_type(value), \
4154 cast_to_float_type(epsilon), \
4183#define expect_not_float_count(function, parameter, value, epsilon, count) \
4184 _expect_not_float(cmocka_tostring(function), \
4185 cmocka_tostring(parameter), \
4188 cast_to_float_type(value), \
4189 cast_to_float_type(epsilon), \
4213#define expect_double(function, parameter, value, epsilon) \
4214 expect_double_count(function, \
4216 cast_to_double_type(value), \
4217 cast_to_double_type(epsilon), \
4249#define expect_double_count(function, parameter, value, epsilon, count) \
4250 _expect_double(cmocka_tostring(function), \
4251 cmocka_tostring(parameter), \
4254 cast_to_double_type(value), \
4255 cast_to_double_type(epsilon), \
4279#define expect_not_double(function, parameter, value, epsilon) \
4280 expect_not_double_count(function, \
4282 cast_to_double_type(value), \
4283 cast_to_double_type(epsilon), \
4315#define expect_not_double_count(function, parameter, value, epsilon, count) \
4316 _expect_not_double(cmocka_tostring(function), \
4317 cmocka_tostring(parameter), \
4320 cast_to_double_type(value), \
4321 cast_to_double_type(epsilon), \
4342#define expect_string(function, parameter, string) \
4343 expect_string_count(function, parameter, string, 1)
4367#define expect_string_count(function, parameter, string, count) \
4368 _expect_string(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4369 (const char*)(string), count)
4389#define expect_not_string(function, parameter, string) \
4390 expect_not_string_count(function, parameter, string, 1)
4414#define expect_not_string_count(function, parameter, string, count) \
4415 _expect_not_string(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4416 (const char*)(string), count)
4437#define expect_memory(function, parameter, memory, size) \
4438 expect_memory_count(function, parameter, memory, size, 1)
4464#define expect_memory_count(function, parameter, memory, size, count) \
4465 _expect_memory(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4466 (const void*)(memory), size, count)
4488#define expect_not_memory(function, parameter, memory, size) \
4489 expect_not_memory_count(function, parameter, memory, size, 1)
4515#define expect_not_memory_count(function, parameter, memory, size, count) \
4516 _expect_not_memory(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4517 (const void*)(memory), size, count)
4535#define expect_any(function, parameter) \
4536 expect_any_count(function, parameter, 1)
4553#define expect_any_always(function, parameter) \
4554 expect_any_count(function, parameter, WILL_RETURN_ALWAYS)
4576#define expect_any_count(function, parameter, count) \
4577 _expect_any(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, count)
4587#define check_expected(parameter) \
4589 CMOCKA_DEPRECATION_WARNING( \
4590 "check_expected: use check_expected_int or " \
4591 "check_expected_uint instead") \
4592 _check_expected(__func__, \
4596 cast_int_to_cmocka_value(parameter)); \
4630#define check_expected_any(parameter) \
4631 _check_expected(__func__, #parameter, __FILE__, __LINE__, \
4632 cast_ptr_to_cmocka_value(&(parameter)))
4648#define check_expected_ptr(parameter) \
4649 _check_expected(__func__, #parameter, __FILE__, __LINE__, \
4650 cast_ptr_to_cmocka_value(parameter))
4666#define check_expected_int(parameter) \
4667 _check_expected(__func__, \
4671 assign_int_to_cmocka_value(parameter))
4687#define check_expected_uint(parameter) \
4688 _check_expected(__func__, \
4692 assign_uint_to_cmocka_value(parameter))
4713#define check_expected_float(parameter) \
4714 _check_expected(__func__, \
4718 assign_float_to_cmocka_value(parameter))
4739#define check_expected_double(parameter) \
4740 _check_expected(__func__, \
4744 assign_double_to_cmocka_value(parameter))
4787#define assert_true(c) _assert_true(cast_to_uintmax_type(c), #c, \
4805#define assert_false(c) _assert_false(cast_to_uintmax_type(c), #c, \
4824#define assert_return_code(rc, error) \
4825 _assert_return_code((rc), \
4827 #rc, __FILE__, __LINE__)
4843#define assert_non_null(c) assert_ptr_not_equal((c), NULL)
4861#define assert_non_null_msg(c, msg) assert_ptr_not_equal_msg((c), NULL, (msg))
4877#define assert_null(c) assert_ptr_equal((c), NULL)
4895#define assert_null_msg(c, msg) assert_ptr_equal_msg((c), NULL, (msg))
4911#define assert_ptr_equal(a, b) assert_ptr_equal_msg((a), (b), NULL)
4929#define assert_ptr_equal_msg(a, b, msg) \
4930 _assert_ptr_equal_msg(cast_to_void_pointer(a), \
4931 cast_to_void_pointer(b), \
4932 __FILE__, __LINE__, (msg))
4948#define assert_ptr_not_equal(a, b) \
4949 assert_ptr_not_equal_msg((a), (b), NULL)
4968#if defined(__has_builtin)
4970#if __has_builtin(__builtin_unreachable)
4971#define assert_ptr_not_equal_msg(a, b, msg) \
4973 const void *cmocka_p1 = cast_to_void_pointer(a), \
4974 *cmocka_p2 = cast_to_void_pointer(b); \
4975 _assert_ptr_not_equal_msg( \
4976 cmocka_p1, cmocka_p2, __FILE__, __LINE__, (msg)); \
4977 if (cmocka_p1 == cmocka_p2) { \
4978 __builtin_unreachable(); \
4982#define assert_ptr_not_equal_msg(a, b, msg) \
4983_assert_ptr_not_equal_msg(cast_to_void_pointer(a), \
4984 cast_to_void_pointer(b), \
4991#define assert_ptr_not_equal_msg(a, b, msg) \
4992_assert_ptr_not_equal_msg(cast_to_void_pointer(a), \
4993 cast_to_void_pointer(b), \
5014#define assert_int_equal(a, b) \
5015 _assert_int_equal(cast_to_intmax_type(a), \
5016 cast_to_intmax_type(b), \
5033#define assert_uint_equal(a, b) \
5034 _assert_uint_equal(cast_to_uintmax_type(a), \
5035 cast_to_uintmax_type(b), \
5054#define assert_int_not_equal(a, b) \
5055 _assert_int_not_equal(cast_to_intmax_type(a), \
5056 cast_to_intmax_type(b), \
5073#define assert_uint_not_equal(a, b) \
5074 _assert_uint_not_equal(cast_to_uintmax_type(a), \
5075 cast_to_uintmax_type(b), \
5094#define assert_float_equal(a, b, epsilon) \
5095 _assert_float_equal((float)a, \
5116#define assert_float_not_equal(a, b, epsilon) \
5117 _assert_float_not_equal((float)a, \
5138#define assert_double_equal(a, b, epsilon) \
5139 _assert_double_equal((double)a, \
5160#define assert_double_not_equal(a, b, epsilon) \
5161 _assert_double_not_equal((double)a, \
5183#define assert_string_equal(a, b) \
5184 _assert_string_equal((a), (b), __FILE__, __LINE__)
5202#define assert_string_not_equal(a, b) \
5203 _assert_string_not_equal((a), (b), __FILE__, __LINE__)
5223#define assert_memory_equal(a, b, size) \
5224 _assert_memory_equal((const void*)(a), (const void*)(b), size, __FILE__, \
5245#define assert_memory_not_equal(a, b, size) \
5246 _assert_memory_not_equal((const void*)(a), (const void*)(b), size, \
5266#define assert_int_in_range(value, minimum, maximum) \
5267 _assert_int_in_range( \
5268 cast_to_intmax_type(value), \
5269 cast_to_intmax_type(minimum), \
5270 cast_to_intmax_type(maximum), __FILE__, __LINE__)
5289#define assert_uint_in_range(value, minimum, maximum) \
5290 _assert_uint_in_range( \
5291 cast_to_uintmax_type(value), \
5292 cast_to_uintmax_type(minimum), \
5293 cast_to_uintmax_type(maximum), __FILE__, __LINE__)
5317#define assert_int_not_in_range(value, minimum, maximum) \
5318 _assert_int_not_in_range(cast_to_intmax_type(value), \
5319 cast_to_intmax_type(minimum), \
5320 cast_to_intmax_type(maximum), \
5346#define assert_uint_not_in_range(value, minimum, maximum) \
5347 _assert_uint_not_in_range(cast_to_uintmax_type(value), \
5348 cast_to_uintmax_type(minimum), \
5349 cast_to_uintmax_type(maximum), \
5360#define assert_in_range(value, minimum, maximum) \
5362 CMOCKA_DEPRECATION_WARNING( \
5363 "assert_in_range: use assert_int_in_range or " \
5364 "assert_uint_in_range instead") \
5365 _assert_uint_in_range(cast_to_uintmax_type(value), \
5366 cast_to_uintmax_type(minimum), \
5367 cast_to_uintmax_type(maximum), \
5379#define assert_not_in_range(value, minimum, maximum) \
5381 CMOCKA_DEPRECATION_WARNING( \
5382 "assert_not_in_range: use assert_int_not_in_range or " \
5383 "assert_uint_not_in_range instead") \
5384 _assert_uint_not_in_range(cast_to_uintmax_type(value), \
5385 cast_to_uintmax_type(minimum), \
5386 cast_to_uintmax_type(maximum), \
5413#define assert_float_not_in_range(value, minimum, maximum, epsilon) \
5414 _assert_float_not_in_range(cast_to_double_type(value), \
5415 cast_to_double_type(minimum), \
5416 cast_to_double_type(maximum), \
5417 cast_to_double_type(epsilon), \
5440#define assert_float_in_range(value, minimum, maximum, epsilon) \
5441 _assert_float_in_range( \
5442 cast_to_double_type(value), \
5443 cast_to_double_type(minimum), \
5444 cast_to_double_type(maximum), \
5445 cast_to_double_type(epsilon), __FILE__, __LINE__)
5454#define assert_in_set(value, values, number_of_values) \
5456 CMOCKA_DEPRECATION_WARNING("assert_in_set: use assert_int_in_set or " \
5457 "assert_uint_in_set instead") \
5458 _assert_uint_in_set( \
5459 value, values, number_of_values, __FILE__, __LINE__); \
5478#define assert_not_in_set(value, values, number_of_values) \
5479 _assert_not_in_set(value, values, number_of_values, __FILE__, __LINE__)
5497#define assert_int_in_set(value, values, number_of_values) \
5498 if (number_of_values > 0) { \
5499 intmax_t _cmocka_set[number_of_values]; \
5500 for (size_t _i = 0; _i < number_of_values; _i++) { \
5501 _cmocka_set[_i] = values[_i]; \
5503 _assert_int_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5522#define assert_int_not_in_set(value, values, number_of_values) \
5523 if (number_of_values > 0) { \
5524 intmax_t _cmocka_set[number_of_values]; \
5525 for (size_t _i = 0; _i < number_of_values; _i++) { \
5526 _cmocka_set[_i] = values[_i]; \
5528 _assert_int_not_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5547#define assert_uint_in_set(value, values, number_of_values) \
5548 if (number_of_values > 0) { \
5549 uintmax_t _cmocka_set[number_of_values]; \
5550 for (size_t _i = 0; _i < number_of_values; _i++) { \
5551 _cmocka_set[_i] = values[_i]; \
5553 _assert_uint_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5572#define assert_uint_not_in_set(value, values, number_of_values) \
5573 if (number_of_values > 0) { \
5574 uintmax_t _cmocka_set[number_of_values]; \
5575 for (size_t _i = 0; _i < number_of_values; _i++) { \
5576 _cmocka_set[_i] = values[_i]; \
5578 _assert_uint_not_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5599#define assert_float_in_set(value, values, number_of_values, epsilon) \
5600 if (number_of_values > 0) { \
5601 double _cmocka_set[number_of_values]; \
5602 for (size_t _i = 0; _i < number_of_values; _i++) { \
5603 _cmocka_set[_i] = values[_i]; \
5605 _assert_float_in_set(value, _cmocka_set, number_of_values, epsilon, __FILE__, __LINE__); \
5626#define assert_float_not_in_set(value, values, number_of_values, epsilon) \
5627 if (number_of_values > 0) { \
5628 double _cmocka_set[number_of_values]; \
5629 for (size_t _i = 0; _i < number_of_values; _i++) { \
5630 _cmocka_set[_i] = values[_i]; \
5632 _assert_float_not_in_set(value, _cmocka_set, number_of_values, epsilon, __FILE__, __LINE__); \
5711#define function_called() _function_called(__func__, __FILE__, __LINE__)
5727#define expect_function_calls(function, times) \
5728 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, times)
5742#define expect_function_call(function) \
5743 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, 1)
5756#define expect_function_call_any(function) \
5757 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, -1)
5770#define ignore_function_calls(function) \
5771 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, -2)
5814#define fail() _fail(__FILE__, __LINE__)
5823#define skip() _skip(__FILE__, __LINE__)
5837#define stop() _stop()
5857#define fail_msg(...) do { \
5858 cmocka_print_error("ERROR: "); \
5859 cmocka_print_error(__VA_ARGS__); \
5860 cmocka_print_error("\n"); \
5865static inline void _unit_test_dummy(
void **state) {
5873#define unit_test(f) \
5874 (CMOCKA_DEPRECATION_WARNING("unit_test: use cmocka_unit_test instead")( \
5875 UnitTest){#f, f, UNIT_TEST_FUNCTION_TYPE_TEST})
5878#define _unit_test_setup(test, setup) \
5879 { #test "_" #setup, setup, UNIT_TEST_FUNCTION_TYPE_SETUP }
5886#define unit_test_setup(test, setup) \
5887 CMOCKA_DEPRECATION_WARNING( \
5888 "unit_test_setup: use cmocka_unit_test_setup instead") \
5889 _unit_test_setup(test, setup), unit_test(test), \
5890 _unit_test_teardown(test, _unit_test_dummy)
5893#define _unit_test_teardown(test, teardown) \
5894 { #test "_" #teardown, teardown, UNIT_TEST_FUNCTION_TYPE_TEARDOWN }
5901#define unit_test_teardown(test, teardown) \
5902 CMOCKA_DEPRECATION_WARNING( \
5903 "unit_test_teardown: use cmocka_unit_test_teardown instead") \
5904 _unit_test_setup(test, _unit_test_dummy), unit_test(test), \
5905 _unit_test_teardown(test, teardown)
5911#define group_test_setup(setup) \
5912 (CMOCKA_DEPRECATION_WARNING( \
5913 "group_test_setup: use cmocka_run_group_tests instead")(UnitTest){ \
5914 "group_" #setup, setup, UNIT_TEST_FUNCTION_TYPE_GROUP_SETUP})
5920#define group_test_teardown(teardown) \
5921 (CMOCKA_DEPRECATION_WARNING( \
5922 "group_test_teardown: use cmocka_run_group_tests instead")(UnitTest){ \
5923 "group_" #teardown, teardown, UNIT_TEST_FUNCTION_TYPE_GROUP_TEARDOWN})
5932#define unit_test_setup_teardown(test, setup, teardown) \
5933 CMOCKA_DEPRECATION_WARNING("unit_test_setup_teardown: use " \
5934 "cmocka_unit_test_setup_teardown instead") \
5935 _unit_test_setup(test, setup), unit_test(test), \
5936 _unit_test_teardown(test, teardown)
5939#define cmocka_unit_test(f) { #f, f, NULL, NULL, NULL }
5942#define cmocka_unit_test_setup(f, setup) { #f, f, setup, NULL, NULL }
5945#define cmocka_unit_test_teardown(f, teardown) { #f, f, NULL, teardown, NULL }
5951#define cmocka_unit_test_setup_teardown(f, setup, teardown) { #f, f, setup, teardown, NULL }
5960#define cmocka_unit_test_prestate(f, state) { #f, f, NULL, NULL, state }
5969#define cmocka_unit_test_prestate_setup_teardown(f, setup, teardown, state) { #f, f, setup, teardown, state }
6032# define cmocka_run_group_tests(group_tests, group_setup, group_teardown) \
6033 _cmocka_run_group_tests(#group_tests, group_tests, sizeof(group_tests) / sizeof((group_tests)[0]), group_setup, group_teardown)
6101# define cmocka_run_group_tests_name(group_name, group_tests, group_setup, group_teardown) \
6102 _cmocka_run_group_tests(group_name, group_tests, sizeof(group_tests) / sizeof((group_tests)[0]), group_setup, group_teardown)
6192#define test_malloc(size) _test_malloc(size, __FILE__, __LINE__)
6211#define test_calloc(num, size) _test_calloc(num, size, __FILE__, __LINE__)
6227#define test_realloc(ptr, size) _test_realloc(ptr, size, __FILE__, __LINE__)
6240#define test_free(ptr) _test_free(ptr, __FILE__, __LINE__)
6243#if defined(UNIT_TESTING) && defined(ALLOCATION_TESTING)
6244#define malloc test_malloc
6245#define realloc test_realloc
6246#define calloc test_calloc
6247#define free test_free
6303void mock_assert(
const int result,
const char*
const expression,
6304 const char *
const file,
const size_t line);
6331#define expect_assert_failure(function_call) \
6333 global_expecting_assert = 1; \
6334 if (setjmp(global_expect_assert_env) != 0) { \
6335 print_message("Expected assertion %s occurred\n", \
6336 global_last_failed_assert); \
6337 global_expecting_assert = 0; \
6340 global_expecting_assert = 0; \
6341 print_error("Expected assert in %s\n", #function_call); \
6342 _fail(__FILE__, __LINE__); \
6373 void *(*func)(void);
6381#define LargestIntegralType uintmax_t
6386#if defined(__GNUC__)
6387#define cast_ptr_to_largest_integral_type(value) \
6389 CMOCKA_DEPRECATION_WARNING( \
6390 "cast_ptr_to_largest_integral_type: " \
6391 "use cast_ptr_to_uintmax_type instead"); \
6392 cast_ptr_to_uintmax_type(value); \
6395#define cast_ptr_to_largest_integral_type(value) \
6396 cast_ptr_to_uintmax_type(value)
6413 const uintmax_t check_value_data);
6429 const intmax_t check_value_data);
6437 const uintmax_t check_value_data);
6445 UNIT_TEST_FUNCTION_TYPE_TEST = 0,
6446 UNIT_TEST_FUNCTION_TYPE_SETUP,
6447 UNIT_TEST_FUNCTION_TYPE_TEARDOWN,
6448 UNIT_TEST_FUNCTION_TYPE_GROUP_SETUP,
6449 UNIT_TEST_FUNCTION_TYPE_GROUP_TEARDOWN,
6472 const size_t number_of_tests;
6497 void *initial_state;
6517 const char *parameter_name;
6519 uintmax_t check_value_data;
6529 const char *parameter_name;
6549void print_message(
const char*
const format, ...) CMOCKA_PRINTF_ATTRIBUTE(1, 2);
6550void print_error(const
char* const format, ...) CMOCKA_PRINTF_ATTRIBUTE(1, 2);
6551void vprint_message(const
char* const format, va_list args) CMOCKA_PRINTF_ATTRIBUTE(1, 0);
6552void vprint_error(const
char* const format, va_list args) CMOCKA_PRINTF_ATTRIBUTE(1, 0);
6623#define cm_print_error(...) \
6625 CMOCKA_DEPRECATION_WARNING( \
6626 "cm_print_error: use cmocka_print_error instead") \
6627 cmocka_print_error(__VA_ARGS__); \
6711CMOCKA_DLLEXTERN extern
int global_expecting_assert;
6712CMOCKA_DLLEXTERN extern jmp_buf global_expect_assert_env;
6713CMOCKA_DLLEXTERN extern const
char * global_last_failed_assert;
6717 const
char *const file,
6723 const
char *const file,
6727bool _has_mock(const
char *const function);
6729void _expect_function_call(
6730 const
char * const function_name,
6731 const
char * const file,
6735void _function_called(const
char * const function, const
char* const file,
6740 const
char* const function, const
char* const parameter,
6741 const
char* const file, const
size_t line,
6744 const
int count) CMOCKA_DEPRECATED;
6747void _expect_check_data(
6748 const
char* const function, const
char* const parameter,
6749 const
char* const file, const
size_t line,
6754void _expect_int_in_set(const
char *const function,
6755 const
char *const parameter,
6756 const
char *const file,
6758 const intmax_t values[],
6759 const
size_t number_of_values,
6760 const intmax_t count);
6761void _expect_uint_in_set(const
char *const function,
6762 const
char *const parameter,
6763 const
char *const file,
6765 const uintmax_t values[],
6766 const
size_t number_of_values,
6767 const intmax_t count);
6769void _expect_float_in_set(const
char *const function,
6770 const
char *const parameter,
6771 const
char *const file,
6773 const
double values[],
6774 const
size_t number_of_values,
6775 const
double epsilon,
6776 const intmax_t count);
6778void _expect_not_in_set(
6779 const
char* const function, const
char* const parameter,
6780 const
char* const file, const
size_t line, const uintmax_t values[],
6781 const
size_t number_of_values, const
int count);
6782void _expect_int_not_in_set(const
char *const function,
6783 const
char *const parameter,
6784 const
char *const file,
6786 const intmax_t values[],
6787 const
size_t number_of_values,
6788 const intmax_t count);
6789void _expect_uint_not_in_set(const
char *const function,
6790 const
char *const parameter,
6791 const
char *const file,
6793 const uintmax_t values[],
6794 const
size_t number_of_values,
6795 const intmax_t count);
6797void _expect_float_not_in_set(
6798 const
char* const function, const
char* const parameter,
6799 const
char* const file, const
size_t line, const
double values[],
6800 const
size_t number_of_values, const
double epsilon, const intmax_t count);
6802void _expect_in_range(const
char *const function,
6803 const
char *const parameter,
6804 const
char *const file,
6806 const uintmax_t minimum,
6807 const uintmax_t maximum,
6808 const
int count) CMOCKA_DEPRECATED;
6809void _expect_int_in_range(const
char *const function,
6810 const
char *const parameter,
6811 const
char *const file,
6813 const intmax_t minimum,
6814 const intmax_t maximum,
6815 const intmax_t count);
6816void _expect_uint_in_range(const
char *const function,
6817 const
char *const parameter,
6818 const
char *const file,
6820 const uintmax_t minimum,
6821 const uintmax_t maximum,
6822 const intmax_t count);
6823void _expect_not_in_range(
6824 const
char* const function, const
char* const parameter,
6825 const
char* const file, const
size_t line,
6826 const uintmax_t minimum,
6827 const uintmax_t maximum, const
int count);
6828void _expect_int_not_in_range(const
char *const function,
6829 const
char *const parameter,
6830 const
char *const file,
6832 const intmax_t minimum,
6833 const intmax_t maximum,
6834 const intmax_t count);
6835void _expect_uint_not_in_range(const
char *const function,
6836 const
char *const parameter,
6837 const
char *const file,
6839 const uintmax_t minimum,
6840 const uintmax_t maximum,
6841 const intmax_t count);
6842void _expect_float_in_range(
6843 const
char* const function, const
char* const parameter,
6844 const
char* const file, const
size_t line,
6845 const
double minimum, const
double maximum, const
double epsilon,
6847void _expect_float_not_in_range(
6848 const
char* const function, const
char* const parameter,
6849 const
char* const file, const
size_t line,
6850 const
double minimum, const
double maximum, const
double epsilon,
6854 const
char* const function, const
char* const parameter,
6855 const
char* const file, const
size_t line, const uintmax_t value,
6857void _expect_int_value(const
char *const function,
6858 const
char *const parameter,
6859 const
char *const file,
6861 const intmax_t value,
6862 const intmax_t count);
6863void _expect_uint_value(const
char *const function,
6864 const
char *const parameter,
6865 const
char *const file,
6867 const uintmax_t value,
6868 const intmax_t count);
6869void _expect_int_not_value(const
char *const function,
6870 const
char *const parameter,
6871 const
char *const file,
6873 const intmax_t value,
6874 const intmax_t count);
6875void _expect_uint_not_value(const
char *const function,
6876 const
char *const parameter,
6877 const
char *const file,
6879 const uintmax_t value,
6880 const intmax_t count);
6881void _expect_not_value(
6882 const
char* const function, const
char* const parameter,
6883 const
char* const file, const
size_t line, const uintmax_t value,
6887 const
char* const function, const
char* const parameter,
6888 const
char* const file, const
size_t line, const
double value,
6889 const
double epsilon, const
int count);
6890void _expect_not_float(
6891 const
char* const function, const
char* const parameter,
6892 const
char* const file, const
size_t line, const
double value,
6893 const
double epsilon, const
int count);
6895void _expect_double(const
char *const function,
6896 const
char *const parameter,
6897 const
char *const file,
6900 const
double epsilon,
6902void _expect_not_double(const
char *const function,
6903 const
char *const parameter,
6904 const
char *const file,
6907 const
double epsilon,
6911 const
char* const function, const
char* const parameter,
6912 const
char* const file, const
size_t line, const
char*
string,
6914void _expect_not_string(
6915 const
char* const function, const
char* const parameter,
6916 const
char* const file, const
size_t line, const
char*
string,
6920 const
char* const function, const
char* const parameter,
6921 const
char* const file, const
size_t line, const
void* const memory,
6922 const
size_t size, const
int count);
6923void _expect_not_memory(
6924 const
char* const function, const
char* const parameter,
6925 const
char* const file, const
size_t line, const
void* const memory,
6926 const
size_t size, const
int count);
6929 const
char* const function, const
char* const parameter,
6930 const
char* const file, const
size_t line, const
int count);
6932void _check_expected(
6933 const
char * const function_name, const
char * const parameter_name,
6936void _will_return(const
char *const function_name,
6937 const
char *const file,
6942void _will_set_parameter(const
char *const function_name,
6944 const
char *const file,
6949void _assert_true(const uintmax_t result,
6950 const
char* const expression,
6951 const
char * const file, const
size_t line);
6952void _assert_false(const uintmax_t result,
6953 const
char * const expression,
6954 const
char * const file, const
size_t line);
6955void _assert_return_code(const intmax_t result,
6956 const int32_t error,
6957 const
char * const expression,
6958 const
char * const file,
6960void _assert_float_equal(const
float a, const
float n,
6961 const
float epsilon, const
char* const file,
6963void _assert_float_not_equal(const
float a, const
float n,
6964 const
float epsilon, const
char* const file,
6966void _assert_double_equal(const
double a, const
double n,
6967 const
double epsilon, const
char* const file,
6969void _assert_double_not_equal(const
double a, const
double n,
6970 const
double epsilon, const
char* const file,
6972void _assert_int_equal(const intmax_t a,
6974 const
char * const file,
6976void _assert_int_not_equal(const intmax_t a,
6978 const
char * const file,
6980void _assert_uint_equal(const uintmax_t a,
6982 const
char * const file,
6984void _assert_uint_not_equal(const uintmax_t a,
6986 const
char * const file,
6988CMOCKA_NO_ACCESS_ATTRIBUTE
6989void _assert_ptr_equal_msg(const
void *a,
6991 const
char *const file,
6993 const
char *const msg);
6994CMOCKA_NO_ACCESS_ATTRIBUTE
6995void _assert_ptr_not_equal_msg(const
void *a,
6997 const
char *const file,
6999 const
char *const msg);
7000void _assert_string_equal(const
char * const a, const
char * const b,
7001 const
char * const file, const
size_t line);
7002void _assert_string_not_equal(const
char * const a, const
char * const b,
7003 const
char *file, const
size_t line);
7004void _assert_memory_equal(const
void * const a, const
void * const b,
7005 const
size_t size, const
char* const file,
7007void _assert_memory_not_equal(const
void * const a, const
void * const b,
7008 const
size_t size, const
char* const file,
7010void _assert_int_in_range(const intmax_t value,
7011 const intmax_t minimum,
7012 const intmax_t maximum,
7013 const
char* const file,
7015void _assert_int_not_in_range(const intmax_t value,
7016 const intmax_t minimum,
7017 const intmax_t maximum,
7018 const
char *const file,
7020void _assert_uint_in_range(const uintmax_t value,
7021 const uintmax_t minimum,
7022 const uintmax_t maximum,
7023 const
char* const file,
7025void _assert_uint_not_in_range(const uintmax_t value,
7026 const uintmax_t minimum,
7027 const uintmax_t maximum,
7028 const
char* const file,
7030void _assert_float_in_range(const
double value,
7031 const
double minimum,
7032 const
double maximum,
7033 const
double epsilon,
7034 const
char* const file,
7036void _assert_float_not_in_range(const
double value,
7037 const
double minimum,
7038 const
double maximum,
7039 const
double epsilon,
7040 const
char* const file,
7042void _assert_not_in_set(
7043 const uintmax_t value, const uintmax_t values[],
7044 const
size_t number_of_values, const
char* const file, const
size_t line);
7045void _assert_int_in_set(const intmax_t value,
7046 const intmax_t values[],
7047 const
size_t number_of_values,
7048 const
char *const file,
7050void _assert_int_not_in_set(const intmax_t value,
7051 const intmax_t values[],
7052 const
size_t number_of_values,
7053 const
char *const file,
7055void _assert_uint_in_set(const uintmax_t value,
7056 const uintmax_t values[],
7057 const
size_t number_of_values,
7058 const
char *const file,
7060void _assert_uint_not_in_set(const uintmax_t value,
7061 const uintmax_t values[],
7062 const
size_t number_of_values,
7063 const
char *const file,
7065void _assert_float_in_set(const
double value,
7066 const
double values[],
7067 const
size_t number_of_values,
7068 const
double epsilon,
7069 const
char *const file,
7071void _assert_float_not_in_set(const
double value,
7072 const
double values[],
7073 const
size_t number_of_values,
7074 const
double epsilon,
7075 const
char *const file,
7078void* _test_malloc(const
size_t size, const
char* file, const
size_t line);
7079void* _test_realloc(
void *ptr, const
size_t size, const
char* file, const
size_t line);
7080void* _test_calloc(const
size_t number_of_elements, const
size_t size,
7081 const
char* file, const
size_t line);
7082void _test_free(
void* const ptr, const
char* file, const
size_t line);
7084CMOCKA_NORETURN
void _fail(const
char * const file, const
size_t line);
7086CMOCKA_NORETURN
void _skip(const
char * const file, const
size_t line);
7088CMOCKA_NORETURN
void _stop(
void);
7091int _cmocka_run_group_tests(const
char *group_name,
7093 const
size_t num_tests,
void * test_realloc(void *ptr, size_t size)
Test function overriding realloc which detects buffer overruns and memory leaks.
void test_free(void *ptr)
Test function overriding free(3).
void * test_calloc(size_t nmemb, size_t size)
Test function overriding calloc.
void * test_malloc(size_t size)
Test function overriding malloc.
void assert_in_set(uintmax_t value, uintmax_t values[], intmax_t count)
void assert_ptr_equal(void *a, void *b)
Assert that the two given pointers are equal.
void assert_int_equal(intmax_t a, intmax_t b)
Assert that the two given integers are equal.
void assert_string_equal(const char *a, const char *b)
Assert that the two given strings are equal.
void assert_uint_in_set(uintmax_t value, uintmax_t values[], intmax_t count)
Assert that the specified unsigned integer value is within a set.
void assert_null(void *pointer)
Assert that the given pointer is NULL.
void assert_float_not_in_set(double value, double values[], intmax_t count, double epsilon)
Assert that the specified float value is not within a set.
void assert_not_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum)
void assert_float_not_in_range(double value, double minimum, double maximum, double epsilon)
Assert that the specified float value is smaller than the minimum or greater than the maximum.
void assert_memory_not_equal(const void *a, const void *b, size_t size)
Assert that the two given areas of memory are not equal.
void assert_ptr_not_equal(void *a, void *b)
Assert that the two given pointers are not equal.
void assert_double_equal(double a, double b, double epsilon)
Assert that the two given double are equal given an epsilon.
void assert_ptr_not_equal_msg(void *a, void *b, const char *const msg)
Assert that the two given pointers are not equal.
void assert_int_in_set(intmax_t value, intmax_t values[], intmax_t count)
Assert that the specified integer value is within a set.
void assert_float_in_range(double value, double minimum, double maximum, double epsilon)
Assert that the specified float value is not smaller than the minimum and and not greater than the ma...
void assert_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum)
void assert_uint_equal(uintmax_t a, uintmax_t b)
Assert that the two given unsigned integers are equal.
void assert_int_not_in_set(intmax_t value, intmax_t values[], intmax_t count)
Assert that the specified value is not within a set.
void assert_non_null(void *pointer)
Assert that the given pointer is non-NULL.
void assert_null_msg(void *pointer, const char *const message)
Assert that the given pointer is NULL.
void assert_uint_not_in_set(uintmax_t value, uintmax_t values[], intmax_t count)
Assert that the specified unsigned integer value is not within a set.
void assert_float_in_set(double value, double values[], intmax_t count, double epsilon)
Assert that the specified float value is within a set.
void assert_true(scalar expression)
Assert that the given expression is true.
void assert_ptr_equal_msg(void *a, void *b, const char *const msg)
Assert that the two given pointers are equal.
void assert_false(scalar expression)
Assert that the given expression is false.
void assert_int_in_range(intmax_t value, intmax_t minimum, intmax_t maximum)
Assert that the specified integer value is not smaller than the minimum and and not greater than the ...
void assert_uint_not_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum)
Assert that the specified value is smaller than the minimum or greater than the maximum.
void assert_int_not_equal(intmax_t a, intmax_t b)
Assert that the two given integers are not equal.
void assert_uint_not_equal(uintmax_t a, uintmax_t b)
Assert that the two given unsigned integers are not equal.
void assert_memory_equal(const void *a, const void *b, size_t size)
Assert that the two given areas of memory are equal, otherwise fail.
void assert_float_equal(float a, float b, float epsilon)
Assert that the two given float are equal given an epsilon.
void assert_double_not_equal(double a, double b, double epsilon)
Assert that the two given double are not equal given an epsilon.
void assert_string_not_equal(const char *a, const char *b)
Assert that the two given strings are not equal.
void assert_int_not_in_range(intmax_t value, intmax_t minimum, intmax_t maximum)
Assert that the specified value is smaller than the minimum or greater than the maximum.
void assert_not_in_set(uintmax_t value, uintmax_t values[], intmax_t count)
Assert that the specified value is not within a set.
void assert_float_not_equal(float a, float b, float epsilon)
Assert that the two given float are not equal given an epsilon.
void assert_non_null_msg(void *pointer, const char *const message)
Assert that the given pointer is non-NULL.
void assert_uint_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum)
Assert that the specified unsigned integer value is not smaller than the minimum and and not greater ...
void assert_return_code(intmax_t rc, int32_t error)
Assert that the return_code is greater than or equal to 0.
void ignore_function_calls(#function)
Ignores function_called() invocations from given mock function.
void expect_function_call_any(#function)
Expects function_called() from given mock at least once.
void expect_function_call(#function)
Store expected single call to a mock to be checked by function_called() later.
void function_called(void)
Check that current mocked function is being called in the expected order.
void expect_function_calls(#function, const int times)
Store expected call(s) to a mock to be checked by function_called() later.
void cmocka_set_message_output(uint32_t output)
Function to set the output format for a test.
Definition cmocka.c:4818
void cm_print_error(const char *const format,...)
void cmocka_set_callbacks(const struct CMCallbacks *f_callbacks)
Set callback functions for CMocka.
Definition cmocka.c:154
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:6604
void cmocka_set_skip_filter(const char *pattern)
Set a pattern to skip tests matching the pattern.
Definition cmocka.c:4878
void cmocka_set_test_filter(const char *pattern)
Set a pattern to only run the test matching the pattern.
Definition cmocka.c:4861
@ CM_OUTPUT_TAP
Definition cmocka.h:6612
@ CM_OUTPUT_STDOUT
Definition cmocka.h:6608
@ CM_OUTPUT_SUBUNIT
Definition cmocka.h:6610
@ CM_OUTPUT_STANDARD
Definition cmocka.h:6606
@ CM_OUTPUT_XML
Definition cmocka.h:6614
void(* UnitTestFunction)(void **state)
Definition cmocka.h:6405
int(* CMFixtureFunction)(void **state)
Definition cmocka.h:6487
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:6444
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:6480
void mock_assert(const int result, const char *const expression, const char *const file, const size_t line)
Function to replace assert(3) in tested code.
Definition cmocka.c:3468
void expect_assert_failure(function fn_call)
Ensure that mock_assert() is called.
void will_return_int(#function, intmax_t value)
Store an integer value to be returned by mock() later.
void will_set_parameter_float_always(#function, #name, float value)
Store a named float value that will always be returned by mock_parameter_float().
uintmax_t mock_parameter(#name)
Retrieve a named value for the current function.
void will_return_float_maybe(#function, float value)
Store a float value that may always be returned by mock_float().
void will_set_parameter_int(#function, #name, intmax_t value)
Store a named integer value to be returned by mock_parameter() later.
intmax_t mock_int()
Retrieve an integer return value of the current function.
void will_return_float_always(#function, float value)
Store a float value that will always be returned by mock_float().
void will_set_parameter_int_count(#function, #name, intmax_t value, int count)
Store a named integer value to be returned a specified number of times by mock_parameter_int() later.
void will_return_double_count(#function, double value, int count)
Store a double precision floating point value to be returned a specified number of times by mock() la...
void will_set_parameter_double_count(#function, #name, double value, int count)
Store a named double value to be returned a specified number of times by mock_parameter_double() late...
void will_set_parameter_uint(#function, #name, uintmax_t value)
Store a named unsigned integer value to be returned by mock_parameter() later.
void will_set_parameter_float_maybe(#function, #name, float value)
Store a named float value that may always be returned by mock_parameter_float().
void * mock_parameter_ptr(#name)
Retrieve a named pointer for the current function.
void will_return_count(#function, uintmax_t value, int count)
void will_set_parameter(#function, #name, uintmax_t value)
Store a named value to be returned by mock_parameter() later.
void will_return_int_maybe(#function, intmax_t value)
Store an integer value that may always be returned by mock_int().
void will_set_parameter_ptr_type(#function, #name, void *value, #type)
Store a named pointer value to be returned by mock_parameter() later.
void will_set_parameter_ptr(#function, #name, void *value)
Store a named pointer value to be returned by mock_parameter() later.
void will_return(#function, uintmax_t value)
Store a value to be returned by mock() later.
void will_return_ptr_type(#function, void *value, type)
Store a pointer value to be returned by mock_ptr_type_checked() later.
void will_return_double_always(#function, double value)
Store a double value that will always be returned by mock_double().
void will_set_errno_always(#function, intmax_t value)
Store an integer value to set errno to by mock_errno() later, for a specified number of times.
type mock_parameter_ptr_type(#name, #type)
Retrieve a named pointer for the current function.
double mock_double(void)
Retrieve a double precision floating point return value of the current function.
void will_return_uint_maybe(#function, uintmax_t value)
Store an unsigned integer value that may always be returned by mock_uint().
void will_return_uint_always(#function, uintmax_t value)
Store an unsigned integer value that will always be returned by mock_uint().
void will_set_parameter_double_maybe(#function, #name, double value)
Store a named double value that may always be returned by mock_parameter_double().
void will_set_parameter_int_maybe(#function, #name, intmax_t value)
Store a named integer value that may always be returned by mock_parameter_int().
void will_set_errno_maybe(#function, intmax_t value)
Store an integer value to set errno to by mock_errno() later, for a specified number of times.
void will_return_uint_count(#function, uintmax_t value, int count)
Store an unsigned integer value to be returned a specified number of times by mock() later.
void will_return_double_maybe(#function, double value)
Store a double value that may always be returned by mock_double().
uintmax_t mock_uint(void)
Retrieve an unsigned integer return value of the current function.
void will_set_parameter_double(#function, #name, double value)
Store a named double precision floating point value to be returned by mock_parameter() later.
void will_set_parameter_ptr_always(#function, #name, void *value)
Store a named pointer value that will be always returned by mock_parameter_ptr().
void will_return_always(#function, uintmax_t value)
void will_return_ptr(#function, void *value)
Store a pointer value to be returned by mock_ptr_type() later.
void will_return_ptr_always(#function, void *value)
Store a value that will be always returned by mock_ptr_type().
void will_return_int_always(#function, intmax_t value)
Store an integer value that will always be returned by mock_int().
type mock_type(#type)
Retrieve a value of the current function and cast it to given type.
void will_set_errno_count(#function, intmax_t value, intmax_t count)
Store an integer value to always set errno to by mock_errno().
void will_set_parameter_float(#function, #name, float value)
Store a named float value to be returned by mock_parameter() later.
void will_set_parameter_double_always(#function, #name, double value)
Store a named double value that will always be returned by mock_parameter_double().
bool has_mock(void)
Check if data is available for the current mock function.
float mock_parameter_float(#name)
Retrieve a named float value for the current function.
void will_set_parameter_uint_maybe(#function, #name, uintmax_t value)
Store a named unsigned integer value that may always be returned by mock_parameter_uint().
void will_set_parameter_int_always(#function, #name, intmax_t value)
Store a named integer value that will always be returned by mock_parameter_int().
void will_return_maybe(#function, uintmax_t value)
void will_set_parameter_always(#function, #name, uintmax_t value)
void will_set_parameter_count(#function, #name, uintmax_t value, int count)
void will_return_int_count(#function, intmax_t value, int count)
Store an integer value to be returned a specified number of times by mock() later.
void will_set_parameter_float_count(#function, #name, float value, int count)
Store a named float value to be returned a specified number of times by mock_parameter_float() later.
void will_return_ptr_count(#function, void *value, int count)
Store a pointer value to be returned by mock_ptr_type() later.
void will_set_parameter_uint_always(#function, #name, uintmax_t value)
Store a named unsigned integer value that will always be returned by mock_parameter_uint().
void will_set_parameter_maybe(#function, #name, uintmax_t value)
uintmax_t mock_parameter_uint(#name)
Retrieve an unsigned integer return value of the current function.
void will_return_uint(#function, uintmax_t value)
Store a unsigned integer value to be returned by mock() later.
void will_return_float(#function, float value)
Store a float value to be returned by mock() later.
void will_set_errno(#function, intmax_t value)
Store an integer value to set errno to by mock_errno() later.
void will_return_float_count(#function, float value, int count)
Store a float value to be returned a specified number of times by mock() later.
type mock_ptr_type(#type)
Retrieve a typed return value of the current function.
void will_set_parameter_ptr_count(#function, #name, void *value, int count)
Store a named pointer value to be returned a specified number of times by mock_parameter_ptr() later.
float mock_float(void)
Retrieve a float return value of the current function.
uintmax_t mock(void)
Retrieve a return value of the current function.
void mock_errno(void)
set errno for the current function.
intmax_t mock_parameter_int(#name)
Retrieve a named value for the current function and cast it to given type.
void will_return_double(#function, double value)
Store a double precision floating point value to be returned by mock() later.
void will_set_parameter_ptr_maybe(#function, #name, void *value)
Store a named pointer value that may be always returned by mock_parameter_ptr().
void will_return_ptr_maybe(#function, void *value)
Store a value that may be always returned by mock_ptr_type().
void will_set_parameter_uint_count(#function, uintmax_t value, int count)
Store a named unsigned integer value to be returned a specified number of times by mock_parameter_uin...
double mock_parameter_double(#name)
Retrieve a named double precision floating point value for the current function.
type mock_ptr_type_checked(#type)
Retrieve a typed return value of the current function with type checking.
void expect_float_not_in_set(#function, #parameter, double value_array[], double epsilon)
Add an event to check if the float parameter value is not part of the provided array.
void expect_uint_in_range_count(#function, uintmax_t minimum, uintmax_t maximum, intmax_t count)
Add an event to repeatedly check an unsigned integer parameter is inside a numerical range....
void expect_uint_value_count(#function, uintmax_t value, intmax_t count)
Add an event to repeatedly check if an unsigned integer parameter is the given value.
void expect_uint_not_in_set_count(#function, uintmax_t value_array[], intmax_t count)
Add an event to check if the unsigned integer parameter value is not part of the provided unsigned in...
void expect_uint_not_in_range(#function, uintmax_t minimum, uintmax_t maximum)
Add an event to check an unsigned integer parameter is outside a numerical range. The check would suc...
void expect_not_double_count(#function, double value, double epsilon, intmax_t count)
Add an event to repeatedly check if a parameter isn't the double precision floating point value.
void expect_int_in_range_count(#function, intmax_t minimum, intmax_t maximum, intmax_t count)
Add an event to repeatedly check an integer parameter is inside a numerical range....
void expect_not_memory_count(#function, #parameter, void *memory, size_t size, intmax_t count)
Add an event to repeatedly check if the parameter doesn't match an area of memory.
void expect_not_string(#function, #parameter, const char *string)
Add an event to check if the parameter value isn't equal to the provided string.
void check_expected_ptr(#parameter)
Determine whether a function parameter is correct.
void expect_float_not_in_range_count(#function, #parameter, double minimum, double maximum, double epsilon, intmax_t count)
Add an event to repeatedly check a parameter is outside a numerical range. The check would succeed if...
void expect_int_not_in_set_count(#function, intmax_t value_array[], intmax_t count)
Add an event to check if the integer parameter value is not part of the provided integer array.
void check_expected(#parameter)
void expect_value_count(#function, #parameter, uintmax_t value, intmax_t count)
void expect_int_not_value_count(#function, intmax_t value, intmax_t count)
Add an event to repeatedly check if a parameter (int) isn't the given value.
void expect_double_count(#function, double value, double epsilon, intmax_t count)
Add an event to repeatedly check if a parameter is the given double precision floating point value.
void expect_not_in_range_count(#function, #parameter, uintmax_t minimum, uintmax_t maximum, intmax_t count)
Add an event to repeatedly check a parameter is outside a numerical range. The check would succeed if...
void expect_check_data(function, parameter, CheckParameterValueData check_function, CMockaValueData check_data)
Add a custom parameter checking function using CMockaValueData (new API).
void expect_uint_in_set_count(#function, #parameter, uintmax_t value_array[], intmax_t count)
Add an event to check if the parameter value is part of the provided unsigned integer array.
void expect_in_range(#function, #parameter, uintmax_t minimum, uintmax_t maximum)
void expect_uint_not_value_count(#function, uintmax_t value, intmax_t count)
Add an event to repeatedly check if a parameter (uint) isn't the given value.
void expect_float(#function, #parameter, double value, double epsilon)
Add an event to check if a parameter is the given floating point value.
void expect_memory_count(#function, #parameter, void *memory, size_t size, intmax_t count)
Add an event to repeatedly check if the parameter does match an area of memory.
void expect_float_in_range_count(#function, #parameter, double minimum, double maximum, double epsilon, intmax_t count)
Add an event to repeatedly check a parameter is inside a numerical range. The check would succeed if ...
void check_expected_float(#parameter)
Determine whether a function parameter is correct.
void expect_float_in_range(#function, #parameter, double minimum, double maximum, double epsilon)
Add an event to check a parameter is inside a numerical range. The check would succeed if minimum <= ...
void expect_double(#function, #parameter, double value, double epsilon)
Add an event to check if a parameter is the given double precision floating point value.
void expect_string(#function, #parameter, const char *string)
Add an event to check if the parameter value is equal to the provided string.
void expect_in_range_count(#function, #parameter, uintmax_t minimum, uintmax_t maximum, intmax_t count)
void expect_not_string_count(#function, #parameter, const char *string, intmax_t count)
Add an event to check if the parameter value isn't equal to the provided string.
void expect_int_value(#function, #parameter, intmax_t value)
Add an event to check if an integer parameter is the given value.
void expect_int_not_in_set(#function, #parameter, intmax_t value_array[])
Add an event to check if the integer parameter value is not part of the provided integer array.
void expect_any_always(#function, #parameter)
Add an event to always check if a parameter (of any value) has been passed.
void expect_uint_in_range(#function, uintmax_t minimum, uintmax_t maximum)
Add an event to check an unsigned integer parameter is inside a numerical range. The check would succ...
void expect_not_memory(#function, #parameter, void *memory, size_t size)
Add an event to check if the parameter doesn't match an area of memory.
void expect_not_in_range(#function, #parameter, uintmax_t minimum, uintmax_t maximum)
Add an event to check a parameter is outside a numerical range. The check would succeed if minimum > ...
void expect_check_count(function, parameter, CheckParameterValue check_function, const void *check_data, intmax_t count)
int(* CheckParameterValue)(const uintmax_t value, const uintmax_t check_value_data)
Definition cmocka.h:6412
void expect_uint_value(#function, #parameter, uintmax_t value)
Add an event to check if an unsigned integer parameter is the given value.
void check_expected_int(#parameter)
Determine whether a function parameter is correct.
void expect_string_count(#function, #parameter, const char *string, intmax_t count)
Add an event to check if the parameter value is equal to the provided string.
void expect_any_count(#function, #parameter, intmax_t count)
Add an event to repeatedly check if a parameter (of any value) has been passed.
void expect_int_in_set_count(#function, #parameter, intmax_t value_array[], intmax_t count)
Add an event to check if the parameter value is part of the provided integer array.
void check_expected_double(#parameter)
Determine whether a function parameter is correct.
int(* CheckIntParameterValue)(const intmax_t value, const intmax_t check_value_data)
Definition cmocka.h:6428
void expect_check_data_count(function, parameter, CheckParameterValueData check_function, CMockaValueData check_data, intmax_t count)
Add a custom parameter checking function using CMockaValueData with count (new API).
int(* CheckParameterValueData)(const CMockaValueData value, const CMockaValueData check_value_data)
Definition cmocka.h:6420
void expect_not_value(#function, #parameter, uintmax_t value)
void expect_memory(#function, #parameter, void *memory, size_t size)
Add an event to check if the parameter does match an area of memory.
void expect_int_in_range(#function, intmax_t minimum, intmax_t maximum)
Add an event to check an integer parameter is inside a numerical range. The check would succeed if mi...
void expect_not_float(#function, #parameter, double value, double epsilon)
Add an event to check if a parameter isn't the given floating point value.
void check_expected_uint(#parameter)
Determine whether a function parameter is correct.
void expect_float_count(#function, #parameter, double value, double epsilon, intmax_t count)
Add an event to repeatedly check if a parameter is the given floating point value.
void expect_not_value_count(#function, #parameter, uintmax_t value, intmax_t count)
void expect_in_set_count(#function, #parameter, uintmax_t value_array[], intmax_t count)
void expect_any(#function, #parameter)
Add an event to check if a parameter (of any value) has been passed.
void expect_float_in_set(#function, #parameter, double value_array[], double epsilon)
Add an event to check if the float parameter value is part of the provided array.
void expect_not_in_set(#function, #parameter, uintmax_t value_array[])
void expect_float_in_set_count(#function, #parameter, double value_array[], double epsilon, intmax_t count)
Add an event to check if the float parameter value is part of the provided integer array.
void expect_float_not_in_range(#function, #parameter, double minimum, double maximum, double epsilon)
Add an event to check a parameter is outside a numerical range. The check would succeed if minimum > ...
void expect_not_in_set_count(#function, #parameter, uintmax_t value_array[], intmax_t count)
int(* CheckUintParameterValue)(const uintmax_t value, const uintmax_t check_value_data)
Definition cmocka.h:6436
void check_expected_any(#parameter)
Check that any parameter value matches the next value in the queue.
void expect_int_not_in_range_count(#function, intmax_t minimum, intmax_t maximum, intmax_t count)
Add an event to repeatedly check an integer parameter is outside a numerical range....
void expect_value(#function, #parameter, uintmax_t value)
void expect_not_float_count(#function, #parameter, double value, double epsilon, intmax_t count)
Add an event to repeatedly check if a parameter isn't the floating point value.
void expect_check(function, parameter, CheckParameterValue check_function, const void *check_data)
void expect_uint_not_in_range_count(#function, uintmax_t minimum, uintmax_t maximum, intmax_t count)
Add an event to repeatedly check an unsigned integer parameter is outside a numerical range....
void expect_not_double(#function, #parameter, double value, double epsilon)
Add an event to check if a parameter isn't the given double precision floating point value.
void expect_uint_not_value(#function, #parameter, uintmax_t value)
Add an event to check if a parameter (uint) isn't the given value.
void expect_int_not_value(#function, #parameter, intmax_t value)
Add an event to check if a parameter (int) isn't the given value.
void expect_in_set(#function, #parameter, uintmax_t value_array[])
void expect_uint_not_in_set(#function, #parameter, uintmax_t value_array[])
Add an event to check if the unsigned integer parameter value is not part of the provided unsigned in...
void expect_float_not_in_set_count(#function, #parameter, double value_array[], double epsilon, intmax_t count)
Add an event to check if the float parameter value is not part of the provided integer array.
void expect_int_value_count(#function, intmax_t value, intmax_t count)
Add an event to repeatedly check if an integer parameter is the given value.
void expect_int_not_in_range(#function, intmax_t minimum, intmax_t maximum)
Add an event to check an integer parameter is outside a numerical range. The check would succeed if m...
void(* vprint_message)(const char *const format, va_list args)
Definition cmocka.h:6568
void(* vprint_error)(const char *const format, va_list args)
Definition cmocka.h:6577
double real_val
Definition cmocka.h:6365
float float_val
Definition cmocka.h:6363
const void * const_ptr
Definition cmocka.h:6369
void * ptr
Definition cmocka.h:6367
intmax_t int_val
Definition cmocka.h:6359
uintmax_t uint_val
Definition cmocka.h:6361