cmocka 2.0.3
Unit testing library with mock support
Loading...
Searching...
No Matches
cmocka.h
1/*
2 * Copyright 2008 Google Inc.
3 * Copyright 2014-2022 Andreas Schneider <asn@cryptomilk.org>
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17#ifndef CMOCKA_H_
18#define CMOCKA_H_
19
20#ifdef _WIN32
21# ifdef _MSC_VER
22
23# ifndef CMOCKA_STATIC
24# ifdef CMOCKA_EXPORTS
25#define CMOCKA_DLLEXTERN __declspec(dllexport)
26# else
27#define CMOCKA_DLLEXTERN __declspec(dllimport)
28# endif /* CMOCKA_EXPORTS */
29# endif /* ndef CMOCKA_STATIC */
30
31#ifndef __func__
32#define __func__ __FUNCTION__
33#endif /* __func__ */
34
35#ifndef inline
36#define inline __inline
37#endif /* inline */
38
39# endif /* _MSC_VER */
40#endif /* _WIN32 */
41
50#ifndef CMOCKA_DLLEXTERN
51#define CMOCKA_DLLEXTERN // only needed on MSVC compiler when using a DLL
52#endif /* ndef CMOCKA_DLLEXTERN */
53
54#ifdef __cplusplus
55extern "C" {
56#endif
57
93
94#ifndef CMOCKA_NO_STANDARD_INCLUDES
95#include <stdarg.h>
96#include <stdbool.h>
97#include <stddef.h>
98#include <stdint.h>
99#include <setjmp.h>
100#endif
101
111
112/* Perform an signed cast to intmax_t. */
113#define cast_to_intmax_type(value) \
114 ((intmax_t)(value))
115
116/* Perform an unsigned cast to uintmax_t. */
117#define cast_to_uintmax_type(value) \
118 ((uintmax_t)(value))
119
120/* Perform a safe cast from pointer to uintmax_t. */
121#define cast_ptr_to_uintmax_type(value) \
122 ((uintmax_t)(uintptr_t)(value))
123
124/* Perform cast to double. */
125#define cast_to_double_type(value) \
126 ((double)(value))
127
128/* Perform cast to float. */
129#define cast_to_float_type(value) \
130 ((float)(value))
131
139#define cast_to_void_pointer(ptr) \
140 ((void *)(uintptr_t)(ptr))
141
149#define cast_int_to_cmocka_value(value) \
150 (CMockaValueData) \
151 { \
152 .uint_val = (uintmax_t)(value) \
153 }
154
156#define cast_ptr_to_cmocka_value(value) \
157 (CMockaValueData) \
158 { \
159 .const_ptr = (value) \
160 }
161
163#define assign_int_to_cmocka_value(value) \
164 (CMockaValueData) \
165 { \
166 .int_val = (value) \
167 }
168
170#define assign_uint_to_cmocka_value(value) \
171 (CMockaValueData) \
172 { \
173 .uint_val = (value) \
174 }
175
177#define assign_float_to_cmocka_value(value) \
178 (CMockaValueData) \
179 { \
180 .float_val = ((float)(value)) \
181 }
182
184#define assign_double_to_cmocka_value(value) \
185 (CMockaValueData) \
186 { \
187 .real_val = ((double)(value)) \
188 }
189
190/* Nested macros are not expanded when they appear along with # or ## */
191#define cmocka_tostring(val) #val
192
194/* GCC have printf type attribute check. */
195#ifdef __GNUC__
196#define CMOCKA_PRINTF_ATTRIBUTE(a,b) \
197 __attribute__ ((__format__ (__printf__, a, b)))
198#else
199#define CMOCKA_PRINTF_ATTRIBUTE(a,b)
200#endif /* __GNUC__ */
201
202#if defined(CMOCKA_DISABLE_DEPRECATION_WARNINGS) || defined(CMOCKA_DISABLE_DEPRECTATION_WARNINGS)
203#define CMOCKA_DEPRECATED
204#define CMOCKA_DEPRECATION_WARNING(msg)
205#else /* CMOCKA_DISABLE_DEPRECATION_WARNINGS */
206
207/* Deprecation warnings for functions */
208#if defined(__GNUC__)
209#define CMOCKA_DEPRECATED __attribute__ ((deprecated))
210#else
211/* MSVC requires __declspec(deprecated) before the function declaration,
212 * not after it. Since we already use CMOCKA_DEPRECATION_WARNING() in
213 * the macro wrappers, we don't need function-level deprecation for MSVC. */
214#define CMOCKA_DEPRECATED
215#endif
216
217/* Deprecation warnings for macros */
218#if defined(__GNUC__) || defined(__clang__)
219/* Use a deprecated typedef in a statement expression to generate warnings
220 * that work even when the header is included as a system header (-isystem).
221 */
222#define CMOCKA_DEPRECATION_WARNING(msg) \
223 __extension__({ \
224 typedef int cmocka_macro __attribute__((deprecated(msg))); \
225 cmocka_macro cmocka_deprecated_var __attribute__((unused)) = 0; \
226 (void)sizeof(cmocka_deprecated_var); \
227 });
228#elif defined(_MSC_VER)
229#define CMOCKA_DEPRECATION_WARNING(msg) __pragma(message("warning: " msg))
230#else
231#define CMOCKA_DEPRECATION_WARNING(msg)
232#endif
233
234#endif /* CMOCKA_DISABLE_DEPRECATION_WARNINGS */
235
236#if defined(__GNUC__)
237#define CMOCKA_NORETURN __attribute__ ((noreturn))
238#elif defined(_MSC_VER)
239#define CMOCKA_NORETURN __declspec(noreturn)
240#else
241#define CMOCKA_NORETURN
242#endif
243
244/* Function attribute that tells the compiler that we never access the value
245 * of a/b, just the pointer address.
246 *
247 * Without this, newer compilers like GCC-12 will print
248 * `-Wmaybe-uninitialized` warnings.
249 *
250 * GCC 10 knows the access attribute but rejects the 'none' mode, which was
251 * only added in GCC 11. Clang defines __GNUC__ as 4, so it is not affected
252 * by the version check.
253 *
254 * See:
255 * https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Common-Function-Attributes.html#Common-Function-Attributes
256 */
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)))
261#endif
262#endif
263#ifndef CMOCKA_NO_ACCESS_ATTRIBUTE
264#define CMOCKA_NO_ACCESS_ATTRIBUTE
265#endif
266
267/* Expands to a comma followed by the given arguments if any were passed,
268 * and to nothing otherwise. Uses the standard C23/C++20 __VA_OPT__()
269 * where available to avoid the GNU ',' ## __VA_ARGS__ token pasting
270 * extension, which clang rejects with -Wgnu-zero-variadic-macro-arguments
271 * when -Werror is in effect.
272 *
273 * clang >= 8 supports __VA_OPT__() in all language modes. GCC accepts it
274 * in C23 (and gnu99) modes but rejects it in strict pre-C23 modes
275 * (-std=c99 -Wpedantic), so only use it there when the language mode
276 * allows it. Everything else falls back to the GNU extension, which
277 * swallows the comma when no arguments are passed. */
278#if (defined(__clang__) && __clang_major__ >= 8) || \
279 (defined(_MSC_VER) && defined(_MSVC_TRADITIONAL) && !_MSVC_TRADITIONAL) || \
280 (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L)
281#define CMOCKA_VA_ARGS(...) __VA_OPT__(,) __VA_ARGS__
282#else
283/* Fallback for compilers without __VA_OPT__ (MSVC traditional
284 * preprocessor, GCC < 8, strict pre-C23 modes): the GNU extension
285 * swallows the comma when no arguments are passed. */
286#define CMOCKA_VA_ARGS(...) , ##__VA_ARGS__
287#endif
289 /* cmocka_util */
291
343
356#define WILL_RETURN_ALWAYS -1
357
369#define WILL_RETURN_ONCE -2
370
380#define EXPECT_ALWAYS -1
381
391#define EXPECT_MAYBE -2
392
393#ifdef DOXYGEN
401uintmax_t mock(void);
402#else
403#define mock() (_mock(__func__, __FILE__, __LINE__, NULL)).uint_val
404#endif
405
406
407#ifdef DOXYGEN
428type mock_type(#type);
429#else
430#define mock_type(type) ((type) mock())
431#endif
432
433#ifdef DOXYGEN
459bool has_mock(void);
460#else
461#define has_mock() _has_mock(__func__)
462#endif
463
464#ifdef DOXYGEN
478intmax_t mock_int();
479#else
480/* TODO: Enable type safety check by passing intmax_t instead of NULL */
481#define mock_int() (_mock(__func__, __FILE__, __LINE__, NULL)).int_val
482#endif
483
484
485#ifdef DOXYGEN
499uintmax_t mock_uint(void);
500#else
501#define mock_uint() (_mock(__func__, __FILE__, __LINE__, "uintmax_t")).uint_val
502#endif
503
504
505#ifdef DOXYGEN
513float mock_float(void);
514#else
515#define mock_float() (_mock(__func__, __FILE__, __LINE__, NULL)).float_val
516#endif
517
518#ifdef DOXYGEN
527double mock_double(void);
528#else
529#define mock_double() (_mock(__func__, __FILE__, __LINE__, NULL)).real_val
530#endif
531
532#ifdef DOXYGEN
553type mock_ptr_type(#type);
554#else
555#define mock_ptr_type(type) \
556 ((type)(_mock(__func__, __FILE__, __LINE__, NULL)).ptr)
557#endif
558
559#ifdef DOXYGEN
582#else
583#define mock_ptr_type_checked(type) \
584 ((type)(_mock(__func__, __FILE__, __LINE__, #type)).ptr)
585#endif
586
587#ifdef DOXYGEN
621uintmax_t mock_parameter(#name);
622#else
623#define mock_parameter(name) \
624 (_mock_parameter(__func__, #name, __FILE__, __LINE__, NULL)).uint_val
625#endif
626
627#ifdef DOXYGEN
650#type mock_parameter_type(#name, #type);
651#else
652#define mock_parameter_type(name, type) ((type) mock_parameter(#name))
653#endif
654
655#ifdef DOXYGEN
673intmax_t mock_parameter_int(#name);
674#else
675#define mock_parameter_int(name) \
676 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "intmax_t")).int_val
677#endif
678
679#ifdef DOXYGEN
697uintmax_t mock_parameter_uint(#name);
698#else
699#define mock_parameter_uint(name) \
700 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "uintmax_t")).uint_val
701#endif
702
703#ifdef DOXYGEN
722#else
723#define mock_parameter_float(name) \
724 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "float")).float_val
725#endif
726
727#ifdef DOXYGEN
746#else
747#define mock_parameter_double(name) \
748 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "double")).real_val
749#endif
750
751#ifdef DOXYGEN
769#else
770#define mock_parameter_ptr(name) \
771 ((_mock_parameter(__func__, #name, __FILE__, __LINE__, NULL)).ptr)
772#endif
773
774#ifdef DOXYGEN
795type mock_parameter_ptr_type(#name, #type);
796#else
797#define mock_parameter_ptr_type(name, type) \
798 ((type)(_mock_parameter(__func__, #name, __FILE__, __LINE__, #type)).ptr)
799#endif
800
801#ifdef DOXYGEN
809void mock_errno(void);
810#else
811#define mock_errno() \
812 do { \
813 intmax_t err = (_mock_parameter( \
814 __func__, \
815 "/errno", \
816 __FILE__, \
817 __LINE__, \
818 "errno")).int_val; \
819 if (err != 0) { \
820 errno = err; \
821 } \
822 } while (0)
823#endif
824
825#ifdef DOXYGEN
859void will_return(#function, uintmax_t value);
860#else
861#define will_return(function, value) \
862 _will_return(cmocka_tostring(function), \
863 __FILE__, \
864 __LINE__, \
865 NULL, \
866 cast_int_to_cmocka_value(value), \
867 1)
868#endif
869
870#ifdef DOXYGEN
894void will_return_int(#function, intmax_t value);
895#else
896#define will_return_int(function, value) \
897 _will_return(#function, \
898 __FILE__, \
899 __LINE__, \
900 "intmax_t", \
901 assign_int_to_cmocka_value(value), \
902 1)
903#endif
904
905#ifdef DOXYGEN
939void will_return_int_count(#function, intmax_t value, int count);
940#else
941#define will_return_int_count(function, value, count) \
942 _will_return(#function, \
943 __FILE__, \
944 __LINE__, \
945 "intmax_t", \
946 assign_int_to_cmocka_value(value), \
947 count)
948#endif
949
950#ifdef DOXYGEN
975void will_return_uint(#function, uintmax_t value);
976#else
977#define will_return_uint(function, value) \
978 _will_return(#function, \
979 __FILE__, \
980 __LINE__, \
981 "uintmax_t", \
982 assign_uint_to_cmocka_value(value), \
983 1)
984#endif
985
986#ifdef DOXYGEN
1020void will_return_uint_count(#function, uintmax_t value, int count);
1021#else
1022#define will_return_uint_count(function, value, count) \
1023 _will_return(#function, \
1024 __FILE__, \
1025 __LINE__, \
1026 "uintmax_t", \
1027 assign_uint_to_cmocka_value(value), \
1028 count)
1029#endif
1030
1031#ifdef DOXYGEN
1056void will_return_float(#function, float value);
1057#else
1058#define will_return_float(function, value) \
1059 _will_return(#function, \
1060 __FILE__, \
1061 __LINE__, \
1062 "float", \
1063 assign_float_to_cmocka_value(value), \
1064 1)
1065#endif
1066
1067#ifdef DOXYGEN
1101void will_return_float_count(#function, float value, int count);
1102#else
1103#define will_return_float_count(function, value, count) \
1104 _will_return(#function, \
1105 __FILE__, \
1106 __LINE__, \
1107 "float", \
1108 assign_float_to_cmocka_value(value), \
1109 count)
1110#endif
1111
1112#ifdef DOXYGEN
1137void will_return_double(#function, double value);
1138#else
1139#define will_return_double(function, value) \
1140 _will_return(#function, \
1141 __FILE__, \
1142 __LINE__, \
1143 "double", \
1144 assign_double_to_cmocka_value(value), \
1145 1)
1146#endif
1147
1148#ifdef DOXYGEN
1182void will_return_double_count(#function, double value, int count);
1183#else
1184#define will_return_double_count(function, value, count) \
1185 _will_return(#function, \
1186 __FILE__, \
1187 __LINE__, \
1188 "double", \
1189 assign_double_to_cmocka_value(value), \
1190 count)
1191#endif
1192
1193#ifdef DOXYGEN
1209void will_return_int_always(#function, intmax_t value);
1210#else
1211#define will_return_int_always(function, value) \
1212 will_return_int_count(function, (value), WILL_RETURN_ALWAYS)
1213#endif
1214
1215#ifdef DOXYGEN
1232void will_return_uint_always(#function, uintmax_t value);
1233#else
1234#define will_return_uint_always(function, value) \
1235 will_return_uint_count(function, (value), WILL_RETURN_ALWAYS)
1236#endif
1237
1238#ifdef DOXYGEN
1254void will_return_float_always(#function, float value);
1255#else
1256#define will_return_float_always(function, value) \
1257 will_return_float_count(function, (value), WILL_RETURN_ALWAYS)
1258#endif
1259
1260#ifdef DOXYGEN
1276void will_return_double_always(#function, double value);
1277#else
1278#define will_return_double_always(function, value) \
1279 will_return_double_count(function, (value), WILL_RETURN_ALWAYS)
1280#endif
1281
1282#ifdef DOXYGEN
1286void will_return_count(#function, uintmax_t value, int count);
1287#else
1288#define will_return_count(function, value, count) \
1289 do { \
1290 CMOCKA_DEPRECATION_WARNING( \
1291 "will_return_count: use will_return_int_count or " \
1292 "will_return_uint_count instead") \
1293 _will_return(cmocka_tostring(function), \
1294 __FILE__, \
1295 __LINE__, \
1296 NULL, \
1297 cast_int_to_cmocka_value(value), \
1298 count); \
1299 } while (0)
1300#endif
1301
1302#ifdef DOXYGEN
1306void will_return_always(#function, uintmax_t value);
1307#else
1308#define will_return_always(function, value) \
1309 do { \
1310 CMOCKA_DEPRECATION_WARNING( \
1311 "will_return_always: use will_return_int_always or " \
1312 "will_return_uint_always instead") \
1313 will_return_count(function, (value), WILL_RETURN_ALWAYS); \
1314 } while (0)
1315#endif
1316
1317#ifdef DOXYGEN
1339void will_return_int_maybe(#function, intmax_t value);
1340#else
1341#define will_return_int_maybe(function, value) \
1342 will_return_int_count(function, (value), WILL_RETURN_ONCE)
1343#endif
1344
1345#ifdef DOXYGEN
1368void will_return_uint_maybe(#function, uintmax_t value);
1369#else
1370#define will_return_uint_maybe(function, value) \
1371 will_return_uint_count(function, (value), WILL_RETURN_ONCE)
1372#endif
1373
1374#ifdef DOXYGEN
1396void will_return_float_maybe(#function, float value);
1397#else
1398#define will_return_float_maybe(function, value) \
1399 will_return_float_count(function, (value), WILL_RETURN_ONCE)
1400#endif
1401
1402#ifdef DOXYGEN
1424void will_return_double_maybe(#function, double value);
1425#else
1426#define will_return_double_maybe(function, value) \
1427 will_return_double_count(function, (value), WILL_RETURN_ONCE)
1428#endif
1429
1430#ifdef DOXYGEN
1434void will_return_maybe(#function, uintmax_t value);
1435#else
1436#define will_return_maybe(function, value) \
1437 do { \
1438 CMOCKA_DEPRECATION_WARNING( \
1439 "will_return_maybe: use will_return_int_maybe or " \
1440 "will_return_uint_maybe instead") \
1441 will_return_count(function, (value), WILL_RETURN_ONCE); \
1442 } while (0)
1443#endif
1444
1445#ifdef DOXYGEN
1470void will_return_ptr(#function, void *value);
1471#else
1472#define will_return_ptr(function, value) \
1473 _will_return(#function, \
1474 __FILE__, \
1475 __LINE__, \
1476 NULL, \
1477 cast_ptr_to_cmocka_value(value), \
1478 1)
1479#endif
1480
1481#ifdef DOXYGEN
1510void will_return_ptr_type(#function, void *value, type);
1511#else
1512#define will_return_ptr_type(function, value, type) \
1513 _will_return(#function, \
1514 __FILE__, \
1515 __LINE__, \
1516 #type, \
1517 cast_ptr_to_cmocka_value(value), \
1518 1)
1519#endif
1520
1521#ifdef DOXYGEN
1537void will_return_ptr_count(#function, void *value, int count);
1538#else
1539#define will_return_ptr_count(function, value, count) \
1540 _will_return(#function, \
1541 __FILE__, \
1542 __LINE__, \
1543 NULL, \
1544 cast_ptr_to_cmocka_value(value), \
1545 count)
1546#endif
1547
1548#ifdef DOXYGEN
1564void will_return_ptr_always(#function, void *value);
1565#else
1566#define will_return_ptr_always(function, value) \
1567 will_return_ptr_count(function, (value), WILL_RETURN_ALWAYS)
1568#endif
1569
1570#ifdef DOXYGEN
1592void will_return_ptr_maybe(#function, void *value);
1593#else
1594#define will_return_ptr_maybe(function, value) \
1595 will_return_ptr_count(function, (value), WILL_RETURN_ONCE)
1596#endif
1597
1598#ifdef DOXYGEN
1643void will_set_parameter(#function, #name, uintmax_t value);
1644#else
1645#define will_set_parameter(function, name, value) \
1646 _will_set_parameter(cmocka_tostring(function), \
1647 #name, \
1648 __FILE__, \
1649 __LINE__, \
1650 NULL, \
1651 cast_int_to_cmocka_value(value), \
1652 1)
1653#endif
1654
1655#ifdef DOXYGEN
1687void will_set_parameter_int(#function, #name, intmax_t value);
1688#else
1689#define will_set_parameter_int(function, name, value) \
1690 _will_set_parameter(#function, \
1691 #name, \
1692 __FILE__, \
1693 __LINE__, \
1694 "intmax_t", \
1695 assign_int_to_cmocka_value(value), \
1696 1)
1697#endif
1698
1699#ifdef DOXYGEN
1733void will_set_parameter_uint(#function, #name, uintmax_t value);
1734#else
1735#define will_set_parameter_uint(function, name, value) \
1736 _will_set_parameter(#function, \
1737 #name, \
1738 __FILE__, \
1739 __LINE__, \
1740 "uintmax_t", \
1741 assign_uint_to_cmocka_value(value), \
1742 1)
1743#endif
1744
1745#ifdef DOXYGEN
1778void will_set_parameter_float(#function, #name, float value);
1779#else
1780#define will_set_parameter_float(function, name, value) \
1781 _will_set_parameter(#function, \
1782 #name, \
1783 __FILE__, \
1784 __LINE__, \
1785 "float", \
1786 assign_float_to_cmocka_value(value), \
1787 1)
1788#endif
1789
1790#ifdef DOXYGEN
1824void will_set_parameter_double(#function, #name, double value);
1825#else
1826#define will_set_parameter_double(function, name, value) \
1827 _will_set_parameter(#function, \
1828 #name, \
1829 __FILE__, \
1830 __LINE__, \
1831 "double", \
1832 assign_double_to_cmocka_value(value), \
1833 1)
1834#endif
1835
1836#ifdef DOXYGEN
1856void will_set_parameter_int_count(#function, #name, intmax_t value, int count);
1857#else
1858#define will_set_parameter_int_count(function, name, value, count) \
1859 _will_set_parameter(#function, \
1860 #name, \
1861 __FILE__, \
1862 __LINE__, \
1863 "intmax_t", \
1864 assign_int_to_cmocka_value(value), \
1865 count)
1866#endif
1867
1868#ifdef DOXYGEN
1889 #name,
1890 uintmax_t value,
1891 int count);
1892#else
1893#define will_set_parameter_uint_count(function, name, value, count) \
1894 _will_set_parameter(#function, \
1895 #name, \
1896 __FILE__, \
1897 __LINE__, \
1898 "uintmax_t", \
1899 assign_uint_to_cmocka_value(value), \
1900 count)
1901#endif
1902
1903#ifdef DOXYGEN
1923void will_set_parameter_float_count(#function, #name, float value, int count);
1924#else
1925#define will_set_parameter_float_count(function, name, value, count) \
1926 _will_set_parameter(#function, \
1927 #name, \
1928 __FILE__, \
1929 __LINE__, \
1930 "float", \
1931 assign_float_to_cmocka_value(value), \
1932 count)
1933#endif
1934
1935#ifdef DOXYGEN
1955void will_set_parameter_double_count(#function, #name, double value, int count);
1956#else
1957#define will_set_parameter_double_count(function, name, value, count) \
1958 _will_set_parameter(#function, \
1959 #name, \
1960 __FILE__, \
1961 __LINE__, \
1962 "double", \
1963 assign_double_to_cmocka_value(value), \
1964 count)
1965#endif
1966
1967#ifdef DOXYGEN
1972void will_set_parameter_count(#function, #name, uintmax_t value, int count);
1973#else
1974#define will_set_parameter_count(function, name, value, count) \
1975 do { \
1976 CMOCKA_DEPRECATION_WARNING( \
1977 "will_set_parameter_count: use will_set_parameter_int_count or " \
1978 "will_set_parameter_uint_count instead") \
1979 _will_set_parameter(cmocka_tostring(function), \
1980 #name, \
1981 __FILE__, \
1982 __LINE__, \
1983 NULL, \
1984 cast_int_to_cmocka_value(value), \
1985 count); \
1986 } while (0)
1987#endif
1988
1989#ifdef DOXYGEN
2009void will_set_parameter_int_always(#function, #name, intmax_t value);
2010#else
2011#define will_set_parameter_int_always(function, name, value) \
2012 will_set_parameter_int_count(function, name, (value), WILL_RETURN_ALWAYS)
2013#endif
2014
2015#ifdef DOXYGEN
2035void will_set_parameter_uint_always(#function, #name, uintmax_t value);
2036#else
2037#define will_set_parameter_uint_always(function, name, value) \
2038 will_set_parameter_uint_count(function, name, (value), WILL_RETURN_ALWAYS)
2039#endif
2040
2041#ifdef DOXYGEN
2061void will_set_parameter_float_always(#function, #name, float value);
2062#else
2063#define will_set_parameter_float_always(function, name, value) \
2064 will_set_parameter_float_count(function, name, (value), WILL_RETURN_ALWAYS)
2065#endif
2066
2067#ifdef DOXYGEN
2087void will_set_parameter_double_always(#function, #name, double value);
2088#else
2089#define will_set_parameter_double_always(function, name, value) \
2090 will_set_parameter_double_count(function, name, (value), WILL_RETURN_ALWAYS)
2091#endif
2092
2093#ifdef DOXYGEN
2098void will_set_parameter_always(#function, #name, uintmax_t value);
2099#else
2100#define will_set_parameter_always(function, name, value) \
2101 do { \
2102 CMOCKA_DEPRECATION_WARNING( \
2103 "will_set_parameter_always: use will_set_parameter_int_always or " \
2104 "will_set_parameter_uint_always instead") \
2105 will_set_parameter_count(function, name, (value), WILL_RETURN_ALWAYS); \
2106 } while (0)
2107#endif
2108
2109#ifdef DOXYGEN
2130void will_set_parameter_int_maybe(#function, #name, intmax_t value);
2131#else
2132#define will_set_parameter_int_maybe(function, name, value) \
2133 will_set_parameter_int_count(function, name, (value), WILL_RETURN_ONCE)
2134#endif
2135
2136#ifdef DOXYGEN
2157void will_set_parameter_uint_maybe(#function, #name, uintmax_t value);
2158#else
2159#define will_set_parameter_uint_maybe(function, name, value) \
2160 will_set_parameter_uint_count(function, name, (value), WILL_RETURN_ONCE)
2161#endif
2162
2163#ifdef DOXYGEN
2184void will_set_parameter_float_maybe(#function, #name, float value);
2185#else
2186#define will_set_parameter_float_maybe(function, name, value) \
2187 will_set_parameter_float_count(function, name, (value), WILL_RETURN_ONCE)
2188#endif
2189
2190#ifdef DOXYGEN
2211void will_set_parameter_double_maybe(#function, #name, double value);
2212#else
2213#define will_set_parameter_double_maybe(function, name, value) \
2214 will_set_parameter_double_count(function, name, (value), WILL_RETURN_ONCE)
2215#endif
2216
2217#ifdef DOXYGEN
2222void will_set_parameter_maybe(#function, #name, uintmax_t value);
2223#else
2224#define will_set_parameter_maybe(function, name, value) \
2225 do { \
2226 CMOCKA_DEPRECATION_WARNING( \
2227 "will_set_parameter_maybe: use will_set_parameter_int_maybe or " \
2228 "will_set_parameter_uint_maybe instead") \
2229 will_set_parameter_count(function, name, (value), WILL_RETURN_ONCE); \
2230 } while (0)
2231#endif
2232
2233#ifdef DOXYGEN
2262void will_set_parameter_ptr(#function, #name, void *value);
2263#else
2264#define will_set_parameter_ptr(function, name, value) \
2265 _will_set_parameter(#function, \
2266 #name, \
2267 __FILE__, \
2268 __LINE__, \
2269 NULL, \
2270 cast_ptr_to_cmocka_value(value), \
2271 1)
2272#endif
2273
2274#ifdef DOXYGEN
2308void will_set_parameter_ptr_type(#function, #name, void *value, #type);
2309#else
2310#define will_set_parameter_ptr_type(function, name, value, type) \
2311 _will_set_parameter(#function, \
2312 #name, \
2313 __FILE__, \
2314 __LINE__, \
2315 #type, \
2316 cast_ptr_to_cmocka_value(value), \
2317 1)
2318#endif
2319
2320#ifdef DOXYGEN
2359void will_set_parameter_ptr_count(#function, #name, void *value, int count);
2360#else
2361#define will_set_parameter_ptr_count(function, name, value, count) \
2362 _will_set_parameter(#function, \
2363 #name, \
2364 __FILE__, \
2365 __LINE__, \
2366 NULL, \
2367 cast_ptr_to_cmocka_value(value), \
2368 count)
2369#endif
2370
2371#ifdef DOXYGEN
2398void will_set_parameter_ptr_always(#function, #name, void *value);
2399#else
2400#define will_set_parameter_ptr_always(function, name, value) \
2401 will_set_parameter_ptr_count(function, name, (value), WILL_RETURN_ALWAYS)
2402#endif
2403
2404#ifdef DOXYGEN
2433void will_set_parameter_ptr_maybe(#function, #name, void *value);
2434#else
2435#define will_set_parameter_ptr_maybe(function, name, value) \
2436 will_set_parameter_ptr_count(function, name, (value), WILL_RETURN_ONCE)
2437#endif
2438
2439#ifdef DOXYGEN
2464void will_set_errno(#function, intmax_t value);
2465#else
2466#define will_set_errno(function, value) \
2467 _will_set_parameter(#function, \
2468 "/errno", \
2469 __FILE__, \
2470 __LINE__, \
2471 "errno", \
2472 assign_int_to_cmocka_value(value), \
2473 1)
2474#endif
2475
2476#ifdef DOXYGEN
2515void will_set_errno_count(#function, intmax_t value, intmax_t count);
2516#else
2517#define will_set_errno_count(function, value, count) \
2518 _will_set_parameter(#function, \
2519 "/errno", \
2520 __FILE__, \
2521 __LINE__, \
2522 "errno", \
2523 assign_int_to_cmocka_value(value), \
2524 (count))
2525#endif
2526
2527#ifdef DOXYGEN
2550void will_set_errno_always(#function, intmax_t value);
2551#else
2552#define will_set_errno_always(function, value) \
2553 will_set_errno_count(function, (value), WILL_RETURN_ALWAYS);
2554#endif
2555
2556#ifdef DOXYGEN
2579void will_set_errno_maybe(#function, intmax_t value);
2580#else
2581#define will_set_errno_maybe(function, value) \
2582 will_set_errno_count(function, (value), WILL_RETURN_ONCE);
2583#endif
2584 /* cmocka_mock */
2586
2631
2632
2633#ifdef DOXYGEN
2637void expect_check(function,
2638 parameter,
2639 CheckParameterValue check_function,
2640 const void *check_data);
2641#else
2642#define expect_check(function, parameter, check_function, check_data) \
2643 do { \
2644 CMOCKA_DEPRECATION_WARNING( \
2645 "expect_check: use expect_check_data instead") \
2646 _expect_check(cmocka_tostring(function), \
2647 cmocka_tostring(parameter), \
2648 __FILE__, \
2649 __LINE__, \
2650 check_function, \
2651 cast_to_uintmax_type(check_data), \
2652 NULL, \
2653 1); \
2654 } while (0)
2655#endif
2656
2657
2658#ifdef DOXYGEN
2663 parameter,
2664 CheckParameterValue check_function,
2665 const void *check_data,
2666 intmax_t count);
2667#else
2668#define expect_check_count( \
2669 function, parameter, check_function, check_data, count) \
2670 do { \
2671 CMOCKA_DEPRECATION_WARNING( \
2672 "expect_check_count: use expect_check_data_count instead") \
2673 _expect_check(cmocka_tostring(function), \
2674 cmocka_tostring(parameter), \
2675 __FILE__, \
2676 __LINE__, \
2677 check_function, \
2678 cast_to_uintmax_type(check_data), \
2679 NULL, \
2680 count); \
2681 } while (0)
2682#endif
2683
2684#ifdef DOXYGEN
2840void expect_check_data(function,
2841 parameter,
2842 CheckParameterValueData check_function,
2843 CMockaValueData check_data);
2844#else
2845#define expect_check_data(function, parameter, check_function, check_data) \
2846 _expect_check_data(cmocka_tostring(function), \
2847 cmocka_tostring(parameter), \
2848 __FILE__, \
2849 __LINE__, \
2850 check_function, \
2851 check_data, \
2852 NULL, \
2853 1)
2854#endif
2855
2856#ifdef DOXYGEN
2922 parameter,
2923 CheckParameterValueData check_function,
2924 CMockaValueData check_data,
2925 intmax_t count);
2926#else
2927#define expect_check_data_count(function, \
2928 parameter, \
2929 check_function, \
2930 check_data, \
2931 count) \
2932 _expect_check_data(cmocka_tostring(function), \
2933 cmocka_tostring(parameter), \
2934 __FILE__, \
2935 __LINE__, \
2936 check_function, \
2937 check_data, \
2938 NULL, \
2939 count)
2940#endif
2941
2942#ifdef DOXYGEN
2946void expect_in_set(#function, #parameter, uintmax_t value_array[]);
2947#else
2948#define expect_in_set(function, parameter, value_array) \
2949 do { \
2950 CMOCKA_DEPRECATION_WARNING("expect_in_set: use expect_int_in_set or " \
2951 "expect_uint_in_set instead") \
2952 expect_in_set_count(function, parameter, value_array, 1); \
2953 } while (0)
2954#endif
2955
2956#ifdef DOXYGEN
2971void expect_in_set(#function, #parameter, intmax_t value_array[]);
2972#else
2973#define expect_int_in_set(function, parameter, value_array) \
2974 expect_int_in_set_count(function, parameter, value_array, 1)
2975#endif
2976
2977#ifdef DOXYGEN
2992void expect_in_set(#function, #parameter, intmax_t value_array[]);
2993#else
2994#define expect_uint_in_set(function, parameter, value_array) \
2995 expect_uint_in_set_count(function, parameter, value_array, 1)
2996#endif
2997
2998#ifdef DOXYGEN
3002void expect_in_set_count(#function, #parameter, uintmax_t value_array[], intmax_t count);
3003#else
3004#define expect_in_set_count(function, parameter, value_array, count) \
3005 do { \
3006 CMOCKA_DEPRECATION_WARNING( \
3007 "expect_in_set_count: use expect_int_in_set_count or " \
3008 "expect_uint_in_set_count instead") \
3009 _expect_uint_in_set(cmocka_tostring(function), \
3010 cmocka_tostring(parameter), \
3011 __FILE__, \
3012 __LINE__, \
3013 value_array, \
3014 sizeof(value_array) / sizeof((value_array)[0]), \
3015 count); \
3016 } while (0)
3017#endif
3018
3019#ifdef DOXYGEN
3038void expect_int_in_set_count(#function, #parameter, intmax_t value_array[], intmax_t count);
3039#else
3040#define expect_int_in_set_count(function, parameter, value_array, count) \
3041 _expect_int_in_set(cmocka_tostring(function), \
3042 cmocka_tostring(parameter), \
3043 __FILE__, \
3044 __LINE__, \
3045 value_array, \
3046 sizeof(value_array) / sizeof((value_array)[0]), \
3047 count)
3048#endif
3049
3050#ifdef DOXYGEN
3069void expect_uint_in_set_count(#function, #parameter, uintmax_t value_array[], intmax_t count);
3070#else
3071#define expect_uint_in_set_count(function, parameter, value_array, count) \
3072 _expect_uint_in_set(cmocka_tostring(function), \
3073 cmocka_tostring(parameter), \
3074 __FILE__, \
3075 __LINE__, \
3076 value_array, \
3077 sizeof(value_array) / sizeof((value_array)[0]), \
3078 count)
3079#endif
3080
3081#ifdef DOXYGEN
3085void expect_not_in_set(#function, #parameter, uintmax_t value_array[]);
3086#else
3087#define expect_not_in_set(function, parameter, value_array) \
3088 do { \
3089 CMOCKA_DEPRECATION_WARNING( \
3090 "expect_not_in_set: use expect_int_not_in_set or " \
3091 "expect_uint_not_in_set instead") \
3092 expect_not_in_set_count(function, parameter, value_array, 1); \
3093 } while (0)
3094#endif
3095
3096#ifdef DOXYGEN
3100void expect_not_in_set_count(#function, #parameter, uintmax_t value_array[], intmax_t count);
3101#else
3102#define expect_not_in_set_count(function, parameter, value_array, count) \
3103 do { \
3104 CMOCKA_DEPRECATION_WARNING( \
3105 "expect_not_in_set_count: use expect_int_not_in_set_count or " \
3106 "expect_uint_not_in_set_count instead") \
3107 _expect_not_in_set(cmocka_tostring(function), \
3108 cmocka_tostring(parameter), \
3109 __FILE__, \
3110 __LINE__, \
3111 value_array, \
3112 sizeof(value_array) / sizeof((value_array)[0]), \
3113 count); \
3114 } while (0)
3115#endif
3116
3117#ifdef DOXYGEN
3132void expect_int_not_in_set(#function, #parameter, intmax_t value_array[]);
3133#else
3134#define expect_int_not_in_set(function, parameter, value_array) \
3135 expect_int_not_in_set_count(function, parameter, value_array, 1)
3136#endif
3137
3138#ifdef DOXYGEN
3158 #parameter,
3159 intmax_t value_array[],
3160 intmax_t count);
3161#else
3162#define expect_int_not_in_set_count(function, parameter, value_array, count) \
3163 _expect_int_not_in_set(cmocka_tostring(function), \
3164 cmocka_tostring(parameter), \
3165 __FILE__, \
3166 __LINE__, \
3167 value_array, \
3168 sizeof(value_array) / sizeof((value_array)[0]), \
3169 count)
3170#endif
3171
3172#ifdef DOXYGEN
3187void expect_uint_not_in_set(#function, #parameter, uintmax_t value_array[]);
3188#else
3189#define expect_uint_not_in_set(function, parameter, value_array) \
3190 expect_uint_not_in_set_count(function, parameter, value_array, 1)
3191#endif
3192
3193#ifdef DOXYGEN
3213 #parameter,
3214 uintmax_t value_array[],
3215 intmax_t count);
3216#else
3217#define expect_uint_not_in_set_count(function, parameter, value_array, count) \
3218 _expect_uint_not_in_set(cmocka_tostring(function), \
3219 cmocka_tostring(parameter), \
3220 __FILE__, \
3221 __LINE__, \
3222 value_array, \
3223 sizeof(value_array) / sizeof((value_array)[0]), \
3224 count)
3225#endif
3226
3227#ifdef DOXYGEN
3244void expect_float_in_set(#function, #parameter, double value_array[], double epsilon);
3245#else
3246#define expect_float_in_set(function, parameter, value_array, epsilon) \
3247 expect_float_in_set_count(function, parameter, value_array, epsilon, 1)
3248#endif
3249
3250#ifdef DOXYGEN
3271void expect_float_in_set_count(#function, #parameter, double value_array[], double epsilon, intmax_t count);
3272#else
3273#define expect_float_in_set_count(function, parameter, value_array, epsilon, count) \
3274 _expect_float_in_set(cmocka_tostring(function), \
3275 cmocka_tostring(parameter), \
3276 __FILE__, \
3277 __LINE__, \
3278 value_array, \
3279 sizeof(value_array) / sizeof((value_array)[0]), \
3280 epsilon, \
3281 count)
3282#endif
3283
3284#ifdef DOXYGEN
3301void expect_float_not_in_set(#function, #parameter, double value_array[], double epsilon);
3302#else
3303#define expect_float_not_in_set(function, parameter, value_array, epsilon) \
3304 expect_float_not_in_set_count(function, parameter, value_array, epsilon, 1)
3305#endif
3306
3307#ifdef DOXYGEN
3328void expect_float_not_in_set_count(#function, #parameter, double value_array[], double epsilon, intmax_t count);
3329#else
3330#define expect_float_not_in_set_count(function, parameter, value_array, epsilon, count) \
3331 _expect_float_not_in_set(cmocka_tostring(function), \
3332 cmocka_tostring(parameter), \
3333 __FILE__, \
3334 __LINE__, \
3335 value_array, \
3336 sizeof(value_array) / sizeof((value_array)[0]), \
3337 epsilon, \
3338 count)
3339#endif
3340
3341
3342#ifdef DOXYGEN
3346void expect_in_range(#function, #parameter, uintmax_t minimum, uintmax_t maximum);
3347#else
3348#define expect_in_range(function, parameter, minimum, maximum) \
3349 do { \
3350 CMOCKA_DEPRECATION_WARNING( \
3351 "expect_in_range: use expect_int_in_range or " \
3352 "expect_uint_in_range instead") \
3353 expect_in_range_count(function, parameter, minimum, maximum, 1); \
3354 } while (0)
3355#endif
3356
3357#ifdef DOXYGEN
3361void expect_in_range_count(#function, #parameter, uintmax_t minimum, uintmax_t maximum, intmax_t count);
3362#else
3363#define expect_in_range_count(function, parameter, minimum, maximum, count) \
3364 do { \
3365 CMOCKA_DEPRECATION_WARNING( \
3366 "expect_in_range_count: use expect_int_in_range_count or " \
3367 "expect_uint_in_range_count instead") \
3368 _expect_in_range(cmocka_tostring(function), \
3369 cmocka_tostring(parameter), \
3370 __FILE__, \
3371 __LINE__, \
3372 minimum, \
3373 maximum, \
3374 count); \
3375 } while (0)
3376#endif
3377
3378#ifdef DOXYGEN
3395void expect_int_in_range(#function,
3396#parameter,
3397 intmax_t minimum,
3398 intmax_t maximum);
3399#else
3400#define expect_int_in_range(function, parameter, minimum, maximum) \
3401 expect_int_in_range_count(function, parameter, minimum, maximum, 1)
3402#endif
3403
3404#ifdef DOXYGEN
3426 #parameter,
3427 intmax_t minimum,
3428 intmax_t maximum,
3429 intmax_t count);
3430#else
3431#define expect_int_in_range_count( \
3432 function, parameter, minimum, maximum, count) \
3433 _expect_int_in_range(cmocka_tostring(function), \
3434 cmocka_tostring(parameter), \
3435 __FILE__, \
3436 __LINE__, \
3437 minimum, \
3438 maximum, \
3439 count)
3440#endif
3441
3442#ifdef DOXYGEN
3460#parameter,
3461 uintmax_t minimum,
3462 uintmax_t maximum);
3463#else
3464#define expect_uint_in_range(function, parameter, minimum, maximum) \
3465 expect_uint_in_range_count(function, parameter, minimum, maximum, 1)
3466#endif
3467
3468#ifdef DOXYGEN
3491 #parameter,
3492 uintmax_t minimum,
3493 uintmax_t maximum,
3494 intmax_t count);
3495#else
3496#define expect_uint_in_range_count( \
3497 function, parameter, minimum, maximum, count) \
3498 _expect_uint_in_range(cmocka_tostring(function), \
3499 cmocka_tostring(parameter), \
3500 __FILE__, \
3501 __LINE__, \
3502 minimum, \
3503 maximum, \
3504 count)
3505#endif
3506
3507#ifdef DOXYGEN
3524void expect_not_in_range(#function, #parameter, uintmax_t minimum, uintmax_t maximum);
3525#else
3526#define expect_not_in_range(function, parameter, minimum, maximum) \
3527 expect_not_in_range_count(function, parameter, minimum, maximum, 1)
3528#endif
3529
3530#ifdef DOXYGEN
3551void expect_not_in_range_count(#function, #parameter, uintmax_t minimum, uintmax_t maximum, intmax_t count);
3552#else
3553#define expect_not_in_range_count(function, parameter, minimum, maximum, \
3554 count) \
3555 _expect_not_in_range(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
3556 minimum, maximum, count)
3557#endif
3558
3559#ifdef DOXYGEN
3577 #parameter,
3578 intmax_t minimum,
3579 intmax_t maximum);
3580#else
3581#define expect_int_not_in_range(function, parameter, minimum, maximum) \
3582 expect_int_not_in_range_count(function, parameter, minimum, maximum, 1)
3583#endif
3584
3585#ifdef DOXYGEN
3607 #parameter,
3608 intmax_t minimum,
3609 intmax_t maximum,
3610 intmax_t count);
3611#else
3612#define expect_int_not_in_range_count( \
3613 function, parameter, minimum, maximum, count) \
3614 _expect_int_not_in_range(cmocka_tostring(function), \
3615 cmocka_tostring(parameter), \
3616 __FILE__, \
3617 __LINE__, \
3618 minimum, \
3619 maximum, \
3620 count)
3621#endif
3622
3623#ifdef DOXYGEN
3641 #parameter,
3642 uintmax_t minimum,
3643 uintmax_t maximum);
3644#else
3645#define expect_uint_not_in_range(function, parameter, minimum, maximum) \
3646 expect_uint_not_in_range_count(function, parameter, minimum, maximum, 1)
3647#endif
3648
3649#ifdef DOXYGEN
3672 #parameter,
3673 uintmax_t minimum,
3674 uintmax_t maximum,
3675 intmax_t count);
3676#else
3677#define expect_uint_not_in_range_count( \
3678 function, parameter, minimum, maximum, count) \
3679 _expect_uint_not_in_range(cmocka_tostring(function), \
3680 cmocka_tostring(parameter), \
3681 __FILE__, \
3682 __LINE__, \
3683 minimum, \
3684 maximum, \
3685 count)
3686#endif
3687
3688#ifdef DOXYGEN
3707void expect_float_in_range(#function, #parameter, double minimum, double maximum, double epsilon);
3708#else
3709#define expect_float_in_range(function, parameter, minimum, maximum, epsilon) \
3710 expect_float_in_range_count(function, parameter, minimum, maximum, epsilon, 1)
3711#endif
3712
3713#ifdef DOXYGEN
3736void expect_float_in_range_count(#function, #parameter, double minimum, double maximum, double epsilon, intmax_t count);
3737#else
3738#define expect_float_in_range_count(function, parameter, minimum, maximum, epsilon, count) \
3739 _expect_float_in_range(cmocka_tostring(function), \
3740 cmocka_tostring(parameter), \
3741 __FILE__, \
3742 __LINE__, \
3743 cast_to_double_type(minimum), \
3744 cast_to_double_type(maximum), \
3745 cast_to_double_type(epsilon), \
3746 count)
3747#endif
3748
3749#ifdef DOXYGEN
3768void expect_float_not_in_range(#function, #parameter, double minimum, double maximum, double epsilon);
3769#else
3770#define expect_float_not_in_range(function, parameter, minimum, maximum, epsilon) \
3771 expect_float_not_in_range_count(function, parameter, minimum, maximum, epsilon, 1)
3772#endif
3773
3774#ifdef DOXYGEN
3797void expect_float_not_in_range_count(#function, #parameter, double minimum, double maximum, double epsilon, intmax_t count);
3798#else
3799#define expect_float_not_in_range_count(function, parameter, minimum, maximum, \
3800 epsilon, count) \
3801 _expect_float_not_in_range(cmocka_tostring(function), \
3802 cmocka_tostring(parameter), \
3803 __FILE__, \
3804 __LINE__, \
3805 cast_to_double_type(minimum), \
3806 cast_to_double_type(maximum), \
3807 cast_to_double_type(epsilon), \
3808 count)
3809#endif
3810
3811#ifdef DOXYGEN
3815void expect_value(#function, #parameter, uintmax_t value);
3816#else
3817#define expect_value(function, parameter, value) \
3818 do { \
3819 CMOCKA_DEPRECATION_WARNING("expect_value: use expect_int_value or " \
3820 "expect_uint_value instead") \
3821 expect_value_count(function, parameter, value, 1); \
3822 } while (0)
3823#endif
3824
3825#ifdef DOXYGEN
3829void expect_value_count(#function, #parameter, uintmax_t value, intmax_t count);
3830#else
3831#define expect_value_count(function, parameter, value, count) \
3832 do { \
3833 CMOCKA_DEPRECATION_WARNING( \
3834 "expect_value_count: use expect_int_value_count or " \
3835 "expect_uint_value_count instead") \
3836 _expect_value(cmocka_tostring(function), \
3837 cmocka_tostring(parameter), \
3838 __FILE__, \
3839 __LINE__, \
3840 cast_to_uintmax_type(value), \
3841 count); \
3842 } while (0)
3843#endif
3844
3845#ifdef DOXYGEN
3859void expect_int_value(#function, #parameter, intmax_t value);
3860#else
3861#define expect_int_value(function, parameter, value) \
3862 expect_int_value_count(function, parameter, value, 1)
3863#endif
3864
3865#ifdef DOXYGEN
3885 #parameter,
3886 intmax_t value,
3887 intmax_t count);
3888#else
3889#define expect_int_value_count(function, parameter, value, count) \
3890 _expect_int_value(cmocka_tostring(function), \
3891 cmocka_tostring(parameter), \
3892 __FILE__, \
3893 __LINE__, \
3894 value, \
3895 count)
3896#endif
3897
3898#ifdef DOXYGEN
3913void expect_uint_value(#function, #parameter, uintmax_t value);
3914#else
3915#define expect_uint_value(function, parameter, value) \
3916 expect_uint_value_count(function, parameter, value, 1)
3917#endif
3918
3919#ifdef DOXYGEN
3939 #parameter,
3940 uintmax_t value,
3941 intmax_t count);
3942#else
3943#define expect_uint_value_count(function, parameter, value, count) \
3944 _expect_uint_value(cmocka_tostring(function), \
3945 cmocka_tostring(parameter), \
3946 __FILE__, \
3947 __LINE__, \
3948 value, \
3949 count)
3950#endif
3951
3952#ifdef DOXYGEN
3966void expect_int_not_value(#function, #parameter, intmax_t value);
3967#else
3968#define expect_int_not_value(function, parameter, value) \
3969 expect_int_not_value_count(function, parameter, value, 1)
3970#endif
3971
3972#ifdef DOXYGEN
3992 #parameter,
3993 intmax_t value,
3994 intmax_t count);
3995#else
3996#define expect_int_not_value_count(function, parameter, value, count) \
3997 _expect_int_not_value(cmocka_tostring(function), \
3998 cmocka_tostring(parameter), \
3999 __FILE__, \
4000 __LINE__, \
4001 value, \
4002 count)
4003#endif
4004
4005#ifdef DOXYGEN
4019void expect_uint_not_value(#function, #parameter, uintmax_t value);
4020#else
4021#define expect_uint_not_value(function, parameter, value) \
4022 expect_uint_not_value_count(function, parameter, value, 1)
4023#endif
4024
4025#ifdef DOXYGEN
4045 #parameter,
4046 uintmax_t value,
4047 intmax_t count);
4048#else
4049#define expect_uint_not_value_count(function, parameter, value, count) \
4050 _expect_uint_not_value(cmocka_tostring(function), \
4051 cmocka_tostring(parameter), \
4052 __FILE__, \
4053 __LINE__, \
4054 value, \
4055 count)
4056#endif
4057
4058#ifdef DOXYGEN
4062void expect_not_value(#function, #parameter, uintmax_t value);
4063#else
4064#define expect_not_value(function, parameter, value) \
4065 do { \
4066 CMOCKA_DEPRECATION_WARNING( \
4067 "expect_not_value: use expect_int_not_value or " \
4068 "expect_uint_not_value instead") \
4069 expect_not_value_count(function, parameter, value, 1); \
4070 } while (0)
4071#endif
4072
4073#ifdef DOXYGEN
4077void expect_not_value_count(#function, #parameter, uintmax_t value, intmax_t count);
4078#else
4079#define expect_not_value_count(function, parameter, value, count) \
4080 do { \
4081 CMOCKA_DEPRECATION_WARNING( \
4082 "expect_not_value_count: use expect_int_not_value_count or " \
4083 "expect_uint_not_value_count instead") \
4084 _expect_not_value(cmocka_tostring(function), \
4085 cmocka_tostring(parameter), \
4086 __FILE__, \
4087 __LINE__, \
4088 cast_to_uintmax_type(value), \
4089 count); \
4090 } while (0)
4091#endif
4092
4093#ifdef DOXYGEN
4112void expect_float(#function, #parameter, double value, double epsilon);
4113#else
4114#define expect_float(function, parameter, value, epsilon) \
4115 expect_float_count(function, parameter, cast_to_double_type(value), \
4116 cast_to_double_type(epsilon), 1)
4117#endif
4118
4119#ifdef DOXYGEN
4142void expect_float_count(#function, #parameter, double value, double epsilon, intmax_t count);
4143#else
4144#define expect_float_count(function, parameter, value, epsilon, count) \
4145 _expect_float(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4146 cast_to_double_type(value), cast_to_double_type(epsilon), count)
4147#endif
4148
4149#ifdef DOXYGEN
4169void expect_not_float(#function, #parameter, double value, double epsilon);
4170#else
4171#define expect_not_float(function, parameter, value, epsilon) \
4172 expect_not_float_count(function, \
4173 parameter, \
4174 cast_to_float_type(value), \
4175 cast_to_float_type(epsilon), \
4176 1)
4177#endif
4178
4179#ifdef DOXYGEN
4202void expect_not_float_count(#function, #parameter, double value, double epsilon, intmax_t count);
4203#else
4204#define expect_not_float_count(function, parameter, value, epsilon, count) \
4205 _expect_not_float(cmocka_tostring(function), \
4206 cmocka_tostring(parameter), \
4207 __FILE__, \
4208 __LINE__, \
4209 cast_to_float_type(value), \
4210 cast_to_float_type(epsilon), \
4211 count)
4212#endif
4213
4214#ifdef DOXYGEN
4232void expect_double(#function, #parameter, double value, double epsilon);
4233#else
4234#define expect_double(function, parameter, value, epsilon) \
4235 expect_double_count(function, \
4236 parameter, \
4237 cast_to_double_type(value), \
4238 cast_to_double_type(epsilon), \
4239 1)
4240#endif
4241
4242#ifdef DOXYGEN
4264void expect_double_count(#function,
4265 #parameter,
4266 double value,
4267 double epsilon,
4268 intmax_t count);
4269#else
4270#define expect_double_count(function, parameter, value, epsilon, count) \
4271 _expect_double(cmocka_tostring(function), \
4272 cmocka_tostring(parameter), \
4273 __FILE__, \
4274 __LINE__, \
4275 cast_to_double_type(value), \
4276 cast_to_double_type(epsilon), \
4277 count)
4278#endif
4279
4280#ifdef DOXYGEN
4298void expect_not_double(#function, #parameter, double value, double epsilon);
4299#else
4300#define expect_not_double(function, parameter, value, epsilon) \
4301 expect_not_double_count(function, \
4302 parameter, \
4303 cast_to_double_type(value), \
4304 cast_to_double_type(epsilon), \
4305 1)
4306#endif
4307
4308#ifdef DOXYGEN
4331 #parameter,
4332 double value,
4333 double epsilon,
4334 intmax_t count);
4335#else
4336#define expect_not_double_count(function, parameter, value, epsilon, count) \
4337 _expect_not_double(cmocka_tostring(function), \
4338 cmocka_tostring(parameter), \
4339 __FILE__, \
4340 __LINE__, \
4341 cast_to_double_type(value), \
4342 cast_to_double_type(epsilon), \
4343 count)
4344#endif
4345
4346#ifdef DOXYGEN
4361void expect_string(#function, #parameter, const char *string);
4362#else
4363#define expect_string(function, parameter, string) \
4364 expect_string_count(function, parameter, string, 1)
4365#endif
4366
4367#ifdef DOXYGEN
4386void expect_string_count(#function, #parameter, const char *string, intmax_t count);
4387#else
4388#define expect_string_count(function, parameter, string, count) \
4389 _expect_string(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4390 (const char*)(string), count)
4391#endif
4392
4393#ifdef DOXYGEN
4408void expect_not_string(#function, #parameter, const char *string);
4409#else
4410#define expect_not_string(function, parameter, string) \
4411 expect_not_string_count(function, parameter, string, 1)
4412#endif
4413
4414#ifdef DOXYGEN
4433void expect_not_string_count(#function, #parameter, const char *string, intmax_t count);
4434#else
4435#define expect_not_string_count(function, parameter, string, count) \
4436 _expect_not_string(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4437 (const char*)(string), count)
4438#endif
4439
4440#ifdef DOXYGEN
4456void expect_memory(#function, #parameter, void *memory, size_t size);
4457#else
4458#define expect_memory(function, parameter, memory, size) \
4459 expect_memory_count(function, parameter, memory, size, 1)
4460#endif
4461
4462#ifdef DOXYGEN
4483void expect_memory_count(#function, #parameter, void *memory, size_t size, intmax_t count);
4484#else
4485#define expect_memory_count(function, parameter, memory, size, count) \
4486 _expect_memory(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4487 (const void*)(memory), size, count)
4488#endif
4489
4490#ifdef DOXYGEN
4507void expect_not_memory(#function, #parameter, void *memory, size_t size);
4508#else
4509#define expect_not_memory(function, parameter, memory, size) \
4510 expect_not_memory_count(function, parameter, memory, size, 1)
4511#endif
4512
4513#ifdef DOXYGEN
4534void expect_not_memory_count(#function, #parameter, void *memory, size_t size, intmax_t count);
4535#else
4536#define expect_not_memory_count(function, parameter, memory, size, count) \
4537 _expect_not_memory(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4538 (const void*)(memory), size, count)
4539#endif
4540
4541
4542#ifdef DOXYGEN
4554void expect_any(#function, #parameter);
4555#else
4556#define expect_any(function, parameter) \
4557 expect_any_count(function, parameter, 1)
4558#endif
4559
4560#ifdef DOXYGEN
4572void expect_any_always(#function, #parameter);
4573#else
4574#define expect_any_always(function, parameter) \
4575 expect_any_count(function, parameter, WILL_RETURN_ALWAYS)
4576#endif
4577
4578#ifdef DOXYGEN
4595void expect_any_count(#function, #parameter, intmax_t count);
4596#else
4597#define expect_any_count(function, parameter, count) \
4598 _expect_any(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, count)
4599#endif
4600
4601#ifdef DOXYGEN
4606void check_expected(#parameter);
4607#else
4608#define check_expected(parameter) \
4609 do { \
4610 CMOCKA_DEPRECATION_WARNING( \
4611 "check_expected: use check_expected_int or " \
4612 "check_expected_uint instead") \
4613 _check_expected(__func__, \
4614 #parameter, \
4615 __FILE__, \
4616 __LINE__, \
4617 cast_int_to_cmocka_value(parameter)); \
4618 } while (0)
4619#endif
4620
4621#ifdef DOXYGEN
4649void check_expected_any(#parameter);
4650#else
4651#define check_expected_any(parameter) \
4652 _check_expected(__func__, #parameter, __FILE__, __LINE__, \
4653 cast_ptr_to_cmocka_value(&(parameter)))
4654#endif
4655
4656#ifdef DOXYGEN
4667void check_expected_ptr(#parameter);
4668#else
4669#define check_expected_ptr(parameter) \
4670 _check_expected(__func__, #parameter, __FILE__, __LINE__, \
4671 cast_ptr_to_cmocka_value(parameter))
4672#endif
4673
4674#ifdef DOXYGEN
4685void check_expected_int(#parameter);
4686#else
4687#define check_expected_int(parameter) \
4688 _check_expected(__func__, \
4689 #parameter, \
4690 __FILE__, \
4691 __LINE__, \
4692 assign_int_to_cmocka_value(parameter))
4693#endif
4694
4695#ifdef DOXYGEN
4706void check_expected_uint(#parameter);
4707#else
4708#define check_expected_uint(parameter) \
4709 _check_expected(__func__, \
4710 #parameter, \
4711 __FILE__, \
4712 __LINE__, \
4713 assign_uint_to_cmocka_value(parameter))
4714#endif
4715
4716#ifdef DOXYGEN
4732void check_expected_float(#parameter);
4733#else
4734#define check_expected_float(parameter) \
4735 _check_expected(__func__, \
4736 #parameter, \
4737 __FILE__, \
4738 __LINE__, \
4739 assign_float_to_cmocka_value(parameter))
4740#endif
4741
4742#ifdef DOXYGEN
4758void check_expected_double(#parameter);
4759#else
4760#define check_expected_double(parameter) \
4761 _check_expected(__func__, \
4762 #parameter, \
4763 __FILE__, \
4764 __LINE__, \
4765 assign_double_to_cmocka_value(parameter))
4766#endif
4767 /* cmocka_param */
4769
4792
4793#ifdef DOXYGEN
4806void assert_true(scalar expression);
4807#else
4808#define assert_true(c) _assert_true(cast_to_uintmax_type(c), #c, \
4809 __FILE__, __LINE__)
4810#endif
4811
4812#ifdef DOXYGEN
4824void assert_false(scalar expression);
4825#else
4826#define assert_false(c) _assert_false(cast_to_uintmax_type(c), #c, \
4827 __FILE__, __LINE__)
4828#endif
4829
4830#ifdef DOXYGEN
4843void assert_return_code(intmax_t rc, int32_t error);
4844#else
4845#define assert_return_code(rc, error) \
4846 _assert_return_code((rc), \
4847 (error), \
4848 #rc, __FILE__, __LINE__)
4849#endif
4850
4851#ifdef DOXYGEN
4862void assert_non_null(void *pointer);
4863#else
4864#define assert_non_null(c) assert_ptr_not_equal((c), NULL)
4865#endif
4866
4867#ifdef DOXYGEN
4880void assert_non_null_msg(void *pointer, const char *const message);
4881#else
4882#define assert_non_null_msg(c, msg) assert_ptr_not_equal_msg((c), NULL, (msg))
4883#endif
4884
4885#ifdef DOXYGEN
4896void assert_null(void *pointer);
4897#else
4898#define assert_null(c) assert_ptr_equal((c), NULL)
4899#endif
4900
4901#ifdef DOXYGEN
4914void assert_null_msg(void *pointer, const char *const message);
4915#else
4916#define assert_null_msg(c, msg) assert_ptr_equal_msg((c), NULL, (msg))
4917#endif
4918
4919#ifdef DOXYGEN
4930void assert_ptr_equal(void *a, void *b);
4931#else
4932#define assert_ptr_equal(a, b) assert_ptr_equal_msg((a), (b), NULL)
4933#endif
4934
4935#ifdef DOXYGEN
4948void assert_ptr_equal_msg(void *a, void *b, const char *const msg);
4949#else
4950#define assert_ptr_equal_msg(a, b, msg) \
4951 _assert_ptr_equal_msg(cast_to_void_pointer(a), \
4952 cast_to_void_pointer(b), \
4953 __FILE__, __LINE__, (msg))
4954#endif
4955
4956#ifdef DOXYGEN
4967void assert_ptr_not_equal(void *a, void *b);
4968#else
4969#define assert_ptr_not_equal(a, b) \
4970 assert_ptr_not_equal_msg((a), (b), NULL)
4971#endif
4972
4973#ifdef DOXYGEN
4986void assert_ptr_not_equal_msg(void *a, void *b, const char *const msg);
4987#else /* DOXYGEN */
4988
4989#if defined(__has_builtin)
4990
4991#if __has_builtin(__builtin_unreachable)
4992#define assert_ptr_not_equal_msg(a, b, msg) \
4993 do { \
4994 const void *cmocka_p1 = cast_to_void_pointer(a), \
4995 *cmocka_p2 = cast_to_void_pointer(b); \
4996 _assert_ptr_not_equal_msg( \
4997 cmocka_p1, cmocka_p2, __FILE__, __LINE__, (msg)); \
4998 if (cmocka_p1 == cmocka_p2) { \
4999 __builtin_unreachable(); \
5000 } \
5001 } while (0)
5002#else /* __has_builtin(__builtin_unreachable) */
5003#define assert_ptr_not_equal_msg(a, b, msg) \
5004_assert_ptr_not_equal_msg(cast_to_void_pointer(a), \
5005 cast_to_void_pointer(b), \
5006 __FILE__, \
5007 __LINE__, \
5008 (msg))
5009#endif /* __has_builtin(__builtin_unreachable) */
5010
5011#else /* defined(__has_builtin) */
5012#define assert_ptr_not_equal_msg(a, b, msg) \
5013_assert_ptr_not_equal_msg(cast_to_void_pointer(a), \
5014 cast_to_void_pointer(b), \
5015 __FILE__, \
5016 __LINE__, \
5017 (msg))
5018#endif /* __has_builtin(__builtin_unreachable) */
5019
5020#endif /* DOXYGEN */
5021
5022#ifdef DOXYGEN
5033void assert_int_equal(intmax_t a, intmax_t b);
5034#else
5035#define assert_int_equal(a, b) \
5036 _assert_int_equal(cast_to_intmax_type(a), \
5037 cast_to_intmax_type(b), \
5038 __FILE__, __LINE__)
5039#endif
5040
5041#ifdef DOXYGEN
5052void assert_uint_equal(uintmax_t a, uintmax_t b);
5053#else
5054#define assert_uint_equal(a, b) \
5055 _assert_uint_equal(cast_to_uintmax_type(a), \
5056 cast_to_uintmax_type(b), \
5057 __FILE__, __LINE__)
5058#endif
5059
5060#ifdef DOXYGEN
5073void assert_int_not_equal(intmax_t a, intmax_t b);
5074#else
5075#define assert_int_not_equal(a, b) \
5076 _assert_int_not_equal(cast_to_intmax_type(a), \
5077 cast_to_intmax_type(b), \
5078 __FILE__, __LINE__)
5079#endif
5080
5081#ifdef DOXYGEN
5092void assert_uint_not_equal(uintmax_t a, uintmax_t b);
5093#else
5094#define assert_uint_not_equal(a, b) \
5095 _assert_uint_not_equal(cast_to_uintmax_type(a), \
5096 cast_to_uintmax_type(b), \
5097 __FILE__, __LINE__)
5098#endif
5099
5100#ifdef DOXYGEN
5113void assert_float_equal(float a, float b, float epsilon);
5114#else
5115#define assert_float_equal(a, b, epsilon) \
5116 _assert_float_equal((float)a, \
5117 (float)b, \
5118 (float)epsilon, \
5119 __FILE__, __LINE__)
5120#endif
5121
5122#ifdef DOXYGEN
5135void assert_float_not_equal(float a, float b, float epsilon);
5136#else
5137#define assert_float_not_equal(a, b, epsilon) \
5138 _assert_float_not_equal((float)a, \
5139 (float)b, \
5140 (float)epsilon, \
5141 __FILE__, __LINE__)
5142#endif
5143
5144#ifdef DOXYGEN
5157void assert_double_equal(double a, double b, double epsilon);
5158#else
5159#define assert_double_equal(a, b, epsilon) \
5160 _assert_double_equal((double)a, \
5161 (double)b, \
5162 (double)epsilon, \
5163 __FILE__, __LINE__)
5164#endif
5165
5166#ifdef DOXYGEN
5179void assert_double_not_equal(double a, double b, double epsilon);
5180#else
5181#define assert_double_not_equal(a, b, epsilon) \
5182 _assert_double_not_equal((double)a, \
5183 (double)b, \
5184 (double)epsilon, \
5185 __FILE__, __LINE__)
5186#endif
5187
5188
5189#ifdef DOXYGEN
5202void assert_string_equal(const char *a, const char *b);
5203#else
5204#define assert_string_equal(a, b) \
5205 _assert_string_equal((a), (b), __FILE__, __LINE__)
5206#endif
5207
5208#ifdef DOXYGEN
5221void assert_string_not_equal(const char *a, const char *b);
5222#else
5223#define assert_string_not_equal(a, b) \
5224 _assert_string_not_equal((a), (b), __FILE__, __LINE__)
5225#endif
5226
5227#ifdef DOXYGEN
5242void assert_memory_equal(const void *a, const void *b, size_t size);
5243#else
5244#define assert_memory_equal(a, b, size) \
5245 _assert_memory_equal((const void*)(a), (const void*)(b), size, __FILE__, \
5246 __LINE__)
5247#endif
5248
5249#ifdef DOXYGEN
5264void assert_memory_not_equal(const void *a, const void *b, size_t size);
5265#else
5266#define assert_memory_not_equal(a, b, size) \
5267 _assert_memory_not_equal((const void*)(a), (const void*)(b), size, \
5268 __FILE__, __LINE__)
5269#endif
5270
5271#ifdef DOXYGEN
5285void assert_int_in_range(intmax_t value, intmax_t minimum, intmax_t maximum);
5286#else
5287#define assert_int_in_range(value, minimum, maximum) \
5288 _assert_int_in_range( \
5289 cast_to_intmax_type(value), \
5290 cast_to_intmax_type(minimum), \
5291 cast_to_intmax_type(maximum), __FILE__, __LINE__)
5292#endif
5293
5294#ifdef DOXYGEN
5308void assert_uint_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum);
5309#else
5310#define assert_uint_in_range(value, minimum, maximum) \
5311 _assert_uint_in_range( \
5312 cast_to_uintmax_type(value), \
5313 cast_to_uintmax_type(minimum), \
5314 cast_to_uintmax_type(maximum), __FILE__, __LINE__)
5315#endif
5316
5317#ifdef DOXYGEN
5334void assert_int_not_in_range(intmax_t value,
5335 intmax_t minimum,
5336 intmax_t maximum);
5337#else
5338#define assert_int_not_in_range(value, minimum, maximum) \
5339 _assert_int_not_in_range(cast_to_intmax_type(value), \
5340 cast_to_intmax_type(minimum), \
5341 cast_to_intmax_type(maximum), \
5342 __FILE__, \
5343 __LINE__)
5344#endif
5345
5346#ifdef DOXYGEN
5363void assert_uint_not_in_range(uintmax_t value,
5364 uintmax_t minimum,
5365 uintmax_t maximum);
5366#else
5367#define assert_uint_not_in_range(value, minimum, maximum) \
5368 _assert_uint_not_in_range(cast_to_uintmax_type(value), \
5369 cast_to_uintmax_type(minimum), \
5370 cast_to_uintmax_type(maximum), \
5371 __FILE__, \
5372 __LINE__)
5373#endif
5374
5375#ifdef DOXYGEN
5379void assert_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum);
5380#else
5381#define assert_in_range(value, minimum, maximum) \
5382 do { \
5383 CMOCKA_DEPRECATION_WARNING( \
5384 "assert_in_range: use assert_int_in_range or " \
5385 "assert_uint_in_range instead") \
5386 _assert_uint_in_range(cast_to_uintmax_type(value), \
5387 cast_to_uintmax_type(minimum), \
5388 cast_to_uintmax_type(maximum), \
5389 __FILE__, \
5390 __LINE__); \
5391 } while (0)
5392#endif
5393
5394#ifdef DOXYGEN
5398void assert_not_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum);
5399#else
5400#define assert_not_in_range(value, minimum, maximum) \
5401 do { \
5402 CMOCKA_DEPRECATION_WARNING( \
5403 "assert_not_in_range: use assert_int_not_in_range or " \
5404 "assert_uint_not_in_range instead") \
5405 _assert_uint_not_in_range(cast_to_uintmax_type(value), \
5406 cast_to_uintmax_type(minimum), \
5407 cast_to_uintmax_type(maximum), \
5408 __FILE__, \
5409 __LINE__); \
5410 } while (0)
5411#endif
5412
5413#ifdef DOXYGEN
5432void assert_float_not_in_range(double value, double minimum, double maximum, double epsilon);
5433#else
5434#define assert_float_not_in_range(value, minimum, maximum, epsilon) \
5435 _assert_float_not_in_range(cast_to_double_type(value), \
5436 cast_to_double_type(minimum), \
5437 cast_to_double_type(maximum), \
5438 cast_to_double_type(epsilon), \
5439 __FILE__, \
5440 __LINE__)
5441#endif
5442
5443#ifdef DOXYGEN
5459void assert_float_in_range(double value, double minimum, double maximum, double epsilon);
5460#else
5461#define assert_float_in_range(value, minimum, maximum, epsilon) \
5462 _assert_float_in_range( \
5463 cast_to_double_type(value), \
5464 cast_to_double_type(minimum), \
5465 cast_to_double_type(maximum), \
5466 cast_to_double_type(epsilon), __FILE__, __LINE__)
5467#endif
5468
5469#ifdef DOXYGEN
5473void assert_in_set(uintmax_t value, uintmax_t values[], intmax_t count);
5474#else
5475#define assert_in_set(value, values, number_of_values) \
5476 do { \
5477 CMOCKA_DEPRECATION_WARNING("assert_in_set: use assert_int_in_set or " \
5478 "assert_uint_in_set instead") \
5479 _assert_uint_in_set( \
5480 value, values, number_of_values, __FILE__, __LINE__); \
5481 } while (0)
5482#endif
5483
5484#ifdef DOXYGEN
5497void assert_not_in_set(uintmax_t value, uintmax_t values[], intmax_t count);
5498#else
5499#define assert_not_in_set(value, values, number_of_values) \
5500 _assert_not_in_set(value, values, number_of_values, __FILE__, __LINE__)
5501#endif
5502
5503#ifdef DOXYGEN
5516void assert_int_in_set(intmax_t value, intmax_t values[], intmax_t count);
5517#else
5518#define assert_int_in_set(value, values, number_of_values) \
5519 if (number_of_values > 0) { \
5520 intmax_t _cmocka_set[number_of_values]; \
5521 for (size_t _i = 0; _i < number_of_values; _i++) { \
5522 _cmocka_set[_i] = values[_i]; \
5523 } \
5524 _assert_int_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5525 }
5526#endif
5527
5528#ifdef DOXYGEN
5541void assert_int_not_in_set(intmax_t value, intmax_t values[], intmax_t count);
5542#else
5543#define assert_int_not_in_set(value, values, number_of_values) \
5544 if (number_of_values > 0) { \
5545 intmax_t _cmocka_set[number_of_values]; \
5546 for (size_t _i = 0; _i < number_of_values; _i++) { \
5547 _cmocka_set[_i] = values[_i]; \
5548 } \
5549 _assert_int_not_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5550 }
5551#endif
5552
5553#ifdef DOXYGEN
5566void assert_uint_in_set(uintmax_t value, uintmax_t values[], intmax_t count);
5567#else
5568#define assert_uint_in_set(value, values, number_of_values) \
5569 if (number_of_values > 0) { \
5570 uintmax_t _cmocka_set[number_of_values]; \
5571 for (size_t _i = 0; _i < number_of_values; _i++) { \
5572 _cmocka_set[_i] = values[_i]; \
5573 } \
5574 _assert_uint_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5575 }
5576#endif
5577
5578#ifdef DOXYGEN
5591void assert_uint_not_in_set(uintmax_t value, uintmax_t values[], intmax_t count);
5592#else
5593#define assert_uint_not_in_set(value, values, number_of_values) \
5594 if (number_of_values > 0) { \
5595 uintmax_t _cmocka_set[number_of_values]; \
5596 for (size_t _i = 0; _i < number_of_values; _i++) { \
5597 _cmocka_set[_i] = values[_i]; \
5598 } \
5599 _assert_uint_not_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5600 }
5601#endif
5602
5603#ifdef DOXYGEN
5618void assert_float_in_set(double value, double values[], intmax_t count, double epsilon);
5619#else
5620#define assert_float_in_set(value, values, number_of_values, epsilon) \
5621 if (number_of_values > 0) { \
5622 double _cmocka_set[number_of_values]; \
5623 for (size_t _i = 0; _i < number_of_values; _i++) { \
5624 _cmocka_set[_i] = values[_i]; \
5625 } \
5626 _assert_float_in_set(value, _cmocka_set, number_of_values, epsilon, __FILE__, __LINE__); \
5627 }
5628#endif
5629
5630#ifdef DOXYGEN
5645void assert_float_not_in_set(double value, double values[], intmax_t count, double epsilon);
5646#else
5647#define assert_float_not_in_set(value, values, number_of_values, epsilon) \
5648 if (number_of_values > 0) { \
5649 double _cmocka_set[number_of_values]; \
5650 for (size_t _i = 0; _i < number_of_values; _i++) { \
5651 _cmocka_set[_i] = values[_i]; \
5652 } \
5653 _assert_float_not_in_set(value, _cmocka_set, number_of_values, epsilon, __FILE__, __LINE__); \
5654 }
5655#endif
5656 /* cmocka_asserts */
5658
5722
5723#ifdef DOXYGEN
5731#else
5732#define function_called() _function_called(__func__, __FILE__, __LINE__)
5733#endif
5734
5735#ifdef DOXYGEN
5746void expect_function_calls(#function, const int times);
5747#else
5748#define expect_function_calls(function, times) \
5749 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, times)
5750#endif
5751
5752#ifdef DOXYGEN
5761void expect_function_call(#function);
5762#else
5763#define expect_function_call(function) \
5764 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, 1)
5765#endif
5766
5767#ifdef DOXYGEN
5776#else
5777#define expect_function_call_any(function) \
5778 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, -1)
5779#endif
5780
5781#ifdef DOXYGEN
5790#else
5791#define ignore_function_calls(function) \
5792 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, -2)
5793#endif
5794 /* cmocka_call_order */
5796
5828
5829#ifdef DOXYGEN
5833void fail(void);
5834#else
5835#define fail() _fail(__FILE__, __LINE__)
5836#endif
5837
5838#ifdef DOXYGEN
5842void skip(void);
5843#else
5844#define skip() _skip(__FILE__, __LINE__)
5845#endif
5846
5847#ifdef DOXYGEN
5856void stop(void);
5857#else
5858#define stop() _stop()
5859#endif
5860
5861#ifdef DOXYGEN
5876void fail_msg(const char *msg, ...);
5877#else
5878#define fail_msg(msg, ...) do { \
5879 cmocka_print_error("ERROR: " msg "\n" CMOCKA_VA_ARGS(__VA_ARGS__)); \
5880 fail(); \
5881} while (0)
5882#endif
5883
5884static inline void _unit_test_dummy(void **state) {
5885 (void)state;
5886}
5887
5892#define unit_test(f) \
5893 (CMOCKA_DEPRECATION_WARNING("unit_test: use cmocka_unit_test instead")( \
5894 UnitTest){#f, f, UNIT_TEST_FUNCTION_TYPE_TEST})
5895
5897#define _unit_test_setup(test, setup) \
5898 { #test "_" #setup, setup, UNIT_TEST_FUNCTION_TYPE_SETUP }
5900
5905#define unit_test_setup(test, setup) \
5906 CMOCKA_DEPRECATION_WARNING( \
5907 "unit_test_setup: use cmocka_unit_test_setup instead") \
5908 _unit_test_setup(test, setup), unit_test(test), \
5909 _unit_test_teardown(test, _unit_test_dummy)
5910
5912#define _unit_test_teardown(test, teardown) \
5913 { #test "_" #teardown, teardown, UNIT_TEST_FUNCTION_TYPE_TEARDOWN }
5915
5920#define unit_test_teardown(test, teardown) \
5921 CMOCKA_DEPRECATION_WARNING( \
5922 "unit_test_teardown: use cmocka_unit_test_teardown instead") \
5923 _unit_test_setup(test, _unit_test_dummy), unit_test(test), \
5924 _unit_test_teardown(test, teardown)
5925
5930#define group_test_setup(setup) \
5931 (CMOCKA_DEPRECATION_WARNING( \
5932 "group_test_setup: use cmocka_run_group_tests instead")(UnitTest){ \
5933 "group_" #setup, setup, UNIT_TEST_FUNCTION_TYPE_GROUP_SETUP})
5934
5939#define group_test_teardown(teardown) \
5940 (CMOCKA_DEPRECATION_WARNING( \
5941 "group_test_teardown: use cmocka_run_group_tests instead")(UnitTest){ \
5942 "group_" #teardown, teardown, UNIT_TEST_FUNCTION_TYPE_GROUP_TEARDOWN})
5943
5951#define unit_test_setup_teardown(test, setup, teardown) \
5952 CMOCKA_DEPRECATION_WARNING("unit_test_setup_teardown: use " \
5953 "cmocka_unit_test_setup_teardown instead") \
5954 _unit_test_setup(test, setup), unit_test(test), \
5955 _unit_test_teardown(test, teardown)
5956
5958#define cmocka_unit_test(f) { #f, f, NULL, NULL, NULL }
5959
5961#define cmocka_unit_test_setup(f, setup) { #f, f, setup, NULL, NULL }
5962
5964#define cmocka_unit_test_teardown(f, teardown) { #f, f, NULL, teardown, NULL }
5965
5970#define cmocka_unit_test_setup_teardown(f, setup, teardown) { #f, f, setup, teardown, NULL }
5971
5979#define cmocka_unit_test_prestate(f, state) { #f, f, NULL, NULL, state }
5980
5988#define cmocka_unit_test_prestate_setup_teardown(f, setup, teardown, state) { #f, f, setup, teardown, state }
5989
5990#ifdef DOXYGEN
6047int cmocka_run_group_tests(const struct CMUnitTest group_tests[],
6048 CMFixtureFunction group_setup,
6049 CMFixtureFunction group_teardown);
6050#else
6051# define cmocka_run_group_tests(group_tests, group_setup, group_teardown) \
6052 _cmocka_run_group_tests(#group_tests, group_tests, sizeof(group_tests) / sizeof((group_tests)[0]), group_setup, group_teardown)
6053#endif
6054
6055#ifdef DOXYGEN
6115int cmocka_run_group_tests_name(const char *group_name,
6116 const struct CMUnitTest group_tests[],
6117 CMFixtureFunction group_setup,
6118 CMFixtureFunction group_teardown);
6119#else
6120# define cmocka_run_group_tests_name(group_name, group_tests, group_setup, group_teardown) \
6121 _cmocka_run_group_tests(group_name, group_tests, sizeof(group_tests) / sizeof((group_tests)[0]), group_setup, group_teardown)
6122#endif
6123 /* cmocka_exec */
6125
6185
6186#ifdef DOXYGEN
6209void *test_malloc(size_t size);
6210#else
6211#define test_malloc(size) _test_malloc(size, __FILE__, __LINE__)
6212#endif
6213
6214#ifdef DOXYGEN
6228void *test_calloc(size_t nmemb, size_t size);
6229#else
6230#define test_calloc(num, size) _test_calloc(num, size, __FILE__, __LINE__)
6231#endif
6232
6233#ifdef DOXYGEN
6244void *test_realloc(void *ptr, size_t size);
6245#else
6246#define test_realloc(ptr, size) _test_realloc(ptr, size, __FILE__, __LINE__)
6247#endif
6248
6249#ifdef DOXYGEN
6257void test_free(void *ptr);
6258#else
6259#define test_free(ptr) _test_free(ptr, __FILE__, __LINE__)
6260#endif
6261
6262#if defined(UNIT_TESTING) && defined(ALLOCATION_TESTING)
6263#define malloc test_malloc
6264#define realloc test_realloc
6265#define calloc test_calloc
6266#define free test_free
6267#endif /* UNIT_TESTING && ALLOCATION_TESTING */
6268 /* cmocka_alloc */
6270
6288
6322void mock_assert(const int result, const char* const expression,
6323 const char * const file, const size_t line);
6324
6325#ifdef DOXYGEN
6348void expect_assert_failure(function fn_call);
6349#else
6350#define expect_assert_failure(function_call) \
6351 { \
6352 global_expecting_assert = 1; \
6353 if (setjmp(global_expect_assert_env) != 0) { \
6354 print_message("Expected assertion %s occurred\n", \
6355 global_last_failed_assert); \
6356 global_expecting_assert = 0; \
6357 } else { \
6358 function_call ; \
6359 global_expecting_assert = 0; \
6360 print_error("Expected assert in %s\n", #function_call); \
6361 _fail(__FILE__, __LINE__); \
6362 } \
6363 }
6364#endif
6365 /* cmocka_mock_assert */
6367
6376typedef union {
6378 intmax_t int_val;
6380 uintmax_t uint_val;
6384 double real_val; // TODO: Should we use `long double` instead
6386 void *ptr;
6388 const void *const_ptr;
6389 // The following aren't used by CMocka currently, but are added to avoid
6390 // breaking ABI compatibility in the future
6392 void *(*func)(void);
6394
6395#ifndef DOXYGEN
6400#define LargestIntegralType uintmax_t
6401
6405#if defined(__GNUC__)
6406#define cast_ptr_to_largest_integral_type(value) \
6407 __extension__({ \
6408 CMOCKA_DEPRECATION_WARNING( \
6409 "cast_ptr_to_largest_integral_type: " \
6410 "use cast_ptr_to_uintmax_type instead"); \
6411 cast_ptr_to_uintmax_type(value); \
6412 })
6413#else
6414#define cast_ptr_to_largest_integral_type(value) \
6415 cast_ptr_to_uintmax_type(value)
6416#endif
6417#endif
6418
6424typedef void (*UnitTestFunction)(void **state);
6425
6431typedef int (*CheckParameterValue)(const uintmax_t value,
6432 const uintmax_t check_value_data);
6433
6439typedef int (*CheckParameterValueData)(const CMockaValueData value,
6440 const CMockaValueData check_value_data);
6441
6447typedef int (*CheckIntParameterValue)(const intmax_t value,
6448 const intmax_t check_value_data);
6449
6455typedef int (*CheckUintParameterValue)(const uintmax_t value,
6456 const uintmax_t check_value_data);
6457
6464 UNIT_TEST_FUNCTION_TYPE_TEST = 0,
6465 UNIT_TEST_FUNCTION_TYPE_SETUP,
6466 UNIT_TEST_FUNCTION_TYPE_TEARDOWN,
6467 UNIT_TEST_FUNCTION_TYPE_GROUP_SETUP,
6468 UNIT_TEST_FUNCTION_TYPE_GROUP_TEARDOWN,
6470
6478typedef struct UnitTest {
6479 const char* name;
6480 UnitTestFunction function;
6481 UnitTestFunctionType function_type;
6483
6487typedef struct GroupTest {
6488 UnitTestFunction setup;
6489 UnitTestFunction teardown;
6490 const UnitTest *tests;
6491 const size_t number_of_tests;
6492} GroupTest;
6493
6499typedef void (*CMUnitTestFunction)(void **state);
6500
6506typedef int (*CMFixtureFunction)(void **state);
6507
6512 const char *name;
6513 CMUnitTestFunction test_func;
6514 CMFixtureFunction setup_func;
6515 CMFixtureFunction teardown_func;
6516 void *initial_state;
6517};
6518
6524typedef struct SourceLocation {
6525 const char* file;
6526 size_t line;
6528
6534typedef struct CheckParameterEvent {
6535 SourceLocation location;
6536 const char *parameter_name;
6537 CheckParameterValue check_value;
6538 uintmax_t check_value_data;
6540
6547 SourceLocation location;
6548 const char *parameter_name;
6549 CheckParameterValueData check_value;
6550 CMockaValueData check_value_data;
6552
6566
6567/* Standard output and error print methods. */
6568void print_message(const char* const format, ...) CMOCKA_PRINTF_ATTRIBUTE(1, 2);
6569void print_error(const char* const format, ...) CMOCKA_PRINTF_ATTRIBUTE(1, 2);
6570void vprint_message(const char* const format, va_list args) CMOCKA_PRINTF_ATTRIBUTE(1, 0);
6571void vprint_error(const char* const format, va_list args) CMOCKA_PRINTF_ATTRIBUTE(1, 0);
6572
6587 void (*vprint_message)(const char * const format, va_list args);
6588
6596 void (*vprint_error)(const char * const format, va_list args);
6597};
6598
6613void cmocka_set_callbacks(const struct CMCallbacks *f_callbacks);
6614
6627 CM_OUTPUT_STDOUT = 0x00000001,
6629 CM_OUTPUT_SUBUNIT = 0x00000002,
6631 CM_OUTPUT_TAP = 0x00000004,
6633 CM_OUTPUT_XML = 0x00000008,
6634};
6635
6636#ifdef DOXYGEN
6640void cm_print_error(const char* const format, ...);
6641#else
6642#define cm_print_error(format, ...) \
6643 do { \
6644 CMOCKA_DEPRECATION_WARNING( \
6645 "cm_print_error: use cmocka_print_error instead") \
6646 cmocka_print_error(format CMOCKA_VA_ARGS(__VA_ARGS__)); \
6647 } while (0)
6648#endif
6649
6662void cmocka_print_error(const char* const format, ...) CMOCKA_PRINTF_ATTRIBUTE(1, 2);
6663
6680void cmocka_set_message_output(uint32_t output);
6681
6682
6698void cmocka_set_test_filter(const char *pattern);
6699
6715void cmocka_set_skip_filter(const char *pattern);
6716 /* cmocka_config */
6718
6728
6729/* Used by expect_assert_failure() and mock_assert(). */
6730CMOCKA_DLLEXTERN extern int global_expecting_assert;
6731CMOCKA_DLLEXTERN extern jmp_buf global_expect_assert_env;
6732CMOCKA_DLLEXTERN extern const char * global_last_failed_assert;
6733
6734/* Retrieves a value for the given function, as set by "will_return". */
6735CMockaValueData _mock(const char *const function,
6736 const char *const file,
6737 const size_t line,
6738 const char *name);
6739
6740CMockaValueData _mock_parameter(const char *const function,
6741 const char *name,
6742 const char *const file,
6743 const size_t line,
6744 const char *type);
6745
6746bool _has_mock(const char *const function);
6747
6748void _expect_function_call(
6749 const char * const function_name,
6750 const char * const file,
6751 const size_t line,
6752 const int count);
6753
6754void _function_called(const char * const function, const char* const file,
6755 const size_t line);
6756
6757/* Old API function using uintmax_t */
6758void _expect_check(
6759 const char* const function, const char* const parameter,
6760 const char* const file, const size_t line,
6761 const CheckParameterValue check_function,
6762 const uintmax_t check_data, CheckParameterEvent * const event,
6763 const int count) CMOCKA_DEPRECATED;
6764
6765/* New API function using CMockaValueData */
6766void _expect_check_data(
6767 const char* const function, const char* const parameter,
6768 const char* const file, const size_t line,
6769 const CheckParameterValueData check_function,
6770 const CMockaValueData check_data, CheckParameterEventData * const event,
6771 const int count);
6772
6773void _expect_int_in_set(const char *const function,
6774 const char *const parameter,
6775 const char *const file,
6776 const size_t line,
6777 const intmax_t values[],
6778 const size_t number_of_values,
6779 const intmax_t count);
6780void _expect_uint_in_set(const char *const function,
6781 const char *const parameter,
6782 const char *const file,
6783 const size_t line,
6784 const uintmax_t values[],
6785 const size_t number_of_values,
6786 const intmax_t count);
6787
6788void _expect_float_in_set(const char *const function,
6789 const char *const parameter,
6790 const char *const file,
6791 const size_t line,
6792 const double values[],
6793 const size_t number_of_values,
6794 const double epsilon,
6795 const intmax_t count);
6796
6797void _expect_not_in_set(
6798 const char* const function, const char* const parameter,
6799 const char* const file, const size_t line, const uintmax_t values[],
6800 const size_t number_of_values, const int count);
6801void _expect_int_not_in_set(const char *const function,
6802 const char *const parameter,
6803 const char *const file,
6804 const size_t line,
6805 const intmax_t values[],
6806 const size_t number_of_values,
6807 const intmax_t count);
6808void _expect_uint_not_in_set(const char *const function,
6809 const char *const parameter,
6810 const char *const file,
6811 const size_t line,
6812 const uintmax_t values[],
6813 const size_t number_of_values,
6814 const intmax_t count);
6815
6816void _expect_float_not_in_set(
6817 const char* const function, const char* const parameter,
6818 const char* const file, const size_t line, const double values[],
6819 const size_t number_of_values, const double epsilon, const intmax_t count);
6820
6821void _expect_in_range(const char *const function,
6822 const char *const parameter,
6823 const char *const file,
6824 const size_t line,
6825 const uintmax_t minimum,
6826 const uintmax_t maximum,
6827 const int count) CMOCKA_DEPRECATED;
6828void _expect_int_in_range(const char *const function,
6829 const char *const parameter,
6830 const char *const file,
6831 const size_t line,
6832 const intmax_t minimum,
6833 const intmax_t maximum,
6834 const intmax_t count);
6835void _expect_uint_in_range(const char *const function,
6836 const char *const parameter,
6837 const char *const file,
6838 const size_t line,
6839 const uintmax_t minimum,
6840 const uintmax_t maximum,
6841 const intmax_t count);
6842void _expect_not_in_range(
6843 const char* const function, const char* const parameter,
6844 const char* const file, const size_t line,
6845 const uintmax_t minimum,
6846 const uintmax_t maximum, const int count);
6847void _expect_int_not_in_range(const char *const function,
6848 const char *const parameter,
6849 const char *const file,
6850 const size_t line,
6851 const intmax_t minimum,
6852 const intmax_t maximum,
6853 const intmax_t count);
6854void _expect_uint_not_in_range(const char *const function,
6855 const char *const parameter,
6856 const char *const file,
6857 const size_t line,
6858 const uintmax_t minimum,
6859 const uintmax_t maximum,
6860 const intmax_t count);
6861void _expect_float_in_range(
6862 const char* const function, const char* const parameter,
6863 const char* const file, const size_t line,
6864 const double minimum, const double maximum, const double epsilon,
6865 const int count);
6866void _expect_float_not_in_range(
6867 const char* const function, const char* const parameter,
6868 const char* const file, const size_t line,
6869 const double minimum, const double maximum, const double epsilon,
6870 const int count);
6871
6872void _expect_value(
6873 const char* const function, const char* const parameter,
6874 const char* const file, const size_t line, const uintmax_t value,
6875 const int count);
6876void _expect_int_value(const char *const function,
6877 const char *const parameter,
6878 const char *const file,
6879 const size_t line,
6880 const intmax_t value,
6881 const intmax_t count);
6882void _expect_uint_value(const char *const function,
6883 const char *const parameter,
6884 const char *const file,
6885 const size_t line,
6886 const uintmax_t value,
6887 const intmax_t count);
6888void _expect_int_not_value(const char *const function,
6889 const char *const parameter,
6890 const char *const file,
6891 const size_t line,
6892 const intmax_t value,
6893 const intmax_t count);
6894void _expect_uint_not_value(const char *const function,
6895 const char *const parameter,
6896 const char *const file,
6897 const size_t line,
6898 const uintmax_t value,
6899 const intmax_t count);
6900void _expect_not_value(
6901 const char* const function, const char* const parameter,
6902 const char* const file, const size_t line, const uintmax_t value,
6903 const int count);
6904
6905void _expect_float(
6906 const char* const function, const char* const parameter,
6907 const char* const file, const size_t line, const double value,
6908 const double epsilon, const int count);
6909void _expect_not_float(
6910 const char* const function, const char* const parameter,
6911 const char* const file, const size_t line, const double value,
6912 const double epsilon, const int count);
6913
6914void _expect_double(const char *const function,
6915 const char *const parameter,
6916 const char *const file,
6917 const size_t line,
6918 const double value,
6919 const double epsilon,
6920 const int count);
6921void _expect_not_double(const char *const function,
6922 const char *const parameter,
6923 const char *const file,
6924 const size_t line,
6925 const double value,
6926 const double epsilon,
6927 const int count);
6928
6929void _expect_string(
6930 const char* const function, const char* const parameter,
6931 const char* const file, const size_t line, const char* string,
6932 const int count);
6933void _expect_not_string(
6934 const char* const function, const char* const parameter,
6935 const char* const file, const size_t line, const char* string,
6936 const int count);
6937
6938void _expect_memory(
6939 const char* const function, const char* const parameter,
6940 const char* const file, const size_t line, const void* const memory,
6941 const size_t size, const int count);
6942void _expect_not_memory(
6943 const char* const function, const char* const parameter,
6944 const char* const file, const size_t line, const void* const memory,
6945 const size_t size, const int count);
6946
6947void _expect_any(
6948 const char* const function, const char* const parameter,
6949 const char* const file, const size_t line, const int count);
6950
6951void _check_expected(
6952 const char * const function_name, const char * const parameter_name,
6953 const char* file, const size_t line, const CMockaValueData value);
6954
6955void _will_return(const char *const function_name,
6956 const char *const file,
6957 const size_t line,
6958 const char *name,
6959 const CMockaValueData value,
6960 const int count);
6961void _will_set_parameter(const char *const function_name,
6962 const char *name,
6963 const char *const file,
6964 const size_t line,
6965 const char *type,
6966 const CMockaValueData value,
6967 const int count);
6968void _assert_true(const uintmax_t result,
6969 const char* const expression,
6970 const char * const file, const size_t line);
6971void _assert_false(const uintmax_t result,
6972 const char * const expression,
6973 const char * const file, const size_t line);
6974void _assert_return_code(const intmax_t result,
6975 const int32_t error,
6976 const char * const expression,
6977 const char * const file,
6978 const size_t line);
6979void _assert_float_equal(const float a, const float n,
6980 const float epsilon, const char* const file,
6981 const size_t line);
6982void _assert_float_not_equal(const float a, const float n,
6983 const float epsilon, const char* const file,
6984 const size_t line);
6985void _assert_double_equal(const double a, const double n,
6986 const double epsilon, const char* const file,
6987 const size_t line);
6988void _assert_double_not_equal(const double a, const double n,
6989 const double epsilon, const char* const file,
6990 const size_t line);
6991void _assert_int_equal(const intmax_t a,
6992 const intmax_t b,
6993 const char * const file,
6994 const size_t line);
6995void _assert_int_not_equal(const intmax_t a,
6996 const intmax_t b,
6997 const char * const file,
6998 const size_t line);
6999void _assert_uint_equal(const uintmax_t a,
7000 const uintmax_t b,
7001 const char * const file,
7002 const size_t line);
7003void _assert_uint_not_equal(const uintmax_t a,
7004 const uintmax_t b,
7005 const char * const file,
7006 const size_t line);
7007CMOCKA_NO_ACCESS_ATTRIBUTE
7008void _assert_ptr_equal_msg(const void *a,
7009 const void *b,
7010 const char *const file,
7011 const size_t line,
7012 const char *const msg);
7013CMOCKA_NO_ACCESS_ATTRIBUTE
7014void _assert_ptr_not_equal_msg(const void *a,
7015 const void *b,
7016 const char *const file,
7017 const size_t line,
7018 const char *const msg);
7019void _assert_string_equal(const char * const a, const char * const b,
7020 const char * const file, const size_t line);
7021void _assert_string_not_equal(const char * const a, const char * const b,
7022 const char *file, const size_t line);
7023void _assert_memory_equal(const void * const a, const void * const b,
7024 const size_t size, const char* const file,
7025 const size_t line);
7026void _assert_memory_not_equal(const void * const a, const void * const b,
7027 const size_t size, const char* const file,
7028 const size_t line);
7029void _assert_int_in_range(const intmax_t value,
7030 const intmax_t minimum,
7031 const intmax_t maximum,
7032 const char* const file,
7033 const size_t line);
7034void _assert_int_not_in_range(const intmax_t value,
7035 const intmax_t minimum,
7036 const intmax_t maximum,
7037 const char *const file,
7038 const size_t line);
7039void _assert_uint_in_range(const uintmax_t value,
7040 const uintmax_t minimum,
7041 const uintmax_t maximum,
7042 const char* const file,
7043 const size_t line);
7044void _assert_uint_not_in_range(const uintmax_t value,
7045 const uintmax_t minimum,
7046 const uintmax_t maximum,
7047 const char* const file,
7048 const size_t line);
7049void _assert_float_in_range(const double value,
7050 const double minimum,
7051 const double maximum,
7052 const double epsilon,
7053 const char* const file,
7054 const size_t line);
7055void _assert_float_not_in_range(const double value,
7056 const double minimum,
7057 const double maximum,
7058 const double epsilon,
7059 const char* const file,
7060 const size_t line);
7061void _assert_not_in_set(
7062 const uintmax_t value, const uintmax_t values[],
7063 const size_t number_of_values, const char* const file, const size_t line);
7064void _assert_int_in_set(const intmax_t value,
7065 const intmax_t values[],
7066 const size_t number_of_values,
7067 const char *const file,
7068 const size_t line);
7069void _assert_int_not_in_set(const intmax_t value,
7070 const intmax_t values[],
7071 const size_t number_of_values,
7072 const char *const file,
7073 const size_t line);
7074void _assert_uint_in_set(const uintmax_t value,
7075 const uintmax_t values[],
7076 const size_t number_of_values,
7077 const char *const file,
7078 const size_t line);
7079void _assert_uint_not_in_set(const uintmax_t value,
7080 const uintmax_t values[],
7081 const size_t number_of_values,
7082 const char *const file,
7083 const size_t line);
7084void _assert_float_in_set(const double value,
7085 const double values[],
7086 const size_t number_of_values,
7087 const double epsilon,
7088 const char *const file,
7089 const size_t line);
7090void _assert_float_not_in_set(const double value,
7091 const double values[],
7092 const size_t number_of_values,
7093 const double epsilon,
7094 const char *const file,
7095 const size_t line);
7096
7097void* _test_malloc(const size_t size, const char* file, const size_t line);
7098void* _test_realloc(void *ptr, const size_t size, const char* file, const size_t line);
7099void* _test_calloc(const size_t number_of_elements, const size_t size,
7100 const char* file, const size_t line);
7101void _test_free(void* const ptr, const char* file, const size_t line);
7102
7103CMOCKA_NORETURN void _fail(const char * const file, const size_t line);
7104
7105CMOCKA_NORETURN void _skip(const char * const file, const size_t line);
7106
7107CMOCKA_NORETURN void _stop(void);
7108
7109/* Test runner */
7110int _cmocka_run_group_tests(const char *group_name,
7111 const struct CMUnitTest * const tests,
7112 const size_t num_tests,
7113 CMFixtureFunction group_setup,
7114 CMFixtureFunction group_teardown);
7115
7117
7118#ifdef __cplusplus
7119} /* extern "C" */
7120#endif
7121
7122#endif /* CMOCKA_H_ */
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:6623
void cmocka_set_skip_filter(const char *pattern)
Set a pattern to skip tests matching the pattern.
Definition cmocka.c:4878
void cmocka_set_test_filter(const char *pattern)
Set a pattern to only run the test matching the pattern.
Definition cmocka.c:4861
@ CM_OUTPUT_TAP
Definition cmocka.h:6631
@ CM_OUTPUT_STDOUT
Definition cmocka.h:6627
@ CM_OUTPUT_SUBUNIT
Definition cmocka.h:6629
@ CM_OUTPUT_STANDARD
Definition cmocka.h:6625
@ CM_OUTPUT_XML
Definition cmocka.h:6633
void(* UnitTestFunction)(void **state)
Definition cmocka.h:6424
int(* CMFixtureFunction)(void **state)
Definition cmocka.h:6506
int cmocka_run_group_tests(const struct CMUnitTest group_tests[], CMFixtureFunction group_setup, CMFixtureFunction group_teardown)
Run tests specified by an array of CMUnitTest structures.
void fail(void)
Forces the test to fail immediately and quit.
void stop(void)
Forces the test to be stopped immediately.
UnitTestFunctionType
Definition cmocka.h:6463
void fail_msg(const char *msg,...)
Forces the test to fail immediately and quit, printing the reason.
int cmocka_run_group_tests_name(const char *group_name, const struct CMUnitTest group_tests[], CMFixtureFunction group_setup, CMFixtureFunction group_teardown)
Run tests specified by an array of CMUnitTest structures and specify a name.
void skip(void)
Forces the test to not be executed, but marked as skipped.
void(* CMUnitTestFunction)(void **state)
Definition cmocka.h:6499
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:6431
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:6447
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:6439
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:6455
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...
Definition cmocka.h:6579
void(* vprint_message)(const char *const format, va_list args)
Definition cmocka.h:6587
void(* vprint_error)(const char *const format, va_list args)
Definition cmocka.h:6596
Definition cmocka.h:6511
Definition cmocka.h:6546
Definition cmocka.h:6534
Definition cmocka.h:6487
Definition cmocka.h:6524
Definition cmocka.h:6478
Definition cmocka.h:6376
double real_val
Definition cmocka.h:6384
float float_val
Definition cmocka.h:6382
const void * const_ptr
Definition cmocka.h:6388
void * ptr
Definition cmocka.h:6386
intmax_t int_val
Definition cmocka.h:6378
uintmax_t uint_val
Definition cmocka.h:6380