cmocka 2.0.4
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
268 /* cmocka_util */
270
322
335#define WILL_RETURN_ALWAYS -1
336
348#define WILL_RETURN_ONCE -2
349
359#define EXPECT_ALWAYS -1
360
370#define EXPECT_MAYBE -2
371
372#ifdef DOXYGEN
380uintmax_t mock(void);
381#else
382#define mock() (_mock(__func__, __FILE__, __LINE__, NULL)).uint_val
383#endif
384
385
386#ifdef DOXYGEN
407type mock_type(#type);
408#else
409#define mock_type(type) ((type) mock())
410#endif
411
412#ifdef DOXYGEN
438bool has_mock(void);
439#else
440#define has_mock() _has_mock(__func__)
441#endif
442
443#ifdef DOXYGEN
457intmax_t mock_int();
458#else
459/* TODO: Enable type safety check by passing intmax_t instead of NULL */
460#define mock_int() (_mock(__func__, __FILE__, __LINE__, NULL)).int_val
461#endif
462
463
464#ifdef DOXYGEN
478uintmax_t mock_uint(void);
479#else
480#define mock_uint() (_mock(__func__, __FILE__, __LINE__, "uintmax_t")).uint_val
481#endif
482
483
484#ifdef DOXYGEN
492float mock_float(void);
493#else
494#define mock_float() (_mock(__func__, __FILE__, __LINE__, NULL)).float_val
495#endif
496
497#ifdef DOXYGEN
506double mock_double(void);
507#else
508#define mock_double() (_mock(__func__, __FILE__, __LINE__, NULL)).real_val
509#endif
510
511#ifdef DOXYGEN
532type mock_ptr_type(#type);
533#else
534#define mock_ptr_type(type) \
535 ((type)(_mock(__func__, __FILE__, __LINE__, NULL)).ptr)
536#endif
537
538#ifdef DOXYGEN
561#else
562#define mock_ptr_type_checked(type) \
563 ((type)(_mock(__func__, __FILE__, __LINE__, #type)).ptr)
564#endif
565
566#ifdef DOXYGEN
600uintmax_t mock_parameter(#name);
601#else
602#define mock_parameter(name) \
603 (_mock_parameter(__func__, #name, __FILE__, __LINE__, NULL)).uint_val
604#endif
605
606#ifdef DOXYGEN
629#type mock_parameter_type(#name, #type);
630#else
631#define mock_parameter_type(name, type) ((type) mock_parameter(#name))
632#endif
633
634#ifdef DOXYGEN
652intmax_t mock_parameter_int(#name);
653#else
654#define mock_parameter_int(name) \
655 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "intmax_t")).int_val
656#endif
657
658#ifdef DOXYGEN
676uintmax_t mock_parameter_uint(#name);
677#else
678#define mock_parameter_uint(name) \
679 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "uintmax_t")).uint_val
680#endif
681
682#ifdef DOXYGEN
701#else
702#define mock_parameter_float(name) \
703 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "float")).float_val
704#endif
705
706#ifdef DOXYGEN
725#else
726#define mock_parameter_double(name) \
727 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "double")).real_val
728#endif
729
730#ifdef DOXYGEN
748#else
749#define mock_parameter_ptr(name) \
750 ((_mock_parameter(__func__, #name, __FILE__, __LINE__, NULL)).ptr)
751#endif
752
753#ifdef DOXYGEN
774type mock_parameter_ptr_type(#name, #type);
775#else
776#define mock_parameter_ptr_type(name, type) \
777 ((type)(_mock_parameter(__func__, #name, __FILE__, __LINE__, #type)).ptr)
778#endif
779
780#ifdef DOXYGEN
788void mock_errno(void);
789#else
790#define mock_errno() \
791 do { \
792 intmax_t err = (_mock_parameter( \
793 __func__, \
794 "/errno", \
795 __FILE__, \
796 __LINE__, \
797 "errno")).int_val; \
798 if (err != 0) { \
799 errno = err; \
800 } \
801 } while (0)
802#endif
803
804#ifdef DOXYGEN
838void will_return(#function, uintmax_t value);
839#else
840#define will_return(function, value) \
841 _will_return(cmocka_tostring(function), \
842 __FILE__, \
843 __LINE__, \
844 NULL, \
845 cast_int_to_cmocka_value(value), \
846 1)
847#endif
848
849#ifdef DOXYGEN
873void will_return_int(#function, intmax_t value);
874#else
875#define will_return_int(function, value) \
876 _will_return(#function, \
877 __FILE__, \
878 __LINE__, \
879 "intmax_t", \
880 assign_int_to_cmocka_value(value), \
881 1)
882#endif
883
884#ifdef DOXYGEN
918void will_return_int_count(#function, intmax_t value, int count);
919#else
920#define will_return_int_count(function, value, count) \
921 _will_return(#function, \
922 __FILE__, \
923 __LINE__, \
924 "intmax_t", \
925 assign_int_to_cmocka_value(value), \
926 count)
927#endif
928
929#ifdef DOXYGEN
954void will_return_uint(#function, uintmax_t value);
955#else
956#define will_return_uint(function, value) \
957 _will_return(#function, \
958 __FILE__, \
959 __LINE__, \
960 "uintmax_t", \
961 assign_uint_to_cmocka_value(value), \
962 1)
963#endif
964
965#ifdef DOXYGEN
999void will_return_uint_count(#function, uintmax_t value, int count);
1000#else
1001#define will_return_uint_count(function, value, count) \
1002 _will_return(#function, \
1003 __FILE__, \
1004 __LINE__, \
1005 "uintmax_t", \
1006 assign_uint_to_cmocka_value(value), \
1007 count)
1008#endif
1009
1010#ifdef DOXYGEN
1035void will_return_float(#function, float value);
1036#else
1037#define will_return_float(function, value) \
1038 _will_return(#function, \
1039 __FILE__, \
1040 __LINE__, \
1041 "float", \
1042 assign_float_to_cmocka_value(value), \
1043 1)
1044#endif
1045
1046#ifdef DOXYGEN
1080void will_return_float_count(#function, float value, int count);
1081#else
1082#define will_return_float_count(function, value, count) \
1083 _will_return(#function, \
1084 __FILE__, \
1085 __LINE__, \
1086 "float", \
1087 assign_float_to_cmocka_value(value), \
1088 count)
1089#endif
1090
1091#ifdef DOXYGEN
1116void will_return_double(#function, double value);
1117#else
1118#define will_return_double(function, value) \
1119 _will_return(#function, \
1120 __FILE__, \
1121 __LINE__, \
1122 "double", \
1123 assign_double_to_cmocka_value(value), \
1124 1)
1125#endif
1126
1127#ifdef DOXYGEN
1161void will_return_double_count(#function, double value, int count);
1162#else
1163#define will_return_double_count(function, value, count) \
1164 _will_return(#function, \
1165 __FILE__, \
1166 __LINE__, \
1167 "double", \
1168 assign_double_to_cmocka_value(value), \
1169 count)
1170#endif
1171
1172#ifdef DOXYGEN
1188void will_return_int_always(#function, intmax_t value);
1189#else
1190#define will_return_int_always(function, value) \
1191 will_return_int_count(function, (value), WILL_RETURN_ALWAYS)
1192#endif
1193
1194#ifdef DOXYGEN
1211void will_return_uint_always(#function, uintmax_t value);
1212#else
1213#define will_return_uint_always(function, value) \
1214 will_return_uint_count(function, (value), WILL_RETURN_ALWAYS)
1215#endif
1216
1217#ifdef DOXYGEN
1233void will_return_float_always(#function, float value);
1234#else
1235#define will_return_float_always(function, value) \
1236 will_return_float_count(function, (value), WILL_RETURN_ALWAYS)
1237#endif
1238
1239#ifdef DOXYGEN
1255void will_return_double_always(#function, double value);
1256#else
1257#define will_return_double_always(function, value) \
1258 will_return_double_count(function, (value), WILL_RETURN_ALWAYS)
1259#endif
1260
1261#ifdef DOXYGEN
1265void will_return_count(#function, uintmax_t value, int count);
1266#else
1267#define will_return_count(function, value, count) \
1268 do { \
1269 CMOCKA_DEPRECATION_WARNING( \
1270 "will_return_count: use will_return_int_count or " \
1271 "will_return_uint_count instead") \
1272 _will_return(cmocka_tostring(function), \
1273 __FILE__, \
1274 __LINE__, \
1275 NULL, \
1276 cast_int_to_cmocka_value(value), \
1277 count); \
1278 } while (0)
1279#endif
1280
1281#ifdef DOXYGEN
1285void will_return_always(#function, uintmax_t value);
1286#else
1287#define will_return_always(function, value) \
1288 do { \
1289 CMOCKA_DEPRECATION_WARNING( \
1290 "will_return_always: use will_return_int_always or " \
1291 "will_return_uint_always instead") \
1292 will_return_count(function, (value), WILL_RETURN_ALWAYS); \
1293 } while (0)
1294#endif
1295
1296#ifdef DOXYGEN
1318void will_return_int_maybe(#function, intmax_t value);
1319#else
1320#define will_return_int_maybe(function, value) \
1321 will_return_int_count(function, (value), WILL_RETURN_ONCE)
1322#endif
1323
1324#ifdef DOXYGEN
1347void will_return_uint_maybe(#function, uintmax_t value);
1348#else
1349#define will_return_uint_maybe(function, value) \
1350 will_return_uint_count(function, (value), WILL_RETURN_ONCE)
1351#endif
1352
1353#ifdef DOXYGEN
1375void will_return_float_maybe(#function, float value);
1376#else
1377#define will_return_float_maybe(function, value) \
1378 will_return_float_count(function, (value), WILL_RETURN_ONCE)
1379#endif
1380
1381#ifdef DOXYGEN
1403void will_return_double_maybe(#function, double value);
1404#else
1405#define will_return_double_maybe(function, value) \
1406 will_return_double_count(function, (value), WILL_RETURN_ONCE)
1407#endif
1408
1409#ifdef DOXYGEN
1413void will_return_maybe(#function, uintmax_t value);
1414#else
1415#define will_return_maybe(function, value) \
1416 do { \
1417 CMOCKA_DEPRECATION_WARNING( \
1418 "will_return_maybe: use will_return_int_maybe or " \
1419 "will_return_uint_maybe instead") \
1420 will_return_count(function, (value), WILL_RETURN_ONCE); \
1421 } while (0)
1422#endif
1423
1424#ifdef DOXYGEN
1449void will_return_ptr(#function, void *value);
1450#else
1451#define will_return_ptr(function, value) \
1452 _will_return(#function, \
1453 __FILE__, \
1454 __LINE__, \
1455 NULL, \
1456 cast_ptr_to_cmocka_value(value), \
1457 1)
1458#endif
1459
1460#ifdef DOXYGEN
1489void will_return_ptr_type(#function, void *value, type);
1490#else
1491#define will_return_ptr_type(function, value, type) \
1492 _will_return(#function, \
1493 __FILE__, \
1494 __LINE__, \
1495 #type, \
1496 cast_ptr_to_cmocka_value(value), \
1497 1)
1498#endif
1499
1500#ifdef DOXYGEN
1516void will_return_ptr_count(#function, void *value, int count);
1517#else
1518#define will_return_ptr_count(function, value, count) \
1519 _will_return(#function, \
1520 __FILE__, \
1521 __LINE__, \
1522 NULL, \
1523 cast_ptr_to_cmocka_value(value), \
1524 count)
1525#endif
1526
1527#ifdef DOXYGEN
1543void will_return_ptr_always(#function, void *value);
1544#else
1545#define will_return_ptr_always(function, value) \
1546 will_return_ptr_count(function, (value), WILL_RETURN_ALWAYS)
1547#endif
1548
1549#ifdef DOXYGEN
1571void will_return_ptr_maybe(#function, void *value);
1572#else
1573#define will_return_ptr_maybe(function, value) \
1574 will_return_ptr_count(function, (value), WILL_RETURN_ONCE)
1575#endif
1576
1577#ifdef DOXYGEN
1622void will_set_parameter(#function, #name, uintmax_t value);
1623#else
1624#define will_set_parameter(function, name, value) \
1625 _will_set_parameter(cmocka_tostring(function), \
1626 #name, \
1627 __FILE__, \
1628 __LINE__, \
1629 NULL, \
1630 cast_int_to_cmocka_value(value), \
1631 1)
1632#endif
1633
1634#ifdef DOXYGEN
1666void will_set_parameter_int(#function, #name, intmax_t value);
1667#else
1668#define will_set_parameter_int(function, name, value) \
1669 _will_set_parameter(#function, \
1670 #name, \
1671 __FILE__, \
1672 __LINE__, \
1673 "intmax_t", \
1674 assign_int_to_cmocka_value(value), \
1675 1)
1676#endif
1677
1678#ifdef DOXYGEN
1712void will_set_parameter_uint(#function, #name, uintmax_t value);
1713#else
1714#define will_set_parameter_uint(function, name, value) \
1715 _will_set_parameter(#function, \
1716 #name, \
1717 __FILE__, \
1718 __LINE__, \
1719 "uintmax_t", \
1720 assign_uint_to_cmocka_value(value), \
1721 1)
1722#endif
1723
1724#ifdef DOXYGEN
1757void will_set_parameter_float(#function, #name, float value);
1758#else
1759#define will_set_parameter_float(function, name, value) \
1760 _will_set_parameter(#function, \
1761 #name, \
1762 __FILE__, \
1763 __LINE__, \
1764 "float", \
1765 assign_float_to_cmocka_value(value), \
1766 1)
1767#endif
1768
1769#ifdef DOXYGEN
1803void will_set_parameter_double(#function, #name, double value);
1804#else
1805#define will_set_parameter_double(function, name, value) \
1806 _will_set_parameter(#function, \
1807 #name, \
1808 __FILE__, \
1809 __LINE__, \
1810 "double", \
1811 assign_double_to_cmocka_value(value), \
1812 1)
1813#endif
1814
1815#ifdef DOXYGEN
1835void will_set_parameter_int_count(#function, #name, intmax_t value, int count);
1836#else
1837#define will_set_parameter_int_count(function, name, value, count) \
1838 _will_set_parameter(#function, \
1839 #name, \
1840 __FILE__, \
1841 __LINE__, \
1842 "intmax_t", \
1843 assign_int_to_cmocka_value(value), \
1844 count)
1845#endif
1846
1847#ifdef DOXYGEN
1868 #name,
1869 uintmax_t value,
1870 int count);
1871#else
1872#define will_set_parameter_uint_count(function, name, value, count) \
1873 _will_set_parameter(#function, \
1874 #name, \
1875 __FILE__, \
1876 __LINE__, \
1877 "uintmax_t", \
1878 assign_uint_to_cmocka_value(value), \
1879 count)
1880#endif
1881
1882#ifdef DOXYGEN
1902void will_set_parameter_float_count(#function, #name, float value, int count);
1903#else
1904#define will_set_parameter_float_count(function, name, value, count) \
1905 _will_set_parameter(#function, \
1906 #name, \
1907 __FILE__, \
1908 __LINE__, \
1909 "float", \
1910 assign_float_to_cmocka_value(value), \
1911 count)
1912#endif
1913
1914#ifdef DOXYGEN
1934void will_set_parameter_double_count(#function, #name, double value, int count);
1935#else
1936#define will_set_parameter_double_count(function, name, value, count) \
1937 _will_set_parameter(#function, \
1938 #name, \
1939 __FILE__, \
1940 __LINE__, \
1941 "double", \
1942 assign_double_to_cmocka_value(value), \
1943 count)
1944#endif
1945
1946#ifdef DOXYGEN
1951void will_set_parameter_count(#function, #name, uintmax_t value, int count);
1952#else
1953#define will_set_parameter_count(function, name, value, count) \
1954 do { \
1955 CMOCKA_DEPRECATION_WARNING( \
1956 "will_set_parameter_count: use will_set_parameter_int_count or " \
1957 "will_set_parameter_uint_count instead") \
1958 _will_set_parameter(cmocka_tostring(function), \
1959 #name, \
1960 __FILE__, \
1961 __LINE__, \
1962 NULL, \
1963 cast_int_to_cmocka_value(value), \
1964 count); \
1965 } while (0)
1966#endif
1967
1968#ifdef DOXYGEN
1988void will_set_parameter_int_always(#function, #name, intmax_t value);
1989#else
1990#define will_set_parameter_int_always(function, name, value) \
1991 will_set_parameter_int_count(function, name, (value), WILL_RETURN_ALWAYS)
1992#endif
1993
1994#ifdef DOXYGEN
2014void will_set_parameter_uint_always(#function, #name, uintmax_t value);
2015#else
2016#define will_set_parameter_uint_always(function, name, value) \
2017 will_set_parameter_uint_count(function, name, (value), WILL_RETURN_ALWAYS)
2018#endif
2019
2020#ifdef DOXYGEN
2040void will_set_parameter_float_always(#function, #name, float value);
2041#else
2042#define will_set_parameter_float_always(function, name, value) \
2043 will_set_parameter_float_count(function, name, (value), WILL_RETURN_ALWAYS)
2044#endif
2045
2046#ifdef DOXYGEN
2066void will_set_parameter_double_always(#function, #name, double value);
2067#else
2068#define will_set_parameter_double_always(function, name, value) \
2069 will_set_parameter_double_count(function, name, (value), WILL_RETURN_ALWAYS)
2070#endif
2071
2072#ifdef DOXYGEN
2077void will_set_parameter_always(#function, #name, uintmax_t value);
2078#else
2079#define will_set_parameter_always(function, name, value) \
2080 do { \
2081 CMOCKA_DEPRECATION_WARNING( \
2082 "will_set_parameter_always: use will_set_parameter_int_always or " \
2083 "will_set_parameter_uint_always instead") \
2084 will_set_parameter_count(function, name, (value), WILL_RETURN_ALWAYS); \
2085 } while (0)
2086#endif
2087
2088#ifdef DOXYGEN
2109void will_set_parameter_int_maybe(#function, #name, intmax_t value);
2110#else
2111#define will_set_parameter_int_maybe(function, name, value) \
2112 will_set_parameter_int_count(function, name, (value), WILL_RETURN_ONCE)
2113#endif
2114
2115#ifdef DOXYGEN
2136void will_set_parameter_uint_maybe(#function, #name, uintmax_t value);
2137#else
2138#define will_set_parameter_uint_maybe(function, name, value) \
2139 will_set_parameter_uint_count(function, name, (value), WILL_RETURN_ONCE)
2140#endif
2141
2142#ifdef DOXYGEN
2163void will_set_parameter_float_maybe(#function, #name, float value);
2164#else
2165#define will_set_parameter_float_maybe(function, name, value) \
2166 will_set_parameter_float_count(function, name, (value), WILL_RETURN_ONCE)
2167#endif
2168
2169#ifdef DOXYGEN
2190void will_set_parameter_double_maybe(#function, #name, double value);
2191#else
2192#define will_set_parameter_double_maybe(function, name, value) \
2193 will_set_parameter_double_count(function, name, (value), WILL_RETURN_ONCE)
2194#endif
2195
2196#ifdef DOXYGEN
2201void will_set_parameter_maybe(#function, #name, uintmax_t value);
2202#else
2203#define will_set_parameter_maybe(function, name, value) \
2204 do { \
2205 CMOCKA_DEPRECATION_WARNING( \
2206 "will_set_parameter_maybe: use will_set_parameter_int_maybe or " \
2207 "will_set_parameter_uint_maybe instead") \
2208 will_set_parameter_count(function, name, (value), WILL_RETURN_ONCE); \
2209 } while (0)
2210#endif
2211
2212#ifdef DOXYGEN
2241void will_set_parameter_ptr(#function, #name, void *value);
2242#else
2243#define will_set_parameter_ptr(function, name, value) \
2244 _will_set_parameter(#function, \
2245 #name, \
2246 __FILE__, \
2247 __LINE__, \
2248 NULL, \
2249 cast_ptr_to_cmocka_value(value), \
2250 1)
2251#endif
2252
2253#ifdef DOXYGEN
2287void will_set_parameter_ptr_type(#function, #name, void *value, #type);
2288#else
2289#define will_set_parameter_ptr_type(function, name, value, type) \
2290 _will_set_parameter(#function, \
2291 #name, \
2292 __FILE__, \
2293 __LINE__, \
2294 #type, \
2295 cast_ptr_to_cmocka_value(value), \
2296 1)
2297#endif
2298
2299#ifdef DOXYGEN
2338void will_set_parameter_ptr_count(#function, #name, void *value, int count);
2339#else
2340#define will_set_parameter_ptr_count(function, name, value, count) \
2341 _will_set_parameter(#function, \
2342 #name, \
2343 __FILE__, \
2344 __LINE__, \
2345 NULL, \
2346 cast_ptr_to_cmocka_value(value), \
2347 count)
2348#endif
2349
2350#ifdef DOXYGEN
2377void will_set_parameter_ptr_always(#function, #name, void *value);
2378#else
2379#define will_set_parameter_ptr_always(function, name, value) \
2380 will_set_parameter_ptr_count(function, name, (value), WILL_RETURN_ALWAYS)
2381#endif
2382
2383#ifdef DOXYGEN
2412void will_set_parameter_ptr_maybe(#function, #name, void *value);
2413#else
2414#define will_set_parameter_ptr_maybe(function, name, value) \
2415 will_set_parameter_ptr_count(function, name, (value), WILL_RETURN_ONCE)
2416#endif
2417
2418#ifdef DOXYGEN
2443void will_set_errno(#function, intmax_t value);
2444#else
2445#define will_set_errno(function, value) \
2446 _will_set_parameter(#function, \
2447 "/errno", \
2448 __FILE__, \
2449 __LINE__, \
2450 "errno", \
2451 assign_int_to_cmocka_value(value), \
2452 1)
2453#endif
2454
2455#ifdef DOXYGEN
2494void will_set_errno_count(#function, intmax_t value, intmax_t count);
2495#else
2496#define will_set_errno_count(function, value, count) \
2497 _will_set_parameter(#function, \
2498 "/errno", \
2499 __FILE__, \
2500 __LINE__, \
2501 "errno", \
2502 assign_int_to_cmocka_value(value), \
2503 (count))
2504#endif
2505
2506#ifdef DOXYGEN
2529void will_set_errno_always(#function, intmax_t value);
2530#else
2531#define will_set_errno_always(function, value) \
2532 will_set_errno_count(function, (value), WILL_RETURN_ALWAYS);
2533#endif
2534
2535#ifdef DOXYGEN
2558void will_set_errno_maybe(#function, intmax_t value);
2559#else
2560#define will_set_errno_maybe(function, value) \
2561 will_set_errno_count(function, (value), WILL_RETURN_ONCE);
2562#endif
2563 /* cmocka_mock */
2565
2610
2611
2612#ifdef DOXYGEN
2616void expect_check(function,
2617 parameter,
2618 CheckParameterValue check_function,
2619 const void *check_data);
2620#else
2621#define expect_check(function, parameter, check_function, check_data) \
2622 do { \
2623 CMOCKA_DEPRECATION_WARNING( \
2624 "expect_check: use expect_check_data instead") \
2625 _expect_check(cmocka_tostring(function), \
2626 cmocka_tostring(parameter), \
2627 __FILE__, \
2628 __LINE__, \
2629 check_function, \
2630 cast_to_uintmax_type(check_data), \
2631 NULL, \
2632 1); \
2633 } while (0)
2634#endif
2635
2636
2637#ifdef DOXYGEN
2642 parameter,
2643 CheckParameterValue check_function,
2644 const void *check_data,
2645 intmax_t count);
2646#else
2647#define expect_check_count( \
2648 function, parameter, check_function, check_data, count) \
2649 do { \
2650 CMOCKA_DEPRECATION_WARNING( \
2651 "expect_check_count: use expect_check_data_count instead") \
2652 _expect_check(cmocka_tostring(function), \
2653 cmocka_tostring(parameter), \
2654 __FILE__, \
2655 __LINE__, \
2656 check_function, \
2657 cast_to_uintmax_type(check_data), \
2658 NULL, \
2659 count); \
2660 } while (0)
2661#endif
2662
2663#ifdef DOXYGEN
2819void expect_check_data(function,
2820 parameter,
2821 CheckParameterValueData check_function,
2822 CMockaValueData check_data);
2823#else
2824#define expect_check_data(function, parameter, check_function, check_data) \
2825 _expect_check_data(cmocka_tostring(function), \
2826 cmocka_tostring(parameter), \
2827 __FILE__, \
2828 __LINE__, \
2829 check_function, \
2830 check_data, \
2831 NULL, \
2832 1)
2833#endif
2834
2835#ifdef DOXYGEN
2901 parameter,
2902 CheckParameterValueData check_function,
2903 CMockaValueData check_data,
2904 intmax_t count);
2905#else
2906#define expect_check_data_count(function, \
2907 parameter, \
2908 check_function, \
2909 check_data, \
2910 count) \
2911 _expect_check_data(cmocka_tostring(function), \
2912 cmocka_tostring(parameter), \
2913 __FILE__, \
2914 __LINE__, \
2915 check_function, \
2916 check_data, \
2917 NULL, \
2918 count)
2919#endif
2920
2921#ifdef DOXYGEN
2925void expect_in_set(#function, #parameter, uintmax_t value_array[]);
2926#else
2927#define expect_in_set(function, parameter, value_array) \
2928 do { \
2929 CMOCKA_DEPRECATION_WARNING("expect_in_set: use expect_int_in_set or " \
2930 "expect_uint_in_set instead") \
2931 expect_in_set_count(function, parameter, value_array, 1); \
2932 } while (0)
2933#endif
2934
2935#ifdef DOXYGEN
2950void expect_in_set(#function, #parameter, intmax_t value_array[]);
2951#else
2952#define expect_int_in_set(function, parameter, value_array) \
2953 expect_int_in_set_count(function, parameter, value_array, 1)
2954#endif
2955
2956#ifdef DOXYGEN
2971void expect_in_set(#function, #parameter, intmax_t value_array[]);
2972#else
2973#define expect_uint_in_set(function, parameter, value_array) \
2974 expect_uint_in_set_count(function, parameter, value_array, 1)
2975#endif
2976
2977#ifdef DOXYGEN
2981void expect_in_set_count(#function, #parameter, uintmax_t value_array[], intmax_t count);
2982#else
2983#define expect_in_set_count(function, parameter, value_array, count) \
2984 do { \
2985 CMOCKA_DEPRECATION_WARNING( \
2986 "expect_in_set_count: use expect_int_in_set_count or " \
2987 "expect_uint_in_set_count instead") \
2988 _expect_uint_in_set(cmocka_tostring(function), \
2989 cmocka_tostring(parameter), \
2990 __FILE__, \
2991 __LINE__, \
2992 value_array, \
2993 sizeof(value_array) / sizeof((value_array)[0]), \
2994 count); \
2995 } while (0)
2996#endif
2997
2998#ifdef DOXYGEN
3017void expect_int_in_set_count(#function, #parameter, intmax_t value_array[], intmax_t count);
3018#else
3019#define expect_int_in_set_count(function, parameter, value_array, count) \
3020 _expect_int_in_set(cmocka_tostring(function), \
3021 cmocka_tostring(parameter), \
3022 __FILE__, \
3023 __LINE__, \
3024 value_array, \
3025 sizeof(value_array) / sizeof((value_array)[0]), \
3026 count)
3027#endif
3028
3029#ifdef DOXYGEN
3048void expect_uint_in_set_count(#function, #parameter, uintmax_t value_array[], intmax_t count);
3049#else
3050#define expect_uint_in_set_count(function, parameter, value_array, count) \
3051 _expect_uint_in_set(cmocka_tostring(function), \
3052 cmocka_tostring(parameter), \
3053 __FILE__, \
3054 __LINE__, \
3055 value_array, \
3056 sizeof(value_array) / sizeof((value_array)[0]), \
3057 count)
3058#endif
3059
3060#ifdef DOXYGEN
3064void expect_not_in_set(#function, #parameter, uintmax_t value_array[]);
3065#else
3066#define expect_not_in_set(function, parameter, value_array) \
3067 do { \
3068 CMOCKA_DEPRECATION_WARNING( \
3069 "expect_not_in_set: use expect_int_not_in_set or " \
3070 "expect_uint_not_in_set instead") \
3071 expect_not_in_set_count(function, parameter, value_array, 1); \
3072 } while (0)
3073#endif
3074
3075#ifdef DOXYGEN
3079void expect_not_in_set_count(#function, #parameter, uintmax_t value_array[], intmax_t count);
3080#else
3081#define expect_not_in_set_count(function, parameter, value_array, count) \
3082 do { \
3083 CMOCKA_DEPRECATION_WARNING( \
3084 "expect_not_in_set_count: use expect_int_not_in_set_count or " \
3085 "expect_uint_not_in_set_count instead") \
3086 _expect_not_in_set(cmocka_tostring(function), \
3087 cmocka_tostring(parameter), \
3088 __FILE__, \
3089 __LINE__, \
3090 value_array, \
3091 sizeof(value_array) / sizeof((value_array)[0]), \
3092 count); \
3093 } while (0)
3094#endif
3095
3096#ifdef DOXYGEN
3111void expect_int_not_in_set(#function, #parameter, intmax_t value_array[]);
3112#else
3113#define expect_int_not_in_set(function, parameter, value_array) \
3114 expect_int_not_in_set_count(function, parameter, value_array, 1)
3115#endif
3116
3117#ifdef DOXYGEN
3137 #parameter,
3138 intmax_t value_array[],
3139 intmax_t count);
3140#else
3141#define expect_int_not_in_set_count(function, parameter, value_array, count) \
3142 _expect_int_not_in_set(cmocka_tostring(function), \
3143 cmocka_tostring(parameter), \
3144 __FILE__, \
3145 __LINE__, \
3146 value_array, \
3147 sizeof(value_array) / sizeof((value_array)[0]), \
3148 count)
3149#endif
3150
3151#ifdef DOXYGEN
3166void expect_uint_not_in_set(#function, #parameter, uintmax_t value_array[]);
3167#else
3168#define expect_uint_not_in_set(function, parameter, value_array) \
3169 expect_uint_not_in_set_count(function, parameter, value_array, 1)
3170#endif
3171
3172#ifdef DOXYGEN
3192 #parameter,
3193 uintmax_t value_array[],
3194 intmax_t count);
3195#else
3196#define expect_uint_not_in_set_count(function, parameter, value_array, count) \
3197 _expect_uint_not_in_set(cmocka_tostring(function), \
3198 cmocka_tostring(parameter), \
3199 __FILE__, \
3200 __LINE__, \
3201 value_array, \
3202 sizeof(value_array) / sizeof((value_array)[0]), \
3203 count)
3204#endif
3205
3206#ifdef DOXYGEN
3223void expect_float_in_set(#function, #parameter, double value_array[], double epsilon);
3224#else
3225#define expect_float_in_set(function, parameter, value_array, epsilon) \
3226 expect_float_in_set_count(function, parameter, value_array, epsilon, 1)
3227#endif
3228
3229#ifdef DOXYGEN
3250void expect_float_in_set_count(#function, #parameter, double value_array[], double epsilon, intmax_t count);
3251#else
3252#define expect_float_in_set_count(function, parameter, value_array, epsilon, count) \
3253 _expect_float_in_set(cmocka_tostring(function), \
3254 cmocka_tostring(parameter), \
3255 __FILE__, \
3256 __LINE__, \
3257 value_array, \
3258 sizeof(value_array) / sizeof((value_array)[0]), \
3259 epsilon, \
3260 count)
3261#endif
3262
3263#ifdef DOXYGEN
3280void expect_float_not_in_set(#function, #parameter, double value_array[], double epsilon);
3281#else
3282#define expect_float_not_in_set(function, parameter, value_array, epsilon) \
3283 expect_float_not_in_set_count(function, parameter, value_array, epsilon, 1)
3284#endif
3285
3286#ifdef DOXYGEN
3307void expect_float_not_in_set_count(#function, #parameter, double value_array[], double epsilon, intmax_t count);
3308#else
3309#define expect_float_not_in_set_count(function, parameter, value_array, epsilon, count) \
3310 _expect_float_not_in_set(cmocka_tostring(function), \
3311 cmocka_tostring(parameter), \
3312 __FILE__, \
3313 __LINE__, \
3314 value_array, \
3315 sizeof(value_array) / sizeof((value_array)[0]), \
3316 epsilon, \
3317 count)
3318#endif
3319
3320
3321#ifdef DOXYGEN
3325void expect_in_range(#function, #parameter, uintmax_t minimum, uintmax_t maximum);
3326#else
3327#define expect_in_range(function, parameter, minimum, maximum) \
3328 do { \
3329 CMOCKA_DEPRECATION_WARNING( \
3330 "expect_in_range: use expect_int_in_range or " \
3331 "expect_uint_in_range instead") \
3332 expect_in_range_count(function, parameter, minimum, maximum, 1); \
3333 } while (0)
3334#endif
3335
3336#ifdef DOXYGEN
3340void expect_in_range_count(#function, #parameter, uintmax_t minimum, uintmax_t maximum, intmax_t count);
3341#else
3342#define expect_in_range_count(function, parameter, minimum, maximum, count) \
3343 do { \
3344 CMOCKA_DEPRECATION_WARNING( \
3345 "expect_in_range_count: use expect_int_in_range_count or " \
3346 "expect_uint_in_range_count instead") \
3347 _expect_in_range(cmocka_tostring(function), \
3348 cmocka_tostring(parameter), \
3349 __FILE__, \
3350 __LINE__, \
3351 minimum, \
3352 maximum, \
3353 count); \
3354 } while (0)
3355#endif
3356
3357#ifdef DOXYGEN
3374void expect_int_in_range(#function,
3375#parameter,
3376 intmax_t minimum,
3377 intmax_t maximum);
3378#else
3379#define expect_int_in_range(function, parameter, minimum, maximum) \
3380 expect_int_in_range_count(function, parameter, minimum, maximum, 1)
3381#endif
3382
3383#ifdef DOXYGEN
3405 #parameter,
3406 intmax_t minimum,
3407 intmax_t maximum,
3408 intmax_t count);
3409#else
3410#define expect_int_in_range_count( \
3411 function, parameter, minimum, maximum, count) \
3412 _expect_int_in_range(cmocka_tostring(function), \
3413 cmocka_tostring(parameter), \
3414 __FILE__, \
3415 __LINE__, \
3416 minimum, \
3417 maximum, \
3418 count)
3419#endif
3420
3421#ifdef DOXYGEN
3439#parameter,
3440 uintmax_t minimum,
3441 uintmax_t maximum);
3442#else
3443#define expect_uint_in_range(function, parameter, minimum, maximum) \
3444 expect_uint_in_range_count(function, parameter, minimum, maximum, 1)
3445#endif
3446
3447#ifdef DOXYGEN
3470 #parameter,
3471 uintmax_t minimum,
3472 uintmax_t maximum,
3473 intmax_t count);
3474#else
3475#define expect_uint_in_range_count( \
3476 function, parameter, minimum, maximum, count) \
3477 _expect_uint_in_range(cmocka_tostring(function), \
3478 cmocka_tostring(parameter), \
3479 __FILE__, \
3480 __LINE__, \
3481 minimum, \
3482 maximum, \
3483 count)
3484#endif
3485
3486#ifdef DOXYGEN
3503void expect_not_in_range(#function, #parameter, uintmax_t minimum, uintmax_t maximum);
3504#else
3505#define expect_not_in_range(function, parameter, minimum, maximum) \
3506 expect_not_in_range_count(function, parameter, minimum, maximum, 1)
3507#endif
3508
3509#ifdef DOXYGEN
3530void expect_not_in_range_count(#function, #parameter, uintmax_t minimum, uintmax_t maximum, intmax_t count);
3531#else
3532#define expect_not_in_range_count(function, parameter, minimum, maximum, \
3533 count) \
3534 _expect_not_in_range(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
3535 minimum, maximum, count)
3536#endif
3537
3538#ifdef DOXYGEN
3556 #parameter,
3557 intmax_t minimum,
3558 intmax_t maximum);
3559#else
3560#define expect_int_not_in_range(function, parameter, minimum, maximum) \
3561 expect_int_not_in_range_count(function, parameter, minimum, maximum, 1)
3562#endif
3563
3564#ifdef DOXYGEN
3586 #parameter,
3587 intmax_t minimum,
3588 intmax_t maximum,
3589 intmax_t count);
3590#else
3591#define expect_int_not_in_range_count( \
3592 function, parameter, minimum, maximum, count) \
3593 _expect_int_not_in_range(cmocka_tostring(function), \
3594 cmocka_tostring(parameter), \
3595 __FILE__, \
3596 __LINE__, \
3597 minimum, \
3598 maximum, \
3599 count)
3600#endif
3601
3602#ifdef DOXYGEN
3620 #parameter,
3621 uintmax_t minimum,
3622 uintmax_t maximum);
3623#else
3624#define expect_uint_not_in_range(function, parameter, minimum, maximum) \
3625 expect_uint_not_in_range_count(function, parameter, minimum, maximum, 1)
3626#endif
3627
3628#ifdef DOXYGEN
3651 #parameter,
3652 uintmax_t minimum,
3653 uintmax_t maximum,
3654 intmax_t count);
3655#else
3656#define expect_uint_not_in_range_count( \
3657 function, parameter, minimum, maximum, count) \
3658 _expect_uint_not_in_range(cmocka_tostring(function), \
3659 cmocka_tostring(parameter), \
3660 __FILE__, \
3661 __LINE__, \
3662 minimum, \
3663 maximum, \
3664 count)
3665#endif
3666
3667#ifdef DOXYGEN
3686void expect_float_in_range(#function, #parameter, double minimum, double maximum, double epsilon);
3687#else
3688#define expect_float_in_range(function, parameter, minimum, maximum, epsilon) \
3689 expect_float_in_range_count(function, parameter, minimum, maximum, epsilon, 1)
3690#endif
3691
3692#ifdef DOXYGEN
3715void expect_float_in_range_count(#function, #parameter, double minimum, double maximum, double epsilon, intmax_t count);
3716#else
3717#define expect_float_in_range_count(function, parameter, minimum, maximum, epsilon, count) \
3718 _expect_float_in_range(cmocka_tostring(function), \
3719 cmocka_tostring(parameter), \
3720 __FILE__, \
3721 __LINE__, \
3722 cast_to_double_type(minimum), \
3723 cast_to_double_type(maximum), \
3724 cast_to_double_type(epsilon), \
3725 count)
3726#endif
3727
3728#ifdef DOXYGEN
3747void expect_float_not_in_range(#function, #parameter, double minimum, double maximum, double epsilon);
3748#else
3749#define expect_float_not_in_range(function, parameter, minimum, maximum, epsilon) \
3750 expect_float_not_in_range_count(function, parameter, minimum, maximum, epsilon, 1)
3751#endif
3752
3753#ifdef DOXYGEN
3776void expect_float_not_in_range_count(#function, #parameter, double minimum, double maximum, double epsilon, intmax_t count);
3777#else
3778#define expect_float_not_in_range_count(function, parameter, minimum, maximum, \
3779 epsilon, count) \
3780 _expect_float_not_in_range(cmocka_tostring(function), \
3781 cmocka_tostring(parameter), \
3782 __FILE__, \
3783 __LINE__, \
3784 cast_to_double_type(minimum), \
3785 cast_to_double_type(maximum), \
3786 cast_to_double_type(epsilon), \
3787 count)
3788#endif
3789
3790#ifdef DOXYGEN
3794void expect_value(#function, #parameter, uintmax_t value);
3795#else
3796#define expect_value(function, parameter, value) \
3797 do { \
3798 CMOCKA_DEPRECATION_WARNING("expect_value: use expect_int_value or " \
3799 "expect_uint_value instead") \
3800 expect_value_count(function, parameter, value, 1); \
3801 } while (0)
3802#endif
3803
3804#ifdef DOXYGEN
3808void expect_value_count(#function, #parameter, uintmax_t value, intmax_t count);
3809#else
3810#define expect_value_count(function, parameter, value, count) \
3811 do { \
3812 CMOCKA_DEPRECATION_WARNING( \
3813 "expect_value_count: use expect_int_value_count or " \
3814 "expect_uint_value_count instead") \
3815 _expect_value(cmocka_tostring(function), \
3816 cmocka_tostring(parameter), \
3817 __FILE__, \
3818 __LINE__, \
3819 cast_to_uintmax_type(value), \
3820 count); \
3821 } while (0)
3822#endif
3823
3824#ifdef DOXYGEN
3838void expect_int_value(#function, #parameter, intmax_t value);
3839#else
3840#define expect_int_value(function, parameter, value) \
3841 expect_int_value_count(function, parameter, value, 1)
3842#endif
3843
3844#ifdef DOXYGEN
3864 #parameter,
3865 intmax_t value,
3866 intmax_t count);
3867#else
3868#define expect_int_value_count(function, parameter, value, count) \
3869 _expect_int_value(cmocka_tostring(function), \
3870 cmocka_tostring(parameter), \
3871 __FILE__, \
3872 __LINE__, \
3873 value, \
3874 count)
3875#endif
3876
3877#ifdef DOXYGEN
3892void expect_uint_value(#function, #parameter, uintmax_t value);
3893#else
3894#define expect_uint_value(function, parameter, value) \
3895 expect_uint_value_count(function, parameter, value, 1)
3896#endif
3897
3898#ifdef DOXYGEN
3918 #parameter,
3919 uintmax_t value,
3920 intmax_t count);
3921#else
3922#define expect_uint_value_count(function, parameter, value, count) \
3923 _expect_uint_value(cmocka_tostring(function), \
3924 cmocka_tostring(parameter), \
3925 __FILE__, \
3926 __LINE__, \
3927 value, \
3928 count)
3929#endif
3930
3931#ifdef DOXYGEN
3945void expect_int_not_value(#function, #parameter, intmax_t value);
3946#else
3947#define expect_int_not_value(function, parameter, value) \
3948 expect_int_not_value_count(function, parameter, value, 1)
3949#endif
3950
3951#ifdef DOXYGEN
3971 #parameter,
3972 intmax_t value,
3973 intmax_t count);
3974#else
3975#define expect_int_not_value_count(function, parameter, value, count) \
3976 _expect_int_not_value(cmocka_tostring(function), \
3977 cmocka_tostring(parameter), \
3978 __FILE__, \
3979 __LINE__, \
3980 value, \
3981 count)
3982#endif
3983
3984#ifdef DOXYGEN
3998void expect_uint_not_value(#function, #parameter, uintmax_t value);
3999#else
4000#define expect_uint_not_value(function, parameter, value) \
4001 expect_uint_not_value_count(function, parameter, value, 1)
4002#endif
4003
4004#ifdef DOXYGEN
4024 #parameter,
4025 uintmax_t value,
4026 intmax_t count);
4027#else
4028#define expect_uint_not_value_count(function, parameter, value, count) \
4029 _expect_uint_not_value(cmocka_tostring(function), \
4030 cmocka_tostring(parameter), \
4031 __FILE__, \
4032 __LINE__, \
4033 value, \
4034 count)
4035#endif
4036
4037#ifdef DOXYGEN
4041void expect_not_value(#function, #parameter, uintmax_t value);
4042#else
4043#define expect_not_value(function, parameter, value) \
4044 do { \
4045 CMOCKA_DEPRECATION_WARNING( \
4046 "expect_not_value: use expect_int_not_value or " \
4047 "expect_uint_not_value instead") \
4048 expect_not_value_count(function, parameter, value, 1); \
4049 } while (0)
4050#endif
4051
4052#ifdef DOXYGEN
4056void expect_not_value_count(#function, #parameter, uintmax_t value, intmax_t count);
4057#else
4058#define expect_not_value_count(function, parameter, value, count) \
4059 do { \
4060 CMOCKA_DEPRECATION_WARNING( \
4061 "expect_not_value_count: use expect_int_not_value_count or " \
4062 "expect_uint_not_value_count instead") \
4063 _expect_not_value(cmocka_tostring(function), \
4064 cmocka_tostring(parameter), \
4065 __FILE__, \
4066 __LINE__, \
4067 cast_to_uintmax_type(value), \
4068 count); \
4069 } while (0)
4070#endif
4071
4072#ifdef DOXYGEN
4091void expect_float(#function, #parameter, double value, double epsilon);
4092#else
4093#define expect_float(function, parameter, value, epsilon) \
4094 expect_float_count(function, parameter, cast_to_double_type(value), \
4095 cast_to_double_type(epsilon), 1)
4096#endif
4097
4098#ifdef DOXYGEN
4121void expect_float_count(#function, #parameter, double value, double epsilon, intmax_t count);
4122#else
4123#define expect_float_count(function, parameter, value, epsilon, count) \
4124 _expect_float(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4125 cast_to_double_type(value), cast_to_double_type(epsilon), count)
4126#endif
4127
4128#ifdef DOXYGEN
4148void expect_not_float(#function, #parameter, double value, double epsilon);
4149#else
4150#define expect_not_float(function, parameter, value, epsilon) \
4151 expect_not_float_count(function, \
4152 parameter, \
4153 cast_to_float_type(value), \
4154 cast_to_float_type(epsilon), \
4155 1)
4156#endif
4157
4158#ifdef DOXYGEN
4181void expect_not_float_count(#function, #parameter, double value, double epsilon, intmax_t count);
4182#else
4183#define expect_not_float_count(function, parameter, value, epsilon, count) \
4184 _expect_not_float(cmocka_tostring(function), \
4185 cmocka_tostring(parameter), \
4186 __FILE__, \
4187 __LINE__, \
4188 cast_to_float_type(value), \
4189 cast_to_float_type(epsilon), \
4190 count)
4191#endif
4192
4193#ifdef DOXYGEN
4211void expect_double(#function, #parameter, double value, double epsilon);
4212#else
4213#define expect_double(function, parameter, value, epsilon) \
4214 expect_double_count(function, \
4215 parameter, \
4216 cast_to_double_type(value), \
4217 cast_to_double_type(epsilon), \
4218 1)
4219#endif
4220
4221#ifdef DOXYGEN
4243void expect_double_count(#function,
4244 #parameter,
4245 double value,
4246 double epsilon,
4247 intmax_t count);
4248#else
4249#define expect_double_count(function, parameter, value, epsilon, count) \
4250 _expect_double(cmocka_tostring(function), \
4251 cmocka_tostring(parameter), \
4252 __FILE__, \
4253 __LINE__, \
4254 cast_to_double_type(value), \
4255 cast_to_double_type(epsilon), \
4256 count)
4257#endif
4258
4259#ifdef DOXYGEN
4277void expect_not_double(#function, #parameter, double value, double epsilon);
4278#else
4279#define expect_not_double(function, parameter, value, epsilon) \
4280 expect_not_double_count(function, \
4281 parameter, \
4282 cast_to_double_type(value), \
4283 cast_to_double_type(epsilon), \
4284 1)
4285#endif
4286
4287#ifdef DOXYGEN
4310 #parameter,
4311 double value,
4312 double epsilon,
4313 intmax_t count);
4314#else
4315#define expect_not_double_count(function, parameter, value, epsilon, count) \
4316 _expect_not_double(cmocka_tostring(function), \
4317 cmocka_tostring(parameter), \
4318 __FILE__, \
4319 __LINE__, \
4320 cast_to_double_type(value), \
4321 cast_to_double_type(epsilon), \
4322 count)
4323#endif
4324
4325#ifdef DOXYGEN
4340void expect_string(#function, #parameter, const char *string);
4341#else
4342#define expect_string(function, parameter, string) \
4343 expect_string_count(function, parameter, string, 1)
4344#endif
4345
4346#ifdef DOXYGEN
4365void expect_string_count(#function, #parameter, const char *string, intmax_t count);
4366#else
4367#define expect_string_count(function, parameter, string, count) \
4368 _expect_string(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4369 (const char*)(string), count)
4370#endif
4371
4372#ifdef DOXYGEN
4387void expect_not_string(#function, #parameter, const char *string);
4388#else
4389#define expect_not_string(function, parameter, string) \
4390 expect_not_string_count(function, parameter, string, 1)
4391#endif
4392
4393#ifdef DOXYGEN
4412void expect_not_string_count(#function, #parameter, const char *string, intmax_t count);
4413#else
4414#define expect_not_string_count(function, parameter, string, count) \
4415 _expect_not_string(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4416 (const char*)(string), count)
4417#endif
4418
4419#ifdef DOXYGEN
4435void expect_memory(#function, #parameter, void *memory, size_t size);
4436#else
4437#define expect_memory(function, parameter, memory, size) \
4438 expect_memory_count(function, parameter, memory, size, 1)
4439#endif
4440
4441#ifdef DOXYGEN
4462void expect_memory_count(#function, #parameter, void *memory, size_t size, intmax_t count);
4463#else
4464#define expect_memory_count(function, parameter, memory, size, count) \
4465 _expect_memory(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4466 (const void*)(memory), size, count)
4467#endif
4468
4469#ifdef DOXYGEN
4486void expect_not_memory(#function, #parameter, void *memory, size_t size);
4487#else
4488#define expect_not_memory(function, parameter, memory, size) \
4489 expect_not_memory_count(function, parameter, memory, size, 1)
4490#endif
4491
4492#ifdef DOXYGEN
4513void expect_not_memory_count(#function, #parameter, void *memory, size_t size, intmax_t count);
4514#else
4515#define expect_not_memory_count(function, parameter, memory, size, count) \
4516 _expect_not_memory(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4517 (const void*)(memory), size, count)
4518#endif
4519
4520
4521#ifdef DOXYGEN
4533void expect_any(#function, #parameter);
4534#else
4535#define expect_any(function, parameter) \
4536 expect_any_count(function, parameter, 1)
4537#endif
4538
4539#ifdef DOXYGEN
4551void expect_any_always(#function, #parameter);
4552#else
4553#define expect_any_always(function, parameter) \
4554 expect_any_count(function, parameter, WILL_RETURN_ALWAYS)
4555#endif
4556
4557#ifdef DOXYGEN
4574void expect_any_count(#function, #parameter, intmax_t count);
4575#else
4576#define expect_any_count(function, parameter, count) \
4577 _expect_any(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, count)
4578#endif
4579
4580#ifdef DOXYGEN
4585void check_expected(#parameter);
4586#else
4587#define check_expected(parameter) \
4588 do { \
4589 CMOCKA_DEPRECATION_WARNING( \
4590 "check_expected: use check_expected_int or " \
4591 "check_expected_uint instead") \
4592 _check_expected(__func__, \
4593 #parameter, \
4594 __FILE__, \
4595 __LINE__, \
4596 cast_int_to_cmocka_value(parameter)); \
4597 } while (0)
4598#endif
4599
4600#ifdef DOXYGEN
4628void check_expected_any(#parameter);
4629#else
4630#define check_expected_any(parameter) \
4631 _check_expected(__func__, #parameter, __FILE__, __LINE__, \
4632 cast_ptr_to_cmocka_value(&(parameter)))
4633#endif
4634
4635#ifdef DOXYGEN
4646void check_expected_ptr(#parameter);
4647#else
4648#define check_expected_ptr(parameter) \
4649 _check_expected(__func__, #parameter, __FILE__, __LINE__, \
4650 cast_ptr_to_cmocka_value(parameter))
4651#endif
4652
4653#ifdef DOXYGEN
4664void check_expected_int(#parameter);
4665#else
4666#define check_expected_int(parameter) \
4667 _check_expected(__func__, \
4668 #parameter, \
4669 __FILE__, \
4670 __LINE__, \
4671 assign_int_to_cmocka_value(parameter))
4672#endif
4673
4674#ifdef DOXYGEN
4685void check_expected_uint(#parameter);
4686#else
4687#define check_expected_uint(parameter) \
4688 _check_expected(__func__, \
4689 #parameter, \
4690 __FILE__, \
4691 __LINE__, \
4692 assign_uint_to_cmocka_value(parameter))
4693#endif
4694
4695#ifdef DOXYGEN
4711void check_expected_float(#parameter);
4712#else
4713#define check_expected_float(parameter) \
4714 _check_expected(__func__, \
4715 #parameter, \
4716 __FILE__, \
4717 __LINE__, \
4718 assign_float_to_cmocka_value(parameter))
4719#endif
4720
4721#ifdef DOXYGEN
4737void check_expected_double(#parameter);
4738#else
4739#define check_expected_double(parameter) \
4740 _check_expected(__func__, \
4741 #parameter, \
4742 __FILE__, \
4743 __LINE__, \
4744 assign_double_to_cmocka_value(parameter))
4745#endif
4746 /* cmocka_param */
4748
4771
4772#ifdef DOXYGEN
4785void assert_true(scalar expression);
4786#else
4787#define assert_true(c) _assert_true(cast_to_uintmax_type(c), #c, \
4788 __FILE__, __LINE__)
4789#endif
4790
4791#ifdef DOXYGEN
4803void assert_false(scalar expression);
4804#else
4805#define assert_false(c) _assert_false(cast_to_uintmax_type(c), #c, \
4806 __FILE__, __LINE__)
4807#endif
4808
4809#ifdef DOXYGEN
4822void assert_return_code(intmax_t rc, int32_t error);
4823#else
4824#define assert_return_code(rc, error) \
4825 _assert_return_code((rc), \
4826 (error), \
4827 #rc, __FILE__, __LINE__)
4828#endif
4829
4830#ifdef DOXYGEN
4841void assert_non_null(void *pointer);
4842#else
4843#define assert_non_null(c) assert_ptr_not_equal((c), NULL)
4844#endif
4845
4846#ifdef DOXYGEN
4859void assert_non_null_msg(void *pointer, const char *const message);
4860#else
4861#define assert_non_null_msg(c, msg) assert_ptr_not_equal_msg((c), NULL, (msg))
4862#endif
4863
4864#ifdef DOXYGEN
4875void assert_null(void *pointer);
4876#else
4877#define assert_null(c) assert_ptr_equal((c), NULL)
4878#endif
4879
4880#ifdef DOXYGEN
4893void assert_null_msg(void *pointer, const char *const message);
4894#else
4895#define assert_null_msg(c, msg) assert_ptr_equal_msg((c), NULL, (msg))
4896#endif
4897
4898#ifdef DOXYGEN
4909void assert_ptr_equal(void *a, void *b);
4910#else
4911#define assert_ptr_equal(a, b) assert_ptr_equal_msg((a), (b), NULL)
4912#endif
4913
4914#ifdef DOXYGEN
4927void assert_ptr_equal_msg(void *a, void *b, const char *const msg);
4928#else
4929#define assert_ptr_equal_msg(a, b, msg) \
4930 _assert_ptr_equal_msg(cast_to_void_pointer(a), \
4931 cast_to_void_pointer(b), \
4932 __FILE__, __LINE__, (msg))
4933#endif
4934
4935#ifdef DOXYGEN
4946void assert_ptr_not_equal(void *a, void *b);
4947#else
4948#define assert_ptr_not_equal(a, b) \
4949 assert_ptr_not_equal_msg((a), (b), NULL)
4950#endif
4951
4952#ifdef DOXYGEN
4965void assert_ptr_not_equal_msg(void *a, void *b, const char *const msg);
4966#else /* DOXYGEN */
4967
4968#if defined(__has_builtin)
4969
4970#if __has_builtin(__builtin_unreachable)
4971#define assert_ptr_not_equal_msg(a, b, msg) \
4972 do { \
4973 const void *cmocka_p1 = cast_to_void_pointer(a), \
4974 *cmocka_p2 = cast_to_void_pointer(b); \
4975 _assert_ptr_not_equal_msg( \
4976 cmocka_p1, cmocka_p2, __FILE__, __LINE__, (msg)); \
4977 if (cmocka_p1 == cmocka_p2) { \
4978 __builtin_unreachable(); \
4979 } \
4980 } while (0)
4981#else /* __has_builtin(__builtin_unreachable) */
4982#define assert_ptr_not_equal_msg(a, b, msg) \
4983_assert_ptr_not_equal_msg(cast_to_void_pointer(a), \
4984 cast_to_void_pointer(b), \
4985 __FILE__, \
4986 __LINE__, \
4987 (msg))
4988#endif /* __has_builtin(__builtin_unreachable) */
4989
4990#else /* defined(__has_builtin) */
4991#define assert_ptr_not_equal_msg(a, b, msg) \
4992_assert_ptr_not_equal_msg(cast_to_void_pointer(a), \
4993 cast_to_void_pointer(b), \
4994 __FILE__, \
4995 __LINE__, \
4996 (msg))
4997#endif /* __has_builtin(__builtin_unreachable) */
4998
4999#endif /* DOXYGEN */
5000
5001#ifdef DOXYGEN
5012void assert_int_equal(intmax_t a, intmax_t b);
5013#else
5014#define assert_int_equal(a, b) \
5015 _assert_int_equal(cast_to_intmax_type(a), \
5016 cast_to_intmax_type(b), \
5017 __FILE__, __LINE__)
5018#endif
5019
5020#ifdef DOXYGEN
5031void assert_uint_equal(uintmax_t a, uintmax_t b);
5032#else
5033#define assert_uint_equal(a, b) \
5034 _assert_uint_equal(cast_to_uintmax_type(a), \
5035 cast_to_uintmax_type(b), \
5036 __FILE__, __LINE__)
5037#endif
5038
5039#ifdef DOXYGEN
5052void assert_int_not_equal(intmax_t a, intmax_t b);
5053#else
5054#define assert_int_not_equal(a, b) \
5055 _assert_int_not_equal(cast_to_intmax_type(a), \
5056 cast_to_intmax_type(b), \
5057 __FILE__, __LINE__)
5058#endif
5059
5060#ifdef DOXYGEN
5071void assert_uint_not_equal(uintmax_t a, uintmax_t b);
5072#else
5073#define assert_uint_not_equal(a, b) \
5074 _assert_uint_not_equal(cast_to_uintmax_type(a), \
5075 cast_to_uintmax_type(b), \
5076 __FILE__, __LINE__)
5077#endif
5078
5079#ifdef DOXYGEN
5092void assert_float_equal(float a, float b, float epsilon);
5093#else
5094#define assert_float_equal(a, b, epsilon) \
5095 _assert_float_equal((float)a, \
5096 (float)b, \
5097 (float)epsilon, \
5098 __FILE__, __LINE__)
5099#endif
5100
5101#ifdef DOXYGEN
5114void assert_float_not_equal(float a, float b, float epsilon);
5115#else
5116#define assert_float_not_equal(a, b, epsilon) \
5117 _assert_float_not_equal((float)a, \
5118 (float)b, \
5119 (float)epsilon, \
5120 __FILE__, __LINE__)
5121#endif
5122
5123#ifdef DOXYGEN
5136void assert_double_equal(double a, double b, double epsilon);
5137#else
5138#define assert_double_equal(a, b, epsilon) \
5139 _assert_double_equal((double)a, \
5140 (double)b, \
5141 (double)epsilon, \
5142 __FILE__, __LINE__)
5143#endif
5144
5145#ifdef DOXYGEN
5158void assert_double_not_equal(double a, double b, double epsilon);
5159#else
5160#define assert_double_not_equal(a, b, epsilon) \
5161 _assert_double_not_equal((double)a, \
5162 (double)b, \
5163 (double)epsilon, \
5164 __FILE__, __LINE__)
5165#endif
5166
5167
5168#ifdef DOXYGEN
5181void assert_string_equal(const char *a, const char *b);
5182#else
5183#define assert_string_equal(a, b) \
5184 _assert_string_equal((a), (b), __FILE__, __LINE__)
5185#endif
5186
5187#ifdef DOXYGEN
5200void assert_string_not_equal(const char *a, const char *b);
5201#else
5202#define assert_string_not_equal(a, b) \
5203 _assert_string_not_equal((a), (b), __FILE__, __LINE__)
5204#endif
5205
5206#ifdef DOXYGEN
5221void assert_memory_equal(const void *a, const void *b, size_t size);
5222#else
5223#define assert_memory_equal(a, b, size) \
5224 _assert_memory_equal((const void*)(a), (const void*)(b), size, __FILE__, \
5225 __LINE__)
5226#endif
5227
5228#ifdef DOXYGEN
5243void assert_memory_not_equal(const void *a, const void *b, size_t size);
5244#else
5245#define assert_memory_not_equal(a, b, size) \
5246 _assert_memory_not_equal((const void*)(a), (const void*)(b), size, \
5247 __FILE__, __LINE__)
5248#endif
5249
5250#ifdef DOXYGEN
5264void assert_int_in_range(intmax_t value, intmax_t minimum, intmax_t maximum);
5265#else
5266#define assert_int_in_range(value, minimum, maximum) \
5267 _assert_int_in_range( \
5268 cast_to_intmax_type(value), \
5269 cast_to_intmax_type(minimum), \
5270 cast_to_intmax_type(maximum), __FILE__, __LINE__)
5271#endif
5272
5273#ifdef DOXYGEN
5287void assert_uint_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum);
5288#else
5289#define assert_uint_in_range(value, minimum, maximum) \
5290 _assert_uint_in_range( \
5291 cast_to_uintmax_type(value), \
5292 cast_to_uintmax_type(minimum), \
5293 cast_to_uintmax_type(maximum), __FILE__, __LINE__)
5294#endif
5295
5296#ifdef DOXYGEN
5313void assert_int_not_in_range(intmax_t value,
5314 intmax_t minimum,
5315 intmax_t maximum);
5316#else
5317#define assert_int_not_in_range(value, minimum, maximum) \
5318 _assert_int_not_in_range(cast_to_intmax_type(value), \
5319 cast_to_intmax_type(minimum), \
5320 cast_to_intmax_type(maximum), \
5321 __FILE__, \
5322 __LINE__)
5323#endif
5324
5325#ifdef DOXYGEN
5342void assert_uint_not_in_range(uintmax_t value,
5343 uintmax_t minimum,
5344 uintmax_t maximum);
5345#else
5346#define assert_uint_not_in_range(value, minimum, maximum) \
5347 _assert_uint_not_in_range(cast_to_uintmax_type(value), \
5348 cast_to_uintmax_type(minimum), \
5349 cast_to_uintmax_type(maximum), \
5350 __FILE__, \
5351 __LINE__)
5352#endif
5353
5354#ifdef DOXYGEN
5358void assert_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum);
5359#else
5360#define assert_in_range(value, minimum, maximum) \
5361 do { \
5362 CMOCKA_DEPRECATION_WARNING( \
5363 "assert_in_range: use assert_int_in_range or " \
5364 "assert_uint_in_range instead") \
5365 _assert_uint_in_range(cast_to_uintmax_type(value), \
5366 cast_to_uintmax_type(minimum), \
5367 cast_to_uintmax_type(maximum), \
5368 __FILE__, \
5369 __LINE__); \
5370 } while (0)
5371#endif
5372
5373#ifdef DOXYGEN
5377void assert_not_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum);
5378#else
5379#define assert_not_in_range(value, minimum, maximum) \
5380 do { \
5381 CMOCKA_DEPRECATION_WARNING( \
5382 "assert_not_in_range: use assert_int_not_in_range or " \
5383 "assert_uint_not_in_range instead") \
5384 _assert_uint_not_in_range(cast_to_uintmax_type(value), \
5385 cast_to_uintmax_type(minimum), \
5386 cast_to_uintmax_type(maximum), \
5387 __FILE__, \
5388 __LINE__); \
5389 } while (0)
5390#endif
5391
5392#ifdef DOXYGEN
5411void assert_float_not_in_range(double value, double minimum, double maximum, double epsilon);
5412#else
5413#define assert_float_not_in_range(value, minimum, maximum, epsilon) \
5414 _assert_float_not_in_range(cast_to_double_type(value), \
5415 cast_to_double_type(minimum), \
5416 cast_to_double_type(maximum), \
5417 cast_to_double_type(epsilon), \
5418 __FILE__, \
5419 __LINE__)
5420#endif
5421
5422#ifdef DOXYGEN
5438void assert_float_in_range(double value, double minimum, double maximum, double epsilon);
5439#else
5440#define assert_float_in_range(value, minimum, maximum, epsilon) \
5441 _assert_float_in_range( \
5442 cast_to_double_type(value), \
5443 cast_to_double_type(minimum), \
5444 cast_to_double_type(maximum), \
5445 cast_to_double_type(epsilon), __FILE__, __LINE__)
5446#endif
5447
5448#ifdef DOXYGEN
5452void assert_in_set(uintmax_t value, uintmax_t values[], intmax_t count);
5453#else
5454#define assert_in_set(value, values, number_of_values) \
5455 do { \
5456 CMOCKA_DEPRECATION_WARNING("assert_in_set: use assert_int_in_set or " \
5457 "assert_uint_in_set instead") \
5458 _assert_uint_in_set( \
5459 value, values, number_of_values, __FILE__, __LINE__); \
5460 } while (0)
5461#endif
5462
5463#ifdef DOXYGEN
5476void assert_not_in_set(uintmax_t value, uintmax_t values[], intmax_t count);
5477#else
5478#define assert_not_in_set(value, values, number_of_values) \
5479 _assert_not_in_set(value, values, number_of_values, __FILE__, __LINE__)
5480#endif
5481
5482#ifdef DOXYGEN
5495void assert_int_in_set(intmax_t value, intmax_t values[], intmax_t count);
5496#else
5497#define assert_int_in_set(value, values, number_of_values) \
5498 if (number_of_values > 0) { \
5499 intmax_t _cmocka_set[number_of_values]; \
5500 for (size_t _i = 0; _i < number_of_values; _i++) { \
5501 _cmocka_set[_i] = values[_i]; \
5502 } \
5503 _assert_int_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5504 }
5505#endif
5506
5507#ifdef DOXYGEN
5520void assert_int_not_in_set(intmax_t value, intmax_t values[], intmax_t count);
5521#else
5522#define assert_int_not_in_set(value, values, number_of_values) \
5523 if (number_of_values > 0) { \
5524 intmax_t _cmocka_set[number_of_values]; \
5525 for (size_t _i = 0; _i < number_of_values; _i++) { \
5526 _cmocka_set[_i] = values[_i]; \
5527 } \
5528 _assert_int_not_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5529 }
5530#endif
5531
5532#ifdef DOXYGEN
5545void assert_uint_in_set(uintmax_t value, uintmax_t values[], intmax_t count);
5546#else
5547#define assert_uint_in_set(value, values, number_of_values) \
5548 if (number_of_values > 0) { \
5549 uintmax_t _cmocka_set[number_of_values]; \
5550 for (size_t _i = 0; _i < number_of_values; _i++) { \
5551 _cmocka_set[_i] = values[_i]; \
5552 } \
5553 _assert_uint_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5554 }
5555#endif
5556
5557#ifdef DOXYGEN
5570void assert_uint_not_in_set(uintmax_t value, uintmax_t values[], intmax_t count);
5571#else
5572#define assert_uint_not_in_set(value, values, number_of_values) \
5573 if (number_of_values > 0) { \
5574 uintmax_t _cmocka_set[number_of_values]; \
5575 for (size_t _i = 0; _i < number_of_values; _i++) { \
5576 _cmocka_set[_i] = values[_i]; \
5577 } \
5578 _assert_uint_not_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5579 }
5580#endif
5581
5582#ifdef DOXYGEN
5597void assert_float_in_set(double value, double values[], intmax_t count, double epsilon);
5598#else
5599#define assert_float_in_set(value, values, number_of_values, epsilon) \
5600 if (number_of_values > 0) { \
5601 double _cmocka_set[number_of_values]; \
5602 for (size_t _i = 0; _i < number_of_values; _i++) { \
5603 _cmocka_set[_i] = values[_i]; \
5604 } \
5605 _assert_float_in_set(value, _cmocka_set, number_of_values, epsilon, __FILE__, __LINE__); \
5606 }
5607#endif
5608
5609#ifdef DOXYGEN
5624void assert_float_not_in_set(double value, double values[], intmax_t count, double epsilon);
5625#else
5626#define assert_float_not_in_set(value, values, number_of_values, epsilon) \
5627 if (number_of_values > 0) { \
5628 double _cmocka_set[number_of_values]; \
5629 for (size_t _i = 0; _i < number_of_values; _i++) { \
5630 _cmocka_set[_i] = values[_i]; \
5631 } \
5632 _assert_float_not_in_set(value, _cmocka_set, number_of_values, epsilon, __FILE__, __LINE__); \
5633 }
5634#endif
5635 /* cmocka_asserts */
5637
5701
5702#ifdef DOXYGEN
5710#else
5711#define function_called() _function_called(__func__, __FILE__, __LINE__)
5712#endif
5713
5714#ifdef DOXYGEN
5725void expect_function_calls(#function, const int times);
5726#else
5727#define expect_function_calls(function, times) \
5728 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, times)
5729#endif
5730
5731#ifdef DOXYGEN
5740void expect_function_call(#function);
5741#else
5742#define expect_function_call(function) \
5743 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, 1)
5744#endif
5745
5746#ifdef DOXYGEN
5755#else
5756#define expect_function_call_any(function) \
5757 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, -1)
5758#endif
5759
5760#ifdef DOXYGEN
5769#else
5770#define ignore_function_calls(function) \
5771 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, -2)
5772#endif
5773 /* cmocka_call_order */
5775
5807
5808#ifdef DOXYGEN
5812void fail(void);
5813#else
5814#define fail() _fail(__FILE__, __LINE__)
5815#endif
5816
5817#ifdef DOXYGEN
5821void skip(void);
5822#else
5823#define skip() _skip(__FILE__, __LINE__)
5824#endif
5825
5826#ifdef DOXYGEN
5835void stop(void);
5836#else
5837#define stop() _stop()
5838#endif
5839
5840#ifdef DOXYGEN
5855void fail_msg(const char *msg, ...);
5856#else
5857#define fail_msg(...) do { \
5858 cmocka_print_error("ERROR: "); \
5859 cmocka_print_error(__VA_ARGS__); \
5860 cmocka_print_error("\n"); \
5861 fail(); \
5862} while (0)
5863#endif
5864
5865static inline void _unit_test_dummy(void **state) {
5866 (void)state;
5867}
5868
5873#define unit_test(f) \
5874 (CMOCKA_DEPRECATION_WARNING("unit_test: use cmocka_unit_test instead")( \
5875 UnitTest){#f, f, UNIT_TEST_FUNCTION_TYPE_TEST})
5876
5878#define _unit_test_setup(test, setup) \
5879 { #test "_" #setup, setup, UNIT_TEST_FUNCTION_TYPE_SETUP }
5881
5886#define unit_test_setup(test, setup) \
5887 CMOCKA_DEPRECATION_WARNING( \
5888 "unit_test_setup: use cmocka_unit_test_setup instead") \
5889 _unit_test_setup(test, setup), unit_test(test), \
5890 _unit_test_teardown(test, _unit_test_dummy)
5891
5893#define _unit_test_teardown(test, teardown) \
5894 { #test "_" #teardown, teardown, UNIT_TEST_FUNCTION_TYPE_TEARDOWN }
5896
5901#define unit_test_teardown(test, teardown) \
5902 CMOCKA_DEPRECATION_WARNING( \
5903 "unit_test_teardown: use cmocka_unit_test_teardown instead") \
5904 _unit_test_setup(test, _unit_test_dummy), unit_test(test), \
5905 _unit_test_teardown(test, teardown)
5906
5911#define group_test_setup(setup) \
5912 (CMOCKA_DEPRECATION_WARNING( \
5913 "group_test_setup: use cmocka_run_group_tests instead")(UnitTest){ \
5914 "group_" #setup, setup, UNIT_TEST_FUNCTION_TYPE_GROUP_SETUP})
5915
5920#define group_test_teardown(teardown) \
5921 (CMOCKA_DEPRECATION_WARNING( \
5922 "group_test_teardown: use cmocka_run_group_tests instead")(UnitTest){ \
5923 "group_" #teardown, teardown, UNIT_TEST_FUNCTION_TYPE_GROUP_TEARDOWN})
5924
5932#define unit_test_setup_teardown(test, setup, teardown) \
5933 CMOCKA_DEPRECATION_WARNING("unit_test_setup_teardown: use " \
5934 "cmocka_unit_test_setup_teardown instead") \
5935 _unit_test_setup(test, setup), unit_test(test), \
5936 _unit_test_teardown(test, teardown)
5937
5939#define cmocka_unit_test(f) { #f, f, NULL, NULL, NULL }
5940
5942#define cmocka_unit_test_setup(f, setup) { #f, f, setup, NULL, NULL }
5943
5945#define cmocka_unit_test_teardown(f, teardown) { #f, f, NULL, teardown, NULL }
5946
5951#define cmocka_unit_test_setup_teardown(f, setup, teardown) { #f, f, setup, teardown, NULL }
5952
5960#define cmocka_unit_test_prestate(f, state) { #f, f, NULL, NULL, state }
5961
5969#define cmocka_unit_test_prestate_setup_teardown(f, setup, teardown, state) { #f, f, setup, teardown, state }
5970
5971#ifdef DOXYGEN
6028int cmocka_run_group_tests(const struct CMUnitTest group_tests[],
6029 CMFixtureFunction group_setup,
6030 CMFixtureFunction group_teardown);
6031#else
6032# define cmocka_run_group_tests(group_tests, group_setup, group_teardown) \
6033 _cmocka_run_group_tests(#group_tests, group_tests, sizeof(group_tests) / sizeof((group_tests)[0]), group_setup, group_teardown)
6034#endif
6035
6036#ifdef DOXYGEN
6096int cmocka_run_group_tests_name(const char *group_name,
6097 const struct CMUnitTest group_tests[],
6098 CMFixtureFunction group_setup,
6099 CMFixtureFunction group_teardown);
6100#else
6101# define cmocka_run_group_tests_name(group_name, group_tests, group_setup, group_teardown) \
6102 _cmocka_run_group_tests(group_name, group_tests, sizeof(group_tests) / sizeof((group_tests)[0]), group_setup, group_teardown)
6103#endif
6104 /* cmocka_exec */
6106
6166
6167#ifdef DOXYGEN
6190void *test_malloc(size_t size);
6191#else
6192#define test_malloc(size) _test_malloc(size, __FILE__, __LINE__)
6193#endif
6194
6195#ifdef DOXYGEN
6209void *test_calloc(size_t nmemb, size_t size);
6210#else
6211#define test_calloc(num, size) _test_calloc(num, size, __FILE__, __LINE__)
6212#endif
6213
6214#ifdef DOXYGEN
6225void *test_realloc(void *ptr, size_t size);
6226#else
6227#define test_realloc(ptr, size) _test_realloc(ptr, size, __FILE__, __LINE__)
6228#endif
6229
6230#ifdef DOXYGEN
6238void test_free(void *ptr);
6239#else
6240#define test_free(ptr) _test_free(ptr, __FILE__, __LINE__)
6241#endif
6242
6243#if defined(UNIT_TESTING) && defined(ALLOCATION_TESTING)
6244#define malloc test_malloc
6245#define realloc test_realloc
6246#define calloc test_calloc
6247#define free test_free
6248#endif /* UNIT_TESTING && ALLOCATION_TESTING */
6249 /* cmocka_alloc */
6251
6269
6303void mock_assert(const int result, const char* const expression,
6304 const char * const file, const size_t line);
6305
6306#ifdef DOXYGEN
6329void expect_assert_failure(function fn_call);
6330#else
6331#define expect_assert_failure(function_call) \
6332 { \
6333 global_expecting_assert = 1; \
6334 if (setjmp(global_expect_assert_env) != 0) { \
6335 print_message("Expected assertion %s occurred\n", \
6336 global_last_failed_assert); \
6337 global_expecting_assert = 0; \
6338 } else { \
6339 function_call ; \
6340 global_expecting_assert = 0; \
6341 print_error("Expected assert in %s\n", #function_call); \
6342 _fail(__FILE__, __LINE__); \
6343 } \
6344 }
6345#endif
6346 /* cmocka_mock_assert */
6348
6357typedef union {
6359 intmax_t int_val;
6361 uintmax_t uint_val;
6365 double real_val; // TODO: Should we use `long double` instead
6367 void *ptr;
6369 const void *const_ptr;
6370 // The following aren't used by CMocka currently, but are added to avoid
6371 // breaking ABI compatibility in the future
6373 void *(*func)(void);
6375
6376#ifndef DOXYGEN
6381#define LargestIntegralType uintmax_t
6382
6386#if defined(__GNUC__)
6387#define cast_ptr_to_largest_integral_type(value) \
6388 __extension__({ \
6389 CMOCKA_DEPRECATION_WARNING( \
6390 "cast_ptr_to_largest_integral_type: " \
6391 "use cast_ptr_to_uintmax_type instead"); \
6392 cast_ptr_to_uintmax_type(value); \
6393 })
6394#else
6395#define cast_ptr_to_largest_integral_type(value) \
6396 cast_ptr_to_uintmax_type(value)
6397#endif
6398#endif
6399
6405typedef void (*UnitTestFunction)(void **state);
6406
6412typedef int (*CheckParameterValue)(const uintmax_t value,
6413 const uintmax_t check_value_data);
6414
6420typedef int (*CheckParameterValueData)(const CMockaValueData value,
6421 const CMockaValueData check_value_data);
6422
6428typedef int (*CheckIntParameterValue)(const intmax_t value,
6429 const intmax_t check_value_data);
6430
6436typedef int (*CheckUintParameterValue)(const uintmax_t value,
6437 const uintmax_t check_value_data);
6438
6445 UNIT_TEST_FUNCTION_TYPE_TEST = 0,
6446 UNIT_TEST_FUNCTION_TYPE_SETUP,
6447 UNIT_TEST_FUNCTION_TYPE_TEARDOWN,
6448 UNIT_TEST_FUNCTION_TYPE_GROUP_SETUP,
6449 UNIT_TEST_FUNCTION_TYPE_GROUP_TEARDOWN,
6451
6459typedef struct UnitTest {
6460 const char* name;
6461 UnitTestFunction function;
6462 UnitTestFunctionType function_type;
6464
6468typedef struct GroupTest {
6469 UnitTestFunction setup;
6470 UnitTestFunction teardown;
6471 const UnitTest *tests;
6472 const size_t number_of_tests;
6473} GroupTest;
6474
6480typedef void (*CMUnitTestFunction)(void **state);
6481
6487typedef int (*CMFixtureFunction)(void **state);
6488
6493 const char *name;
6494 CMUnitTestFunction test_func;
6495 CMFixtureFunction setup_func;
6496 CMFixtureFunction teardown_func;
6497 void *initial_state;
6498};
6499
6505typedef struct SourceLocation {
6506 const char* file;
6507 size_t line;
6509
6515typedef struct CheckParameterEvent {
6516 SourceLocation location;
6517 const char *parameter_name;
6518 CheckParameterValue check_value;
6519 uintmax_t check_value_data;
6521
6528 SourceLocation location;
6529 const char *parameter_name;
6530 CheckParameterValueData check_value;
6531 CMockaValueData check_value_data;
6533
6547
6548/* Standard output and error print methods. */
6549void print_message(const char* const format, ...) CMOCKA_PRINTF_ATTRIBUTE(1, 2);
6550void print_error(const char* const format, ...) CMOCKA_PRINTF_ATTRIBUTE(1, 2);
6551void vprint_message(const char* const format, va_list args) CMOCKA_PRINTF_ATTRIBUTE(1, 0);
6552void vprint_error(const char* const format, va_list args) CMOCKA_PRINTF_ATTRIBUTE(1, 0);
6553
6568 void (*vprint_message)(const char * const format, va_list args);
6569
6577 void (*vprint_error)(const char * const format, va_list args);
6578};
6579
6594void cmocka_set_callbacks(const struct CMCallbacks *f_callbacks);
6595
6608 CM_OUTPUT_STDOUT = 0x00000001,
6610 CM_OUTPUT_SUBUNIT = 0x00000002,
6612 CM_OUTPUT_TAP = 0x00000004,
6614 CM_OUTPUT_XML = 0x00000008,
6615};
6616
6617#ifdef DOXYGEN
6621void cm_print_error(const char* const format, ...);
6622#else
6623#define cm_print_error(...) \
6624 do { \
6625 CMOCKA_DEPRECATION_WARNING( \
6626 "cm_print_error: use cmocka_print_error instead") \
6627 cmocka_print_error(__VA_ARGS__); \
6628 } while (0)
6629#endif
6630
6643void cmocka_print_error(const char* const format, ...) CMOCKA_PRINTF_ATTRIBUTE(1, 2);
6644
6661void cmocka_set_message_output(uint32_t output);
6662
6663
6679void cmocka_set_test_filter(const char *pattern);
6680
6696void cmocka_set_skip_filter(const char *pattern);
6697 /* cmocka_config */
6699
6709
6710/* Used by expect_assert_failure() and mock_assert(). */
6711CMOCKA_DLLEXTERN extern int global_expecting_assert;
6712CMOCKA_DLLEXTERN extern jmp_buf global_expect_assert_env;
6713CMOCKA_DLLEXTERN extern const char * global_last_failed_assert;
6714
6715/* Retrieves a value for the given function, as set by "will_return". */
6716CMockaValueData _mock(const char *const function,
6717 const char *const file,
6718 const size_t line,
6719 const char *name);
6720
6721CMockaValueData _mock_parameter(const char *const function,
6722 const char *name,
6723 const char *const file,
6724 const size_t line,
6725 const char *type);
6726
6727bool _has_mock(const char *const function);
6728
6729void _expect_function_call(
6730 const char * const function_name,
6731 const char * const file,
6732 const size_t line,
6733 const int count);
6734
6735void _function_called(const char * const function, const char* const file,
6736 const size_t line);
6737
6738/* Old API function using uintmax_t */
6739void _expect_check(
6740 const char* const function, const char* const parameter,
6741 const char* const file, const size_t line,
6742 const CheckParameterValue check_function,
6743 const uintmax_t check_data, CheckParameterEvent * const event,
6744 const int count) CMOCKA_DEPRECATED;
6745
6746/* New API function using CMockaValueData */
6747void _expect_check_data(
6748 const char* const function, const char* const parameter,
6749 const char* const file, const size_t line,
6750 const CheckParameterValueData check_function,
6751 const CMockaValueData check_data, CheckParameterEventData * const event,
6752 const int count);
6753
6754void _expect_int_in_set(const char *const function,
6755 const char *const parameter,
6756 const char *const file,
6757 const size_t line,
6758 const intmax_t values[],
6759 const size_t number_of_values,
6760 const intmax_t count);
6761void _expect_uint_in_set(const char *const function,
6762 const char *const parameter,
6763 const char *const file,
6764 const size_t line,
6765 const uintmax_t values[],
6766 const size_t number_of_values,
6767 const intmax_t count);
6768
6769void _expect_float_in_set(const char *const function,
6770 const char *const parameter,
6771 const char *const file,
6772 const size_t line,
6773 const double values[],
6774 const size_t number_of_values,
6775 const double epsilon,
6776 const intmax_t count);
6777
6778void _expect_not_in_set(
6779 const char* const function, const char* const parameter,
6780 const char* const file, const size_t line, const uintmax_t values[],
6781 const size_t number_of_values, const int count);
6782void _expect_int_not_in_set(const char *const function,
6783 const char *const parameter,
6784 const char *const file,
6785 const size_t line,
6786 const intmax_t values[],
6787 const size_t number_of_values,
6788 const intmax_t count);
6789void _expect_uint_not_in_set(const char *const function,
6790 const char *const parameter,
6791 const char *const file,
6792 const size_t line,
6793 const uintmax_t values[],
6794 const size_t number_of_values,
6795 const intmax_t count);
6796
6797void _expect_float_not_in_set(
6798 const char* const function, const char* const parameter,
6799 const char* const file, const size_t line, const double values[],
6800 const size_t number_of_values, const double epsilon, const intmax_t count);
6801
6802void _expect_in_range(const char *const function,
6803 const char *const parameter,
6804 const char *const file,
6805 const size_t line,
6806 const uintmax_t minimum,
6807 const uintmax_t maximum,
6808 const int count) CMOCKA_DEPRECATED;
6809void _expect_int_in_range(const char *const function,
6810 const char *const parameter,
6811 const char *const file,
6812 const size_t line,
6813 const intmax_t minimum,
6814 const intmax_t maximum,
6815 const intmax_t count);
6816void _expect_uint_in_range(const char *const function,
6817 const char *const parameter,
6818 const char *const file,
6819 const size_t line,
6820 const uintmax_t minimum,
6821 const uintmax_t maximum,
6822 const intmax_t count);
6823void _expect_not_in_range(
6824 const char* const function, const char* const parameter,
6825 const char* const file, const size_t line,
6826 const uintmax_t minimum,
6827 const uintmax_t maximum, const int count);
6828void _expect_int_not_in_range(const char *const function,
6829 const char *const parameter,
6830 const char *const file,
6831 const size_t line,
6832 const intmax_t minimum,
6833 const intmax_t maximum,
6834 const intmax_t count);
6835void _expect_uint_not_in_range(const char *const function,
6836 const char *const parameter,
6837 const char *const file,
6838 const size_t line,
6839 const uintmax_t minimum,
6840 const uintmax_t maximum,
6841 const intmax_t count);
6842void _expect_float_in_range(
6843 const char* const function, const char* const parameter,
6844 const char* const file, const size_t line,
6845 const double minimum, const double maximum, const double epsilon,
6846 const int count);
6847void _expect_float_not_in_range(
6848 const char* const function, const char* const parameter,
6849 const char* const file, const size_t line,
6850 const double minimum, const double maximum, const double epsilon,
6851 const int count);
6852
6853void _expect_value(
6854 const char* const function, const char* const parameter,
6855 const char* const file, const size_t line, const uintmax_t value,
6856 const int count);
6857void _expect_int_value(const char *const function,
6858 const char *const parameter,
6859 const char *const file,
6860 const size_t line,
6861 const intmax_t value,
6862 const intmax_t count);
6863void _expect_uint_value(const char *const function,
6864 const char *const parameter,
6865 const char *const file,
6866 const size_t line,
6867 const uintmax_t value,
6868 const intmax_t count);
6869void _expect_int_not_value(const char *const function,
6870 const char *const parameter,
6871 const char *const file,
6872 const size_t line,
6873 const intmax_t value,
6874 const intmax_t count);
6875void _expect_uint_not_value(const char *const function,
6876 const char *const parameter,
6877 const char *const file,
6878 const size_t line,
6879 const uintmax_t value,
6880 const intmax_t count);
6881void _expect_not_value(
6882 const char* const function, const char* const parameter,
6883 const char* const file, const size_t line, const uintmax_t value,
6884 const int count);
6885
6886void _expect_float(
6887 const char* const function, const char* const parameter,
6888 const char* const file, const size_t line, const double value,
6889 const double epsilon, const int count);
6890void _expect_not_float(
6891 const char* const function, const char* const parameter,
6892 const char* const file, const size_t line, const double value,
6893 const double epsilon, const int count);
6894
6895void _expect_double(const char *const function,
6896 const char *const parameter,
6897 const char *const file,
6898 const size_t line,
6899 const double value,
6900 const double epsilon,
6901 const int count);
6902void _expect_not_double(const char *const function,
6903 const char *const parameter,
6904 const char *const file,
6905 const size_t line,
6906 const double value,
6907 const double epsilon,
6908 const int count);
6909
6910void _expect_string(
6911 const char* const function, const char* const parameter,
6912 const char* const file, const size_t line, const char* string,
6913 const int count);
6914void _expect_not_string(
6915 const char* const function, const char* const parameter,
6916 const char* const file, const size_t line, const char* string,
6917 const int count);
6918
6919void _expect_memory(
6920 const char* const function, const char* const parameter,
6921 const char* const file, const size_t line, const void* const memory,
6922 const size_t size, const int count);
6923void _expect_not_memory(
6924 const char* const function, const char* const parameter,
6925 const char* const file, const size_t line, const void* const memory,
6926 const size_t size, const int count);
6927
6928void _expect_any(
6929 const char* const function, const char* const parameter,
6930 const char* const file, const size_t line, const int count);
6931
6932void _check_expected(
6933 const char * const function_name, const char * const parameter_name,
6934 const char* file, const size_t line, const CMockaValueData value);
6935
6936void _will_return(const char *const function_name,
6937 const char *const file,
6938 const size_t line,
6939 const char *name,
6940 const CMockaValueData value,
6941 const int count);
6942void _will_set_parameter(const char *const function_name,
6943 const char *name,
6944 const char *const file,
6945 const size_t line,
6946 const char *type,
6947 const CMockaValueData value,
6948 const int count);
6949void _assert_true(const uintmax_t result,
6950 const char* const expression,
6951 const char * const file, const size_t line);
6952void _assert_false(const uintmax_t result,
6953 const char * const expression,
6954 const char * const file, const size_t line);
6955void _assert_return_code(const intmax_t result,
6956 const int32_t error,
6957 const char * const expression,
6958 const char * const file,
6959 const size_t line);
6960void _assert_float_equal(const float a, const float n,
6961 const float epsilon, const char* const file,
6962 const size_t line);
6963void _assert_float_not_equal(const float a, const float n,
6964 const float epsilon, const char* const file,
6965 const size_t line);
6966void _assert_double_equal(const double a, const double n,
6967 const double epsilon, const char* const file,
6968 const size_t line);
6969void _assert_double_not_equal(const double a, const double n,
6970 const double epsilon, const char* const file,
6971 const size_t line);
6972void _assert_int_equal(const intmax_t a,
6973 const intmax_t b,
6974 const char * const file,
6975 const size_t line);
6976void _assert_int_not_equal(const intmax_t a,
6977 const intmax_t b,
6978 const char * const file,
6979 const size_t line);
6980void _assert_uint_equal(const uintmax_t a,
6981 const uintmax_t b,
6982 const char * const file,
6983 const size_t line);
6984void _assert_uint_not_equal(const uintmax_t a,
6985 const uintmax_t b,
6986 const char * const file,
6987 const size_t line);
6988CMOCKA_NO_ACCESS_ATTRIBUTE
6989void _assert_ptr_equal_msg(const void *a,
6990 const void *b,
6991 const char *const file,
6992 const size_t line,
6993 const char *const msg);
6994CMOCKA_NO_ACCESS_ATTRIBUTE
6995void _assert_ptr_not_equal_msg(const void *a,
6996 const void *b,
6997 const char *const file,
6998 const size_t line,
6999 const char *const msg);
7000void _assert_string_equal(const char * const a, const char * const b,
7001 const char * const file, const size_t line);
7002void _assert_string_not_equal(const char * const a, const char * const b,
7003 const char *file, const size_t line);
7004void _assert_memory_equal(const void * const a, const void * const b,
7005 const size_t size, const char* const file,
7006 const size_t line);
7007void _assert_memory_not_equal(const void * const a, const void * const b,
7008 const size_t size, const char* const file,
7009 const size_t line);
7010void _assert_int_in_range(const intmax_t value,
7011 const intmax_t minimum,
7012 const intmax_t maximum,
7013 const char* const file,
7014 const size_t line);
7015void _assert_int_not_in_range(const intmax_t value,
7016 const intmax_t minimum,
7017 const intmax_t maximum,
7018 const char *const file,
7019 const size_t line);
7020void _assert_uint_in_range(const uintmax_t value,
7021 const uintmax_t minimum,
7022 const uintmax_t maximum,
7023 const char* const file,
7024 const size_t line);
7025void _assert_uint_not_in_range(const uintmax_t value,
7026 const uintmax_t minimum,
7027 const uintmax_t maximum,
7028 const char* const file,
7029 const size_t line);
7030void _assert_float_in_range(const double value,
7031 const double minimum,
7032 const double maximum,
7033 const double epsilon,
7034 const char* const file,
7035 const size_t line);
7036void _assert_float_not_in_range(const double value,
7037 const double minimum,
7038 const double maximum,
7039 const double epsilon,
7040 const char* const file,
7041 const size_t line);
7042void _assert_not_in_set(
7043 const uintmax_t value, const uintmax_t values[],
7044 const size_t number_of_values, const char* const file, const size_t line);
7045void _assert_int_in_set(const intmax_t value,
7046 const intmax_t values[],
7047 const size_t number_of_values,
7048 const char *const file,
7049 const size_t line);
7050void _assert_int_not_in_set(const intmax_t value,
7051 const intmax_t values[],
7052 const size_t number_of_values,
7053 const char *const file,
7054 const size_t line);
7055void _assert_uint_in_set(const uintmax_t value,
7056 const uintmax_t values[],
7057 const size_t number_of_values,
7058 const char *const file,
7059 const size_t line);
7060void _assert_uint_not_in_set(const uintmax_t value,
7061 const uintmax_t values[],
7062 const size_t number_of_values,
7063 const char *const file,
7064 const size_t line);
7065void _assert_float_in_set(const double value,
7066 const double values[],
7067 const size_t number_of_values,
7068 const double epsilon,
7069 const char *const file,
7070 const size_t line);
7071void _assert_float_not_in_set(const double value,
7072 const double values[],
7073 const size_t number_of_values,
7074 const double epsilon,
7075 const char *const file,
7076 const size_t line);
7077
7078void* _test_malloc(const size_t size, const char* file, const size_t line);
7079void* _test_realloc(void *ptr, const size_t size, const char* file, const size_t line);
7080void* _test_calloc(const size_t number_of_elements, const size_t size,
7081 const char* file, const size_t line);
7082void _test_free(void* const ptr, const char* file, const size_t line);
7083
7084CMOCKA_NORETURN void _fail(const char * const file, const size_t line);
7085
7086CMOCKA_NORETURN void _skip(const char * const file, const size_t line);
7087
7088CMOCKA_NORETURN void _stop(void);
7089
7090/* Test runner */
7091int _cmocka_run_group_tests(const char *group_name,
7092 const struct CMUnitTest * const tests,
7093 const size_t num_tests,
7094 CMFixtureFunction group_setup,
7095 CMFixtureFunction group_teardown);
7096
7098
7099#ifdef __cplusplus
7100} /* extern "C" */
7101#endif
7102
7103#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:6604
void cmocka_set_skip_filter(const char *pattern)
Set a pattern to skip tests matching the pattern.
Definition cmocka.c:4878
void cmocka_set_test_filter(const char *pattern)
Set a pattern to only run the test matching the pattern.
Definition cmocka.c:4861
@ CM_OUTPUT_TAP
Definition cmocka.h:6612
@ CM_OUTPUT_STDOUT
Definition cmocka.h:6608
@ CM_OUTPUT_SUBUNIT
Definition cmocka.h:6610
@ CM_OUTPUT_STANDARD
Definition cmocka.h:6606
@ CM_OUTPUT_XML
Definition cmocka.h:6614
void(* UnitTestFunction)(void **state)
Definition cmocka.h:6405
int(* CMFixtureFunction)(void **state)
Definition cmocka.h:6487
int cmocka_run_group_tests(const struct CMUnitTest group_tests[], CMFixtureFunction group_setup, CMFixtureFunction group_teardown)
Run tests specified by an array of CMUnitTest structures.
void fail(void)
Forces the test to fail immediately and quit.
void stop(void)
Forces the test to be stopped immediately.
UnitTestFunctionType
Definition cmocka.h:6444
void fail_msg(const char *msg,...)
Forces the test to fail immediately and quit, printing the reason.
int cmocka_run_group_tests_name(const char *group_name, const struct CMUnitTest group_tests[], CMFixtureFunction group_setup, CMFixtureFunction group_teardown)
Run tests specified by an array of CMUnitTest structures and specify a name.
void skip(void)
Forces the test to not be executed, but marked as skipped.
void(* CMUnitTestFunction)(void **state)
Definition cmocka.h:6480
void mock_assert(const int result, const char *const expression, const char *const file, const size_t line)
Function to replace assert(3) in tested code.
Definition cmocka.c:3468
void expect_assert_failure(function fn_call)
Ensure that mock_assert() is called.
void will_return_int(#function, intmax_t value)
Store an integer value to be returned by mock() later.
void will_set_parameter_float_always(#function, #name, float value)
Store a named float value that will always be returned by mock_parameter_float().
uintmax_t mock_parameter(#name)
Retrieve a named value for the current function.
void will_return_float_maybe(#function, float value)
Store a float value that may always be returned by mock_float().
void will_set_parameter_int(#function, #name, intmax_t value)
Store a named integer value to be returned by mock_parameter() later.
intmax_t mock_int()
Retrieve an integer return value of the current function.
void will_return_float_always(#function, float value)
Store a float value that will always be returned by mock_float().
void will_set_parameter_int_count(#function, #name, intmax_t value, int count)
Store a named integer value to be returned a specified number of times by mock_parameter_int() later.
void will_return_double_count(#function, double value, int count)
Store a double precision floating point value to be returned a specified number of times by mock() la...
void will_set_parameter_double_count(#function, #name, double value, int count)
Store a named double value to be returned a specified number of times by mock_parameter_double() late...
void will_set_parameter_uint(#function, #name, uintmax_t value)
Store a named unsigned integer value to be returned by mock_parameter() later.
void will_set_parameter_float_maybe(#function, #name, float value)
Store a named float value that may always be returned by mock_parameter_float().
void * mock_parameter_ptr(#name)
Retrieve a named pointer for the current function.
void will_return_count(#function, uintmax_t value, int count)
void will_set_parameter(#function, #name, uintmax_t value)
Store a named value to be returned by mock_parameter() later.
void will_return_int_maybe(#function, intmax_t value)
Store an integer value that may always be returned by mock_int().
void will_set_parameter_ptr_type(#function, #name, void *value, #type)
Store a named pointer value to be returned by mock_parameter() later.
void will_set_parameter_ptr(#function, #name, void *value)
Store a named pointer value to be returned by mock_parameter() later.
void will_return(#function, uintmax_t value)
Store a value to be returned by mock() later.
void will_return_ptr_type(#function, void *value, type)
Store a pointer value to be returned by mock_ptr_type_checked() later.
void will_return_double_always(#function, double value)
Store a double value that will always be returned by mock_double().
void will_set_errno_always(#function, intmax_t value)
Store an integer value to set errno to by mock_errno() later, for a specified number of times.
type mock_parameter_ptr_type(#name, #type)
Retrieve a named pointer for the current function.
double mock_double(void)
Retrieve a double precision floating point return value of the current function.
void will_return_uint_maybe(#function, uintmax_t value)
Store an unsigned integer value that may always be returned by mock_uint().
void will_return_uint_always(#function, uintmax_t value)
Store an unsigned integer value that will always be returned by mock_uint().
void will_set_parameter_double_maybe(#function, #name, double value)
Store a named double value that may always be returned by mock_parameter_double().
void will_set_parameter_int_maybe(#function, #name, intmax_t value)
Store a named integer value that may always be returned by mock_parameter_int().
void will_set_errno_maybe(#function, intmax_t value)
Store an integer value to set errno to by mock_errno() later, for a specified number of times.
void will_return_uint_count(#function, uintmax_t value, int count)
Store an unsigned integer value to be returned a specified number of times by mock() later.
void will_return_double_maybe(#function, double value)
Store a double value that may always be returned by mock_double().
uintmax_t mock_uint(void)
Retrieve an unsigned integer return value of the current function.
void will_set_parameter_double(#function, #name, double value)
Store a named double precision floating point value to be returned by mock_parameter() later.
void will_set_parameter_ptr_always(#function, #name, void *value)
Store a named pointer value that will be always returned by mock_parameter_ptr().
void will_return_always(#function, uintmax_t value)
void will_return_ptr(#function, void *value)
Store a pointer value to be returned by mock_ptr_type() later.
void will_return_ptr_always(#function, void *value)
Store a value that will be always returned by mock_ptr_type().
void will_return_int_always(#function, intmax_t value)
Store an integer value that will always be returned by mock_int().
type mock_type(#type)
Retrieve a value of the current function and cast it to given type.
void will_set_errno_count(#function, intmax_t value, intmax_t count)
Store an integer value to always set errno to by mock_errno().
void will_set_parameter_float(#function, #name, float value)
Store a named float value to be returned by mock_parameter() later.
void will_set_parameter_double_always(#function, #name, double value)
Store a named double value that will always be returned by mock_parameter_double().
bool has_mock(void)
Check if data is available for the current mock function.
float mock_parameter_float(#name)
Retrieve a named float value for the current function.
void will_set_parameter_uint_maybe(#function, #name, uintmax_t value)
Store a named unsigned integer value that may always be returned by mock_parameter_uint().
void will_set_parameter_int_always(#function, #name, intmax_t value)
Store a named integer value that will always be returned by mock_parameter_int().
void will_return_maybe(#function, uintmax_t value)
void will_set_parameter_always(#function, #name, uintmax_t value)
void will_set_parameter_count(#function, #name, uintmax_t value, int count)
void will_return_int_count(#function, intmax_t value, int count)
Store an integer value to be returned a specified number of times by mock() later.
void will_set_parameter_float_count(#function, #name, float value, int count)
Store a named float value to be returned a specified number of times by mock_parameter_float() later.
void will_return_ptr_count(#function, void *value, int count)
Store a pointer value to be returned by mock_ptr_type() later.
void will_set_parameter_uint_always(#function, #name, uintmax_t value)
Store a named unsigned integer value that will always be returned by mock_parameter_uint().
void will_set_parameter_maybe(#function, #name, uintmax_t value)
uintmax_t mock_parameter_uint(#name)
Retrieve an unsigned integer return value of the current function.
void will_return_uint(#function, uintmax_t value)
Store a unsigned integer value to be returned by mock() later.
void will_return_float(#function, float value)
Store a float value to be returned by mock() later.
void will_set_errno(#function, intmax_t value)
Store an integer value to set errno to by mock_errno() later.
void will_return_float_count(#function, float value, int count)
Store a float value to be returned a specified number of times by mock() later.
type mock_ptr_type(#type)
Retrieve a typed return value of the current function.
void will_set_parameter_ptr_count(#function, #name, void *value, int count)
Store a named pointer value to be returned a specified number of times by mock_parameter_ptr() later.
float mock_float(void)
Retrieve a float return value of the current function.
uintmax_t mock(void)
Retrieve a return value of the current function.
void mock_errno(void)
set errno for the current function.
intmax_t mock_parameter_int(#name)
Retrieve a named value for the current function and cast it to given type.
void will_return_double(#function, double value)
Store a double precision floating point value to be returned by mock() later.
void will_set_parameter_ptr_maybe(#function, #name, void *value)
Store a named pointer value that may be always returned by mock_parameter_ptr().
void will_return_ptr_maybe(#function, void *value)
Store a value that may be always returned by mock_ptr_type().
void will_set_parameter_uint_count(#function, uintmax_t value, int count)
Store a named unsigned integer value to be returned a specified number of times by mock_parameter_uin...
double mock_parameter_double(#name)
Retrieve a named double precision floating point value for the current function.
type mock_ptr_type_checked(#type)
Retrieve a typed return value of the current function with type checking.
void expect_float_not_in_set(#function, #parameter, double value_array[], double epsilon)
Add an event to check if the float parameter value is not part of the provided array.
void expect_uint_in_range_count(#function, uintmax_t minimum, uintmax_t maximum, intmax_t count)
Add an event to repeatedly check an unsigned integer parameter is inside a numerical range....
void expect_uint_value_count(#function, uintmax_t value, intmax_t count)
Add an event to repeatedly check if an unsigned integer parameter is the given value.
void expect_uint_not_in_set_count(#function, uintmax_t value_array[], intmax_t count)
Add an event to check if the unsigned integer parameter value is not part of the provided unsigned in...
void expect_uint_not_in_range(#function, uintmax_t minimum, uintmax_t maximum)
Add an event to check an unsigned integer parameter is outside a numerical range. The check would suc...
void expect_not_double_count(#function, double value, double epsilon, intmax_t count)
Add an event to repeatedly check if a parameter isn't the double precision floating point value.
void expect_int_in_range_count(#function, intmax_t minimum, intmax_t maximum, intmax_t count)
Add an event to repeatedly check an integer parameter is inside a numerical range....
void expect_not_memory_count(#function, #parameter, void *memory, size_t size, intmax_t count)
Add an event to repeatedly check if the parameter doesn't match an area of memory.
void expect_not_string(#function, #parameter, const char *string)
Add an event to check if the parameter value isn't equal to the provided string.
void check_expected_ptr(#parameter)
Determine whether a function parameter is correct.
void expect_float_not_in_range_count(#function, #parameter, double minimum, double maximum, double epsilon, intmax_t count)
Add an event to repeatedly check a parameter is outside a numerical range. The check would succeed if...
void expect_int_not_in_set_count(#function, intmax_t value_array[], intmax_t count)
Add an event to check if the integer parameter value is not part of the provided integer array.
void check_expected(#parameter)
void expect_value_count(#function, #parameter, uintmax_t value, intmax_t count)
void expect_int_not_value_count(#function, intmax_t value, intmax_t count)
Add an event to repeatedly check if a parameter (int) isn't the given value.
void expect_double_count(#function, double value, double epsilon, intmax_t count)
Add an event to repeatedly check if a parameter is the given double precision floating point value.
void expect_not_in_range_count(#function, #parameter, uintmax_t minimum, uintmax_t maximum, intmax_t count)
Add an event to repeatedly check a parameter is outside a numerical range. The check would succeed if...
void expect_check_data(function, parameter, CheckParameterValueData check_function, CMockaValueData check_data)
Add a custom parameter checking function using CMockaValueData (new API).
void expect_uint_in_set_count(#function, #parameter, uintmax_t value_array[], intmax_t count)
Add an event to check if the parameter value is part of the provided unsigned integer array.
void expect_in_range(#function, #parameter, uintmax_t minimum, uintmax_t maximum)
void expect_uint_not_value_count(#function, uintmax_t value, intmax_t count)
Add an event to repeatedly check if a parameter (uint) isn't the given value.
void expect_float(#function, #parameter, double value, double epsilon)
Add an event to check if a parameter is the given floating point value.
void expect_memory_count(#function, #parameter, void *memory, size_t size, intmax_t count)
Add an event to repeatedly check if the parameter does match an area of memory.
void expect_float_in_range_count(#function, #parameter, double minimum, double maximum, double epsilon, intmax_t count)
Add an event to repeatedly check a parameter is inside a numerical range. The check would succeed if ...
void check_expected_float(#parameter)
Determine whether a function parameter is correct.
void expect_float_in_range(#function, #parameter, double minimum, double maximum, double epsilon)
Add an event to check a parameter is inside a numerical range. The check would succeed if minimum <= ...
void expect_double(#function, #parameter, double value, double epsilon)
Add an event to check if a parameter is the given double precision floating point value.
void expect_string(#function, #parameter, const char *string)
Add an event to check if the parameter value is equal to the provided string.
void expect_in_range_count(#function, #parameter, uintmax_t minimum, uintmax_t maximum, intmax_t count)
void expect_not_string_count(#function, #parameter, const char *string, intmax_t count)
Add an event to check if the parameter value isn't equal to the provided string.
void expect_int_value(#function, #parameter, intmax_t value)
Add an event to check if an integer parameter is the given value.
void expect_int_not_in_set(#function, #parameter, intmax_t value_array[])
Add an event to check if the integer parameter value is not part of the provided integer array.
void expect_any_always(#function, #parameter)
Add an event to always check if a parameter (of any value) has been passed.
void expect_uint_in_range(#function, uintmax_t minimum, uintmax_t maximum)
Add an event to check an unsigned integer parameter is inside a numerical range. The check would succ...
void expect_not_memory(#function, #parameter, void *memory, size_t size)
Add an event to check if the parameter doesn't match an area of memory.
void expect_not_in_range(#function, #parameter, uintmax_t minimum, uintmax_t maximum)
Add an event to check a parameter is outside a numerical range. The check would succeed if minimum > ...
void expect_check_count(function, parameter, CheckParameterValue check_function, const void *check_data, intmax_t count)
int(* CheckParameterValue)(const uintmax_t value, const uintmax_t check_value_data)
Definition cmocka.h:6412
void expect_uint_value(#function, #parameter, uintmax_t value)
Add an event to check if an unsigned integer parameter is the given value.
void check_expected_int(#parameter)
Determine whether a function parameter is correct.
void expect_string_count(#function, #parameter, const char *string, intmax_t count)
Add an event to check if the parameter value is equal to the provided string.
void expect_any_count(#function, #parameter, intmax_t count)
Add an event to repeatedly check if a parameter (of any value) has been passed.
void expect_int_in_set_count(#function, #parameter, intmax_t value_array[], intmax_t count)
Add an event to check if the parameter value is part of the provided integer array.
void check_expected_double(#parameter)
Determine whether a function parameter is correct.
int(* CheckIntParameterValue)(const intmax_t value, const intmax_t check_value_data)
Definition cmocka.h:6428
void expect_check_data_count(function, parameter, CheckParameterValueData check_function, CMockaValueData check_data, intmax_t count)
Add a custom parameter checking function using CMockaValueData with count (new API).
int(* CheckParameterValueData)(const CMockaValueData value, const CMockaValueData check_value_data)
Definition cmocka.h:6420
void expect_not_value(#function, #parameter, uintmax_t value)
void expect_memory(#function, #parameter, void *memory, size_t size)
Add an event to check if the parameter does match an area of memory.
void expect_int_in_range(#function, intmax_t minimum, intmax_t maximum)
Add an event to check an integer parameter is inside a numerical range. The check would succeed if mi...
void expect_not_float(#function, #parameter, double value, double epsilon)
Add an event to check if a parameter isn't the given floating point value.
void check_expected_uint(#parameter)
Determine whether a function parameter is correct.
void expect_float_count(#function, #parameter, double value, double epsilon, intmax_t count)
Add an event to repeatedly check if a parameter is the given floating point value.
void expect_not_value_count(#function, #parameter, uintmax_t value, intmax_t count)
void expect_in_set_count(#function, #parameter, uintmax_t value_array[], intmax_t count)
void expect_any(#function, #parameter)
Add an event to check if a parameter (of any value) has been passed.
void expect_float_in_set(#function, #parameter, double value_array[], double epsilon)
Add an event to check if the float parameter value is part of the provided array.
void expect_not_in_set(#function, #parameter, uintmax_t value_array[])
void expect_float_in_set_count(#function, #parameter, double value_array[], double epsilon, intmax_t count)
Add an event to check if the float parameter value is part of the provided integer array.
void expect_float_not_in_range(#function, #parameter, double minimum, double maximum, double epsilon)
Add an event to check a parameter is outside a numerical range. The check would succeed if minimum > ...
void expect_not_in_set_count(#function, #parameter, uintmax_t value_array[], intmax_t count)
int(* CheckUintParameterValue)(const uintmax_t value, const uintmax_t check_value_data)
Definition cmocka.h:6436
void check_expected_any(#parameter)
Check that any parameter value matches the next value in the queue.
void expect_int_not_in_range_count(#function, intmax_t minimum, intmax_t maximum, intmax_t count)
Add an event to repeatedly check an integer parameter is outside a numerical range....
void expect_value(#function, #parameter, uintmax_t value)
void expect_not_float_count(#function, #parameter, double value, double epsilon, intmax_t count)
Add an event to repeatedly check if a parameter isn't the floating point value.
void expect_check(function, parameter, CheckParameterValue check_function, const void *check_data)
void expect_uint_not_in_range_count(#function, uintmax_t minimum, uintmax_t maximum, intmax_t count)
Add an event to repeatedly check an unsigned integer parameter is outside a numerical range....
void expect_not_double(#function, #parameter, double value, double epsilon)
Add an event to check if a parameter isn't the given double precision floating point value.
void expect_uint_not_value(#function, #parameter, uintmax_t value)
Add an event to check if a parameter (uint) isn't the given value.
void expect_int_not_value(#function, #parameter, intmax_t value)
Add an event to check if a parameter (int) isn't the given value.
void expect_in_set(#function, #parameter, uintmax_t value_array[])
void expect_uint_not_in_set(#function, #parameter, uintmax_t value_array[])
Add an event to check if the unsigned integer parameter value is not part of the provided unsigned in...
void expect_float_not_in_set_count(#function, #parameter, double value_array[], double epsilon, intmax_t count)
Add an event to check if the float parameter value is not part of the provided integer array.
void expect_int_value_count(#function, intmax_t value, intmax_t count)
Add an event to repeatedly check if an integer parameter is the given value.
void expect_int_not_in_range(#function, intmax_t minimum, intmax_t maximum)
Add an event to check an integer parameter is outside a numerical range. The check would succeed if m...
Definition cmocka.h:6560
void(* vprint_message)(const char *const format, va_list args)
Definition cmocka.h:6568
void(* vprint_error)(const char *const format, va_list args)
Definition cmocka.h:6577
Definition cmocka.h:6492
Definition cmocka.h:6527
Definition cmocka.h:6515
Definition cmocka.h:6468
Definition cmocka.h:6505
Definition cmocka.h:6459
Definition cmocka.h:6357
double real_val
Definition cmocka.h:6365
float float_val
Definition cmocka.h:6363
const void * const_ptr
Definition cmocka.h:6369
void * ptr
Definition cmocka.h:6367
intmax_t int_val
Definition cmocka.h:6359
uintmax_t uint_val
Definition cmocka.h:6361