cmocka 2.0.2
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_DEPRETATION_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 * See:
251 * https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Common-Function-Attributes.html#Common-Function-Attributes
252 */
253#ifdef __has_attribute
254#if __has_attribute(access)
255#define CMOCKA_NO_ACCESS_ATTRIBUTE \
256 __attribute__((access(none, 1), access(none, 2)))
257#endif
258#endif
259#ifndef CMOCKA_NO_ACCESS_ATTRIBUTE
260#define CMOCKA_NO_ACCESS_ATTRIBUTE
261#endif
263 /* cmocka_util */
265
317
330#define WILL_RETURN_ALWAYS -1
331
343#define WILL_RETURN_ONCE -2
344
354#define EXPECT_ALWAYS -1
355
365#define EXPECT_MAYBE -2
366
367#ifdef DOXYGEN
375uintmax_t mock(void);
376#else
377#define mock() (_mock(__func__, __FILE__, __LINE__, NULL)).uint_val
378#endif
379
380
381#ifdef DOXYGEN
402type mock_type(#type);
403#else
404#define mock_type(type) ((type) mock())
405#endif
406
407#ifdef DOXYGEN
433bool has_mock(void);
434#else
435#define has_mock() _has_mock(__func__)
436#endif
437
438#ifdef DOXYGEN
452intmax_t mock_int();
453#else
454/* TODO: Enable type safety check by passing intmax_t instead of NULL */
455#define mock_int() (_mock(__func__, __FILE__, __LINE__, NULL)).int_val
456#endif
457
458
459#ifdef DOXYGEN
473uintmax_t mock_uint(void);
474#else
475#define mock_uint() (_mock(__func__, __FILE__, __LINE__, "uintmax_t")).uint_val
476#endif
477
478
479#ifdef DOXYGEN
487float mock_float(void);
488#else
489#define mock_float() (_mock(__func__, __FILE__, __LINE__, NULL)).float_val
490#endif
491
492#ifdef DOXYGEN
501double mock_double(void);
502#else
503#define mock_double() (_mock(__func__, __FILE__, __LINE__, NULL)).real_val
504#endif
505
506#ifdef DOXYGEN
527type mock_ptr_type(#type);
528#else
529#define mock_ptr_type(type) \
530 ((type)(_mock(__func__, __FILE__, __LINE__, NULL)).ptr)
531#endif
532
533#ifdef DOXYGEN
556#else
557#define mock_ptr_type_checked(type) \
558 ((type)(_mock(__func__, __FILE__, __LINE__, #type)).ptr)
559#endif
560
561#ifdef DOXYGEN
595uintmax_t mock_parameter(#name);
596#else
597#define mock_parameter(name) \
598 (_mock_parameter(__func__, #name, __FILE__, __LINE__, NULL)).uint_val
599#endif
600
601#ifdef DOXYGEN
624#type mock_parameter_type(#name, #type);
625#else
626#define mock_parameter_type(name, type) ((type) mock_parameter(#name))
627#endif
628
629#ifdef DOXYGEN
647intmax_t mock_parameter_int(#name);
648#else
649#define mock_parameter_int(name) \
650 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "intmax_t")).int_val
651#endif
652
653#ifdef DOXYGEN
671uintmax_t mock_parameter_uint(#name);
672#else
673#define mock_parameter_uint(name) \
674 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "uintmax_t")).uint_val
675#endif
676
677#ifdef DOXYGEN
696#else
697#define mock_parameter_float(name) \
698 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "float")).float_val
699#endif
700
701#ifdef DOXYGEN
720#else
721#define mock_parameter_double(name) \
722 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "double")).real_val
723#endif
724
725#ifdef DOXYGEN
743#else
744#define mock_parameter_ptr(name) \
745 ((_mock_parameter(__func__, #name, __FILE__, __LINE__, NULL)).ptr)
746#endif
747
748#ifdef DOXYGEN
769type mock_parameter_ptr_type(#name, #type);
770#else
771#define mock_parameter_ptr_type(name, type) \
772 ((type)(_mock_parameter(__func__, #name, __FILE__, __LINE__, #type)).ptr)
773#endif
774
775#ifdef DOXYGEN
783void mock_errno(void);
784#else
785#define mock_errno() \
786 do { \
787 intmax_t err = (_mock_parameter( \
788 __func__, \
789 "/errno", \
790 __FILE__, \
791 __LINE__, \
792 "errno")).int_val; \
793 if (err != 0) { \
794 errno = err; \
795 } \
796 } while (0)
797#endif
798
799#ifdef DOXYGEN
833void will_return(#function, uintmax_t value);
834#else
835#define will_return(function, value) \
836 _will_return(cmocka_tostring(function), \
837 __FILE__, \
838 __LINE__, \
839 NULL, \
840 cast_int_to_cmocka_value(value), \
841 1)
842#endif
843
844#ifdef DOXYGEN
868void will_return_int(#function, intmax_t value);
869#else
870#define will_return_int(function, value) \
871 _will_return(#function, \
872 __FILE__, \
873 __LINE__, \
874 "intmax_t", \
875 assign_int_to_cmocka_value(value), \
876 1)
877#endif
878
879#ifdef DOXYGEN
913void will_return_int_count(#function, intmax_t value, int count);
914#else
915#define will_return_int_count(function, value, count) \
916 _will_return(#function, \
917 __FILE__, \
918 __LINE__, \
919 "intmax_t", \
920 assign_int_to_cmocka_value(value), \
921 count)
922#endif
923
924#ifdef DOXYGEN
949void will_return_uint(#function, uintmax_t value);
950#else
951#define will_return_uint(function, value) \
952 _will_return(#function, \
953 __FILE__, \
954 __LINE__, \
955 "uintmax_t", \
956 assign_uint_to_cmocka_value(value), \
957 1)
958#endif
959
960#ifdef DOXYGEN
994void will_return_uint_count(#function, uintmax_t value, int count);
995#else
996#define will_return_uint_count(function, value, count) \
997 _will_return(#function, \
998 __FILE__, \
999 __LINE__, \
1000 "uintmax_t", \
1001 assign_uint_to_cmocka_value(value), \
1002 count)
1003#endif
1004
1005#ifdef DOXYGEN
1030void will_return_float(#function, float value);
1031#else
1032#define will_return_float(function, value) \
1033 _will_return(#function, \
1034 __FILE__, \
1035 __LINE__, \
1036 "float", \
1037 assign_float_to_cmocka_value(value), \
1038 1)
1039#endif
1040
1041#ifdef DOXYGEN
1075void will_return_float_count(#function, float value, int count);
1076#else
1077#define will_return_float_count(function, value, count) \
1078 _will_return(#function, \
1079 __FILE__, \
1080 __LINE__, \
1081 "float", \
1082 assign_float_to_cmocka_value(value), \
1083 count)
1084#endif
1085
1086#ifdef DOXYGEN
1111void will_return_double(#function, double value);
1112#else
1113#define will_return_double(function, value) \
1114 _will_return(#function, \
1115 __FILE__, \
1116 __LINE__, \
1117 "double", \
1118 assign_double_to_cmocka_value(value), \
1119 1)
1120#endif
1121
1122#ifdef DOXYGEN
1156void will_return_double_count(#function, double value, int count);
1157#else
1158#define will_return_double_count(function, value, count) \
1159 _will_return(#function, \
1160 __FILE__, \
1161 __LINE__, \
1162 "double", \
1163 assign_double_to_cmocka_value(value), \
1164 count)
1165#endif
1166
1167#ifdef DOXYGEN
1183void will_return_int_always(#function, intmax_t value);
1184#else
1185#define will_return_int_always(function, value) \
1186 will_return_int_count(function, (value), WILL_RETURN_ALWAYS)
1187#endif
1188
1189#ifdef DOXYGEN
1206void will_return_uint_always(#function, uintmax_t value);
1207#else
1208#define will_return_uint_always(function, value) \
1209 will_return_uint_count(function, (value), WILL_RETURN_ALWAYS)
1210#endif
1211
1212#ifdef DOXYGEN
1228void will_return_float_always(#function, float value);
1229#else
1230#define will_return_float_always(function, value) \
1231 will_return_float_count(function, (value), WILL_RETURN_ALWAYS)
1232#endif
1233
1234#ifdef DOXYGEN
1250void will_return_double_always(#function, double value);
1251#else
1252#define will_return_double_always(function, value) \
1253 will_return_double_count(function, (value), WILL_RETURN_ALWAYS)
1254#endif
1255
1256#ifdef DOXYGEN
1260void will_return_count(#function, uintmax_t value, int count);
1261#else
1262#define will_return_count(function, value, count) \
1263 do { \
1264 CMOCKA_DEPRECATION_WARNING( \
1265 "will_return_count: use will_return_int_count or " \
1266 "will_return_uint_count instead") \
1267 _will_return(cmocka_tostring(function), \
1268 __FILE__, \
1269 __LINE__, \
1270 NULL, \
1271 cast_int_to_cmocka_value(value), \
1272 count); \
1273 } while (0)
1274#endif
1275
1276#ifdef DOXYGEN
1280void will_return_always(#function, uintmax_t value);
1281#else
1282#define will_return_always(function, value) \
1283 do { \
1284 CMOCKA_DEPRECATION_WARNING( \
1285 "will_return_always: use will_return_int_always or " \
1286 "will_return_uint_always instead") \
1287 will_return_count(function, (value), WILL_RETURN_ALWAYS); \
1288 } while (0)
1289#endif
1290
1291#ifdef DOXYGEN
1313void will_return_int_maybe(#function, intmax_t value);
1314#else
1315#define will_return_int_maybe(function, value) \
1316 will_return_int_count(function, (value), WILL_RETURN_ONCE)
1317#endif
1318
1319#ifdef DOXYGEN
1342void will_return_uint_maybe(#function, uintmax_t value);
1343#else
1344#define will_return_uint_maybe(function, value) \
1345 will_return_uint_count(function, (value), WILL_RETURN_ONCE)
1346#endif
1347
1348#ifdef DOXYGEN
1370void will_return_float_maybe(#function, float value);
1371#else
1372#define will_return_float_maybe(function, value) \
1373 will_return_float_count(function, (value), WILL_RETURN_ONCE)
1374#endif
1375
1376#ifdef DOXYGEN
1398void will_return_double_maybe(#function, double value);
1399#else
1400#define will_return_double_maybe(function, value) \
1401 will_return_double_count(function, (value), WILL_RETURN_ONCE)
1402#endif
1403
1404#ifdef DOXYGEN
1408void will_return_maybe(#function, uintmax_t value);
1409#else
1410#define will_return_maybe(function, value) \
1411 do { \
1412 CMOCKA_DEPRECATION_WARNING( \
1413 "will_return_maybe: use will_return_int_maybe or " \
1414 "will_return_uint_maybe instead") \
1415 will_return_count(function, (value), WILL_RETURN_ONCE); \
1416 } while (0)
1417#endif
1418
1419#ifdef DOXYGEN
1444void will_return_ptr(#function, void *value);
1445#else
1446#define will_return_ptr(function, value) \
1447 _will_return(#function, \
1448 __FILE__, \
1449 __LINE__, \
1450 NULL, \
1451 cast_ptr_to_cmocka_value(value), \
1452 1)
1453#endif
1454
1455#ifdef DOXYGEN
1484void will_return_ptr_type(#function, void *value, type);
1485#else
1486#define will_return_ptr_type(function, value, type) \
1487 _will_return(#function, \
1488 __FILE__, \
1489 __LINE__, \
1490 #type, \
1491 cast_ptr_to_cmocka_value(value), \
1492 1)
1493#endif
1494
1495#ifdef DOXYGEN
1511void will_return_ptr_count(#function, void *value, int count);
1512#else
1513#define will_return_ptr_count(function, value, count) \
1514 _will_return(#function, \
1515 __FILE__, \
1516 __LINE__, \
1517 NULL, \
1518 cast_ptr_to_cmocka_value(value), \
1519 count)
1520#endif
1521
1522#ifdef DOXYGEN
1538void will_return_ptr_always(#function, void *value);
1539#else
1540#define will_return_ptr_always(function, value) \
1541 will_return_ptr_count(function, (value), WILL_RETURN_ALWAYS)
1542#endif
1543
1544#ifdef DOXYGEN
1566void will_return_ptr_maybe(#function, void *value);
1567#else
1568#define will_return_ptr_maybe(function, value) \
1569 will_return_ptr_count(function, (value), WILL_RETURN_ONCE)
1570#endif
1571
1572#ifdef DOXYGEN
1617void will_set_parameter(#function, #name, uintmax_t value);
1618#else
1619#define will_set_parameter(function, name, value) \
1620 _will_set_parameter(cmocka_tostring(function), \
1621 #name, \
1622 __FILE__, \
1623 __LINE__, \
1624 NULL, \
1625 cast_int_to_cmocka_value(value), \
1626 1)
1627#endif
1628
1629#ifdef DOXYGEN
1661void will_set_parameter_int(#function, #name, intmax_t value);
1662#else
1663#define will_set_parameter_int(function, name, value) \
1664 _will_set_parameter(#function, \
1665 #name, \
1666 __FILE__, \
1667 __LINE__, \
1668 "intmax_t", \
1669 assign_int_to_cmocka_value(value), \
1670 1)
1671#endif
1672
1673#ifdef DOXYGEN
1707void will_set_parameter_uint(#function, #name, uintmax_t value);
1708#else
1709#define will_set_parameter_uint(function, name, value) \
1710 _will_set_parameter(#function, \
1711 #name, \
1712 __FILE__, \
1713 __LINE__, \
1714 "uintmax_t", \
1715 assign_uint_to_cmocka_value(value), \
1716 1)
1717#endif
1718
1719#ifdef DOXYGEN
1752void will_set_parameter_float(#function, #name, float value);
1753#else
1754#define will_set_parameter_float(function, name, value) \
1755 _will_set_parameter(#function, \
1756 #name, \
1757 __FILE__, \
1758 __LINE__, \
1759 "float", \
1760 assign_float_to_cmocka_value(value), \
1761 1)
1762#endif
1763
1764#ifdef DOXYGEN
1798void will_set_parameter_double(#function, #name, double value);
1799#else
1800#define will_set_parameter_double(function, name, value) \
1801 _will_set_parameter(#function, \
1802 #name, \
1803 __FILE__, \
1804 __LINE__, \
1805 "double", \
1806 assign_double_to_cmocka_value(value), \
1807 1)
1808#endif
1809
1810#ifdef DOXYGEN
1830void will_set_parameter_int_count(#function, #name, intmax_t value, int count);
1831#else
1832#define will_set_parameter_int_count(function, name, value, count) \
1833 _will_set_parameter(#function, \
1834 #name, \
1835 __FILE__, \
1836 __LINE__, \
1837 "intmax_t", \
1838 assign_int_to_cmocka_value(value), \
1839 count)
1840#endif
1841
1842#ifdef DOXYGEN
1863 #name,
1864 uintmax_t value,
1865 int count);
1866#else
1867#define will_set_parameter_uint_count(function, name, value, count) \
1868 _will_set_parameter(#function, \
1869 #name, \
1870 __FILE__, \
1871 __LINE__, \
1872 "uintmax_t", \
1873 assign_uint_to_cmocka_value(value), \
1874 count)
1875#endif
1876
1877#ifdef DOXYGEN
1897void will_set_parameter_float_count(#function, #name, float value, int count);
1898#else
1899#define will_set_parameter_float_count(function, name, value, count) \
1900 _will_set_parameter(#function, \
1901 #name, \
1902 __FILE__, \
1903 __LINE__, \
1904 "float", \
1905 assign_float_to_cmocka_value(value), \
1906 count)
1907#endif
1908
1909#ifdef DOXYGEN
1929void will_set_parameter_double_count(#function, #name, double value, int count);
1930#else
1931#define will_set_parameter_double_count(function, name, value, count) \
1932 _will_set_parameter(#function, \
1933 #name, \
1934 __FILE__, \
1935 __LINE__, \
1936 "double", \
1937 assign_double_to_cmocka_value(value), \
1938 count)
1939#endif
1940
1941#ifdef DOXYGEN
1946void will_set_parameter_count(#function, #name, uintmax_t value, int count);
1947#else
1948#define will_set_parameter_count(function, name, value, count) \
1949 do { \
1950 CMOCKA_DEPRECATION_WARNING( \
1951 "will_set_parameter_count: use will_set_parameter_int_count or " \
1952 "will_set_parameter_uint_count instead") \
1953 _will_set_parameter(cmocka_tostring(function), \
1954 #name, \
1955 __FILE__, \
1956 __LINE__, \
1957 NULL, \
1958 cast_int_to_cmocka_value(value), \
1959 count); \
1960 } while (0)
1961#endif
1962
1963#ifdef DOXYGEN
1983void will_set_parameter_int_always(#function, #name, intmax_t value);
1984#else
1985#define will_set_parameter_int_always(function, name, value) \
1986 will_set_parameter_int_count(function, name, (value), WILL_RETURN_ALWAYS)
1987#endif
1988
1989#ifdef DOXYGEN
2009void will_set_parameter_uint_always(#function, #name, uintmax_t value);
2010#else
2011#define will_set_parameter_uint_always(function, name, value) \
2012 will_set_parameter_uint_count(function, name, (value), WILL_RETURN_ALWAYS)
2013#endif
2014
2015#ifdef DOXYGEN
2035void will_set_parameter_float_always(#function, #name, float value);
2036#else
2037#define will_set_parameter_float_always(function, name, value) \
2038 will_set_parameter_float_count(function, name, (value), WILL_RETURN_ALWAYS)
2039#endif
2040
2041#ifdef DOXYGEN
2061void will_set_parameter_double_always(#function, #name, double value);
2062#else
2063#define will_set_parameter_double_always(function, name, value) \
2064 will_set_parameter_double_count(function, name, (value), WILL_RETURN_ALWAYS)
2065#endif
2066
2067#ifdef DOXYGEN
2072void will_set_parameter_always(#function, #name, uintmax_t value);
2073#else
2074#define will_set_parameter_always(function, name, value) \
2075 do { \
2076 CMOCKA_DEPRECATION_WARNING( \
2077 "will_set_parameter_always: use will_set_parameter_int_always or " \
2078 "will_set_parameter_uint_always instead") \
2079 will_set_parameter_count(function, name, (value), WILL_RETURN_ALWAYS); \
2080 } while (0)
2081#endif
2082
2083#ifdef DOXYGEN
2104void will_set_parameter_int_maybe(#function, #name, intmax_t value);
2105#else
2106#define will_set_parameter_int_maybe(function, name, value) \
2107 will_set_parameter_int_count(function, name, (value), WILL_RETURN_ONCE)
2108#endif
2109
2110#ifdef DOXYGEN
2131void will_set_parameter_uint_maybe(#function, #name, uintmax_t value);
2132#else
2133#define will_set_parameter_uint_maybe(function, name, value) \
2134 will_set_parameter_uint_count(function, name, (value), WILL_RETURN_ONCE)
2135#endif
2136
2137#ifdef DOXYGEN
2158void will_set_parameter_float_maybe(#function, #name, float value);
2159#else
2160#define will_set_parameter_float_maybe(function, name, value) \
2161 will_set_parameter_float_count(function, name, (value), WILL_RETURN_ONCE)
2162#endif
2163
2164#ifdef DOXYGEN
2185void will_set_parameter_double_maybe(#function, #name, double value);
2186#else
2187#define will_set_parameter_double_maybe(function, name, value) \
2188 will_set_parameter_double_count(function, name, (value), WILL_RETURN_ONCE)
2189#endif
2190
2191#ifdef DOXYGEN
2196void will_set_parameter_maybe(#function, #name, uintmax_t value);
2197#else
2198#define will_set_parameter_maybe(function, name, value) \
2199 do { \
2200 CMOCKA_DEPRECATION_WARNING( \
2201 "will_set_parameter_maybe: use will_set_parameter_int_maybe or " \
2202 "will_set_parameter_uint_maybe instead") \
2203 will_set_parameter_count(function, name, (value), WILL_RETURN_ONCE); \
2204 } while (0)
2205#endif
2206
2207#ifdef DOXYGEN
2236void will_set_parameter_ptr(#function, #name, void *value);
2237#else
2238#define will_set_parameter_ptr(function, name, value) \
2239 _will_set_parameter(#function, \
2240 #name, \
2241 __FILE__, \
2242 __LINE__, \
2243 NULL, \
2244 cast_ptr_to_cmocka_value(value), \
2245 1)
2246#endif
2247
2248#ifdef DOXYGEN
2282void will_set_parameter_ptr_type(#function, #name, void *value, #type);
2283#else
2284#define will_set_parameter_ptr_type(function, name, value, type) \
2285 _will_set_parameter(#function, \
2286 #name, \
2287 __FILE__, \
2288 __LINE__, \
2289 #type, \
2290 cast_ptr_to_cmocka_value(value), \
2291 1)
2292#endif
2293
2294#ifdef DOXYGEN
2333void will_set_parameter_ptr_count(#function, #name, void *value, int count);
2334#else
2335#define will_set_parameter_ptr_count(function, name, value, count) \
2336 _will_set_parameter(#function, \
2337 #name, \
2338 __FILE__, \
2339 __LINE__, \
2340 NULL, \
2341 cast_ptr_to_cmocka_value(value), \
2342 count)
2343#endif
2344
2345#ifdef DOXYGEN
2372void will_set_parameter_ptr_always(#function, #name, void *value);
2373#else
2374#define will_set_parameter_ptr_always(function, name, value) \
2375 will_set_parameter_ptr_count(function, name, (value), WILL_RETURN_ALWAYS)
2376#endif
2377
2378#ifdef DOXYGEN
2407void will_set_parameter_ptr_maybe(#function, #name, void *value);
2408#else
2409#define will_set_parameter_ptr_maybe(function, name, value) \
2410 will_set_parameter_ptr_count(function, name, (value), WILL_RETURN_ONCE)
2411#endif
2412
2413#ifdef DOXYGEN
2438void will_set_errno(#function, intmax_t value);
2439#else
2440#define will_set_errno(function, value) \
2441 _will_set_parameter(#function, \
2442 "/errno", \
2443 __FILE__, \
2444 __LINE__, \
2445 "errno", \
2446 assign_int_to_cmocka_value(value), \
2447 1)
2448#endif
2449
2450#ifdef DOXYGEN
2489void will_set_errno_count(#function, intmax_t value, size_t count);
2490#else
2491#define will_set_errno_count(function, value, count) \
2492 _will_set_parameter(#function, \
2493 "/errno", \
2494 __FILE__, \
2495 __LINE__, \
2496 "errno", \
2497 assign_int_to_cmocka_value(value), \
2498 (count))
2499#endif
2500
2501#ifdef DOXYGEN
2524void will_set_errno_always(#function, intmax_t value);
2525#else
2526#define will_set_errno_always(function, value) \
2527 will_set_errno_count(function, (value), WILL_RETURN_ALWAYS);
2528#endif
2529
2530#ifdef DOXYGEN
2553void will_set_errno_maybe(#function, intmax_t value);
2554#else
2555#define will_set_errno_maybe(function, value) \
2556 will_set_errno_count(function, (value), WILL_RETURN_ONCE);
2557#endif
2558 /* cmocka_mock */
2560
2605
2606
2607#ifdef DOXYGEN
2611void expect_check(function,
2612 parameter,
2613 CheckParameterValue check_function,
2614 const void *check_data);
2615#else
2616#define expect_check(function, parameter, check_function, check_data) \
2617 do { \
2618 CMOCKA_DEPRECATION_WARNING( \
2619 "expect_check: use expect_check_data instead") \
2620 _expect_check(cmocka_tostring(function), \
2621 cmocka_tostring(parameter), \
2622 __FILE__, \
2623 __LINE__, \
2624 check_function, \
2625 cast_to_uintmax_type(check_data), \
2626 NULL, \
2627 1); \
2628 } while (0)
2629#endif
2630
2631
2632#ifdef DOXYGEN
2637 parameter,
2638 CheckParameterValue check_function,
2639 const void *check_data,
2640 size_t count);
2641#else
2642#define expect_check_count( \
2643 function, parameter, check_function, check_data, count) \
2644 do { \
2645 CMOCKA_DEPRECATION_WARNING( \
2646 "expect_check_count: use expect_check_data_count instead") \
2647 _expect_check(cmocka_tostring(function), \
2648 cmocka_tostring(parameter), \
2649 __FILE__, \
2650 __LINE__, \
2651 check_function, \
2652 cast_to_uintmax_type(check_data), \
2653 NULL, \
2654 count); \
2655 } while (0)
2656#endif
2657
2658#ifdef DOXYGEN
2814void expect_check_data(function,
2815 parameter,
2816 CheckParameterValueData check_function,
2817 CMockaValueData check_data);
2818#else
2819#define expect_check_data(function, parameter, check_function, check_data) \
2820 _expect_check_data(cmocka_tostring(function), \
2821 cmocka_tostring(parameter), \
2822 __FILE__, \
2823 __LINE__, \
2824 check_function, \
2825 check_data, \
2826 NULL, \
2827 1)
2828#endif
2829
2830#ifdef DOXYGEN
2896 parameter,
2897 CheckParameterValueData check_function,
2898 CMockaValueData check_data,
2899 size_t count);
2900#else
2901#define expect_check_data_count(function, \
2902 parameter, \
2903 check_function, \
2904 check_data, \
2905 count) \
2906 _expect_check_data(cmocka_tostring(function), \
2907 cmocka_tostring(parameter), \
2908 __FILE__, \
2909 __LINE__, \
2910 check_function, \
2911 check_data, \
2912 NULL, \
2913 count)
2914#endif
2915
2916#ifdef DOXYGEN
2920void expect_in_set(#function, #parameter, uintmax_t value_array[]);
2921#else
2922#define expect_in_set(function, parameter, value_array) \
2923 do { \
2924 CMOCKA_DEPRECATION_WARNING("expect_in_set: use expect_int_in_set or " \
2925 "expect_uint_in_set instead") \
2926 expect_in_set_count(function, parameter, value_array, 1); \
2927 } while (0)
2928#endif
2929
2930#ifdef DOXYGEN
2945void expect_in_set(#function, #parameter, intmax_t value_array[]);
2946#else
2947#define expect_int_in_set(function, parameter, value_array) \
2948 expect_int_in_set_count(function, parameter, value_array, 1)
2949#endif
2950
2951#ifdef DOXYGEN
2966void expect_in_set(#function, #parameter, intmax_t value_array[]);
2967#else
2968#define expect_uint_in_set(function, parameter, value_array) \
2969 expect_uint_in_set_count(function, parameter, value_array, 1)
2970#endif
2971
2972#ifdef DOXYGEN
2976void expect_in_set_count(#function, #parameter, uintmax_t value_array[], size_t count);
2977#else
2978#define expect_in_set_count(function, parameter, value_array, count) \
2979 do { \
2980 CMOCKA_DEPRECATION_WARNING( \
2981 "expect_in_set_count: use expect_int_in_set_count or " \
2982 "expect_uint_in_set_count instead") \
2983 _expect_uint_in_set(cmocka_tostring(function), \
2984 cmocka_tostring(parameter), \
2985 __FILE__, \
2986 __LINE__, \
2987 value_array, \
2988 sizeof(value_array) / sizeof((value_array)[0]), \
2989 count); \
2990 } while (0)
2991#endif
2992
2993#ifdef DOXYGEN
3012void expect_int_in_set_count(#function, #parameter, intmax_t value_array[], size_t count);
3013#else
3014#define expect_int_in_set_count(function, parameter, value_array, count) \
3015 _expect_int_in_set(cmocka_tostring(function), \
3016 cmocka_tostring(parameter), \
3017 __FILE__, \
3018 __LINE__, \
3019 value_array, \
3020 sizeof(value_array) / sizeof((value_array)[0]), \
3021 count)
3022#endif
3023
3024#ifdef DOXYGEN
3043void expect_uint_in_set_count(#function, #parameter, uintmax_t value_array[], size_t count);
3044#else
3045#define expect_uint_in_set_count(function, parameter, value_array, count) \
3046 _expect_uint_in_set(cmocka_tostring(function), \
3047 cmocka_tostring(parameter), \
3048 __FILE__, \
3049 __LINE__, \
3050 value_array, \
3051 sizeof(value_array) / sizeof((value_array)[0]), \
3052 count)
3053#endif
3054
3055#ifdef DOXYGEN
3059void expect_not_in_set(#function, #parameter, uintmax_t value_array[]);
3060#else
3061#define expect_not_in_set(function, parameter, value_array) \
3062 do { \
3063 CMOCKA_DEPRECATION_WARNING( \
3064 "expect_not_in_set: use expect_int_not_in_set or " \
3065 "expect_uint_not_in_set instead") \
3066 expect_not_in_set_count(function, parameter, value_array, 1); \
3067 } while (0)
3068#endif
3069
3070#ifdef DOXYGEN
3074void expect_not_in_set_count(#function, #parameter, uintmax_t value_array[], size_t count);
3075#else
3076#define expect_not_in_set_count(function, parameter, value_array, count) \
3077 do { \
3078 CMOCKA_DEPRECATION_WARNING( \
3079 "expect_not_in_set_count: use expect_int_not_in_set_count or " \
3080 "expect_uint_not_in_set_count instead") \
3081 _expect_not_in_set(cmocka_tostring(function), \
3082 cmocka_tostring(parameter), \
3083 __FILE__, \
3084 __LINE__, \
3085 value_array, \
3086 sizeof(value_array) / sizeof((value_array)[0]), \
3087 count); \
3088 } while (0)
3089#endif
3090
3091#ifdef DOXYGEN
3106void expect_int_not_in_set(#function, #parameter, intmax_t value_array[]);
3107#else
3108#define expect_int_not_in_set(function, parameter, value_array) \
3109 expect_int_not_in_set_count(function, parameter, value_array, 1)
3110#endif
3111
3112#ifdef DOXYGEN
3132 #parameter,
3133 intmax_t value_array[],
3134 size_t count);
3135#else
3136#define expect_int_not_in_set_count(function, parameter, value_array, count) \
3137 _expect_int_not_in_set(cmocka_tostring(function), \
3138 cmocka_tostring(parameter), \
3139 __FILE__, \
3140 __LINE__, \
3141 value_array, \
3142 sizeof(value_array) / sizeof((value_array)[0]), \
3143 count)
3144#endif
3145
3146#ifdef DOXYGEN
3161void expect_uint_not_in_set(#function, #parameter, uintmax_t value_array[]);
3162#else
3163#define expect_uint_not_in_set(function, parameter, value_array) \
3164 expect_uint_not_in_set_count(function, parameter, value_array, 1)
3165#endif
3166
3167#ifdef DOXYGEN
3187 #parameter,
3188 uintmax_t value_array[],
3189 size_t count);
3190#else
3191#define expect_uint_not_in_set_count(function, parameter, value_array, count) \
3192 _expect_uint_not_in_set(cmocka_tostring(function), \
3193 cmocka_tostring(parameter), \
3194 __FILE__, \
3195 __LINE__, \
3196 value_array, \
3197 sizeof(value_array) / sizeof((value_array)[0]), \
3198 count)
3199#endif
3200
3201#ifdef DOXYGEN
3218void expect_float_in_set(#function, #parameter, double value_array[], double epsilon);
3219#else
3220#define expect_float_in_set(function, parameter, value_array, epsilon) \
3221 expect_float_in_set_count(function, parameter, value_array, epsilon, 1)
3222#endif
3223
3224#ifdef DOXYGEN
3245void expect_float_in_set_count(#function, #parameter, double value_array[], double epsilon, size_t count);
3246#else
3247#define expect_float_in_set_count(function, parameter, value_array, epsilon, count) \
3248 _expect_float_in_set(cmocka_tostring(function), \
3249 cmocka_tostring(parameter), \
3250 __FILE__, \
3251 __LINE__, \
3252 value_array, \
3253 sizeof(value_array) / sizeof((value_array)[0]), \
3254 epsilon, \
3255 count)
3256#endif
3257
3258#ifdef DOXYGEN
3275void expect_float_not_in_set(#function, #parameter, double value_array[], double epsilon);
3276#else
3277#define expect_float_not_in_set(function, parameter, value_array, epsilon) \
3278 expect_float_not_in_set_count(function, parameter, value_array, epsilon, 1)
3279#endif
3280
3281#ifdef DOXYGEN
3302void expect_float_not_in_set_count(#function, #parameter, double value_array[], double epsilon, size_t count);
3303#else
3304#define expect_float_not_in_set_count(function, parameter, value_array, epsilon, count) \
3305 _expect_float_not_in_set(cmocka_tostring(function), \
3306 cmocka_tostring(parameter), \
3307 __FILE__, \
3308 __LINE__, \
3309 value_array, \
3310 sizeof(value_array) / sizeof((value_array)[0]), \
3311 epsilon, \
3312 count)
3313#endif
3314
3315
3316#ifdef DOXYGEN
3320void expect_in_range(#function, #parameter, uintmax_t minimum, uintmax_t maximum);
3321#else
3322#define expect_in_range(function, parameter, minimum, maximum) \
3323 do { \
3324 CMOCKA_DEPRECATION_WARNING( \
3325 "expect_in_range: use expect_int_in_range or " \
3326 "expect_uint_in_range instead") \
3327 expect_in_range_count(function, parameter, minimum, maximum, 1); \
3328 } while (0)
3329#endif
3330
3331#ifdef DOXYGEN
3335void expect_in_range_count(#function, #parameter, uintmax_t minimum, uintmax_t maximum, size_t count);
3336#else
3337#define expect_in_range_count(function, parameter, minimum, maximum, count) \
3338 do { \
3339 CMOCKA_DEPRECATION_WARNING( \
3340 "expect_in_range_count: use expect_int_in_range_count or " \
3341 "expect_uint_in_range_count instead") \
3342 _expect_in_range(cmocka_tostring(function), \
3343 cmocka_tostring(parameter), \
3344 __FILE__, \
3345 __LINE__, \
3346 minimum, \
3347 maximum, \
3348 count); \
3349 } while (0)
3350#endif
3351
3352#ifdef DOXYGEN
3369void expect_int_in_range(#function,
3370#parameter,
3371 intmax_t minimum,
3372 intmax_t maximum);
3373#else
3374#define expect_int_in_range(function, parameter, minimum, maximum) \
3375 expect_int_in_range_count(function, parameter, minimum, maximum, 1)
3376#endif
3377
3378#ifdef DOXYGEN
3400#parameter,
3401 intmax_t minimum,
3402 intmax_t maximum,
3403 size_t count);
3404#else
3405#define expect_int_in_range_count( \
3406 function, parameter, minimum, maximum, count) \
3407 _expect_int_in_range(cmocka_tostring(function), \
3408 cmocka_tostring(parameter), \
3409 __FILE__, \
3410 __LINE__, \
3411 minimum, \
3412 maximum, \
3413 count)
3414#endif
3415
3416#ifdef DOXYGEN
3434#parameter,
3435 uintmax_t minimum,
3436 uintmax_t maximum);
3437#else
3438#define expect_uint_in_range(function, parameter, minimum, maximum) \
3439 expect_uint_in_range_count(function, parameter, minimum, maximum, 1)
3440#endif
3441
3442#ifdef DOXYGEN
3465#parameter,
3466 uintmax_t minimum,
3467 uintmax_t maximum,
3468 size_t count);
3469#else
3470#define expect_uint_in_range_count( \
3471 function, parameter, minimum, maximum, count) \
3472 _expect_uint_in_range(cmocka_tostring(function), \
3473 cmocka_tostring(parameter), \
3474 __FILE__, \
3475 __LINE__, \
3476 minimum, \
3477 maximum, \
3478 count)
3479#endif
3480
3481#ifdef DOXYGEN
3498void expect_not_in_range(#function, #parameter, uintmax_t minimum, uintmax_t maximum);
3499#else
3500#define expect_not_in_range(function, parameter, minimum, maximum) \
3501 expect_not_in_range_count(function, parameter, minimum, maximum, 1)
3502#endif
3503
3504#ifdef DOXYGEN
3525void expect_not_in_range_count(#function, #parameter, uintmax_t minimum, uintmax_t maximum, size_t count);
3526#else
3527#define expect_not_in_range_count(function, parameter, minimum, maximum, \
3528 count) \
3529 _expect_not_in_range(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
3530 minimum, maximum, count)
3531#endif
3532
3533#ifdef DOXYGEN
3551 #parameter,
3552 intmax_t minimum,
3553 intmax_t maximum);
3554#else
3555#define expect_int_not_in_range(function, parameter, minimum, maximum) \
3556 expect_int_not_in_range_count(function, parameter, minimum, maximum, 1)
3557#endif
3558
3559#ifdef DOXYGEN
3581 #parameter,
3582 intmax_t minimum,
3583 intmax_t maximum,
3584 size_t count);
3585#else
3586#define expect_int_not_in_range_count( \
3587 function, parameter, minimum, maximum, count) \
3588 _expect_int_not_in_range(cmocka_tostring(function), \
3589 cmocka_tostring(parameter), \
3590 __FILE__, \
3591 __LINE__, \
3592 minimum, \
3593 maximum, \
3594 count)
3595#endif
3596
3597#ifdef DOXYGEN
3615 #parameter,
3616 uintmax_t minimum,
3617 uintmax_t maximum);
3618#else
3619#define expect_uint_not_in_range(function, parameter, minimum, maximum) \
3620 expect_uint_not_in_range_count(function, parameter, minimum, maximum, 1)
3621#endif
3622
3623#ifdef DOXYGEN
3646 #parameter,
3647 uintmax_t minimum,
3648 uintmax_t maximum,
3649 size_t count);
3650#else
3651#define expect_uint_not_in_range_count( \
3652 function, parameter, minimum, maximum, count) \
3653 _expect_uint_not_in_range(cmocka_tostring(function), \
3654 cmocka_tostring(parameter), \
3655 __FILE__, \
3656 __LINE__, \
3657 minimum, \
3658 maximum, \
3659 count)
3660#endif
3661
3662#ifdef DOXYGEN
3681void expect_float_in_range(#function, #parameter, double minimum, double maximum, double epsilon);
3682#else
3683#define expect_float_in_range(function, parameter, minimum, maximum, epsilon) \
3684 expect_float_in_range_count(function, parameter, minimum, maximum, epsilon, 1)
3685#endif
3686
3687#ifdef DOXYGEN
3710void expect_float_in_range_count(#function, #parameter, double minimum, double maximum, double epsilon, size_t count);
3711#else
3712#define expect_float_in_range_count(function, parameter, minimum, maximum, epsilon, count) \
3713 _expect_float_in_range(cmocka_tostring(function), \
3714 cmocka_tostring(parameter), \
3715 __FILE__, \
3716 __LINE__, \
3717 cast_to_double_type(minimum), \
3718 cast_to_double_type(maximum), \
3719 cast_to_double_type(epsilon), \
3720 count)
3721#endif
3722
3723#ifdef DOXYGEN
3742void expect_float_not_in_range(#function, #parameter, double minimum, double maximum, double epsilon);
3743#else
3744#define expect_float_not_in_range(function, parameter, minimum, maximum, epsilon) \
3745 expect_float_not_in_range_count(function, parameter, minimum, maximum, epsilon, 1)
3746#endif
3747
3748#ifdef DOXYGEN
3771void expect_float_not_in_range_count(#function, #parameter, double minimum, double maximum, double epsilon, size_t count);
3772#else
3773#define expect_float_not_in_range_count(function, parameter, minimum, maximum, \
3774 epsilon, count) \
3775 _expect_float_not_in_range(cmocka_tostring(function), \
3776 cmocka_tostring(parameter), \
3777 __FILE__, \
3778 __LINE__, \
3779 cast_to_double_type(minimum), \
3780 cast_to_double_type(maximum), \
3781 cast_to_double_type(epsilon), \
3782 count)
3783#endif
3784
3785#ifdef DOXYGEN
3789void expect_value(#function, #parameter, uintmax_t value);
3790#else
3791#define expect_value(function, parameter, value) \
3792 do { \
3793 CMOCKA_DEPRECATION_WARNING("expect_value: use expect_int_value or " \
3794 "expect_uint_value instead") \
3795 expect_value_count(function, parameter, value, 1); \
3796 } while (0)
3797#endif
3798
3799#ifdef DOXYGEN
3803void expect_value_count(#function, #parameter, uintmax_t value, size_t count);
3804#else
3805#define expect_value_count(function, parameter, value, count) \
3806 do { \
3807 CMOCKA_DEPRECATION_WARNING( \
3808 "expect_value_count: use expect_int_value_count or " \
3809 "expect_uint_value_count instead") \
3810 _expect_value(cmocka_tostring(function), \
3811 cmocka_tostring(parameter), \
3812 __FILE__, \
3813 __LINE__, \
3814 cast_to_uintmax_type(value), \
3815 count); \
3816 } while (0)
3817#endif
3818
3819#ifdef DOXYGEN
3833void expect_int_value(#function, #parameter, intmax_t value);
3834#else
3835#define expect_int_value(function, parameter, value) \
3836 expect_int_value_count(function, parameter, value, 1)
3837#endif
3838
3839#ifdef DOXYGEN
3859#parameter,
3860 intmax_t value,
3861 size_t count);
3862#else
3863#define expect_int_value_count(function, parameter, value, count) \
3864 _expect_int_value(cmocka_tostring(function), \
3865 cmocka_tostring(parameter), \
3866 __FILE__, \
3867 __LINE__, \
3868 value, \
3869 count)
3870#endif
3871
3872#ifdef DOXYGEN
3887void expect_uint_value(#function, #parameter, uintmax_t value);
3888#else
3889#define expect_uint_value(function, parameter, value) \
3890 expect_uint_value_count(function, parameter, value, 1)
3891#endif
3892
3893#ifdef DOXYGEN
3913#parameter,
3914 uintmax_t value,
3915 size_t count);
3916#else
3917#define expect_uint_value_count(function, parameter, value, count) \
3918 _expect_uint_value(cmocka_tostring(function), \
3919 cmocka_tostring(parameter), \
3920 __FILE__, \
3921 __LINE__, \
3922 value, \
3923 count)
3924#endif
3925
3926#ifdef DOXYGEN
3940void expect_int_not_value(#function, #parameter, intmax_t value);
3941#else
3942#define expect_int_not_value(function, parameter, value) \
3943 expect_int_not_value_count(function, parameter, value, 1)
3944#endif
3945
3946#ifdef DOXYGEN
3966 #parameter,
3967 intmax_t value,
3968 size_t count);
3969#else
3970#define expect_int_not_value_count(function, parameter, value, count) \
3971 _expect_int_not_value(cmocka_tostring(function), \
3972 cmocka_tostring(parameter), \
3973 __FILE__, \
3974 __LINE__, \
3975 value, \
3976 count)
3977#endif
3978
3979#ifdef DOXYGEN
3993void expect_uint_not_value(#function, #parameter, uintmax_t value);
3994#else
3995#define expect_uint_not_value(function, parameter, value) \
3996 expect_uint_not_value_count(function, parameter, value, 1)
3997#endif
3998
3999#ifdef DOXYGEN
4019 #parameter,
4020 uintmax_t value,
4021 size_t count);
4022#else
4023#define expect_uint_not_value_count(function, parameter, value, count) \
4024 _expect_uint_not_value(cmocka_tostring(function), \
4025 cmocka_tostring(parameter), \
4026 __FILE__, \
4027 __LINE__, \
4028 value, \
4029 count)
4030#endif
4031
4032#ifdef DOXYGEN
4036void expect_not_value(#function, #parameter, uintmax_t value);
4037#else
4038#define expect_not_value(function, parameter, value) \
4039 do { \
4040 CMOCKA_DEPRECATION_WARNING( \
4041 "expect_not_value: use expect_int_not_value or " \
4042 "expect_uint_not_value instead") \
4043 expect_not_value_count(function, parameter, value, 1); \
4044 } while (0)
4045#endif
4046
4047#ifdef DOXYGEN
4051void expect_not_value_count(#function, #parameter, uintmax_t value, size_t count);
4052#else
4053#define expect_not_value_count(function, parameter, value, count) \
4054 do { \
4055 CMOCKA_DEPRECATION_WARNING( \
4056 "expect_not_value_count: use expect_int_not_value_count or " \
4057 "expect_uint_not_value_count instead") \
4058 _expect_not_value(cmocka_tostring(function), \
4059 cmocka_tostring(parameter), \
4060 __FILE__, \
4061 __LINE__, \
4062 cast_to_uintmax_type(value), \
4063 count); \
4064 } while (0)
4065#endif
4066
4067#ifdef DOXYGEN
4086void expect_float(#function, #parameter, double value, double epsilon);
4087#else
4088#define expect_float(function, parameter, value, epsilon) \
4089 expect_float_count(function, parameter, cast_to_double_type(value), \
4090 cast_to_double_type(epsilon), 1)
4091#endif
4092
4093#ifdef DOXYGEN
4116void expect_float_count(#function, #parameter, double value, double epsilon, size_t count);
4117#else
4118#define expect_float_count(function, parameter, value, epsilon, count) \
4119 _expect_float(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4120 cast_to_double_type(value), cast_to_double_type(epsilon), count)
4121#endif
4122
4123#ifdef DOXYGEN
4143void expect_not_float(#function, #parameter, double value, double epsilon);
4144#else
4145#define expect_not_float(function, parameter, value, epsilon) \
4146 expect_not_float_count(function, \
4147 parameter, \
4148 cast_to_float_type(value), \
4149 cast_to_float_type(epsilon), \
4150 1)
4151#endif
4152
4153#ifdef DOXYGEN
4176void expect_not_float_count(#function, #parameter, double value, double epsilon, size_t count);
4177#else
4178#define expect_not_float_count(function, parameter, value, epsilon, count) \
4179 _expect_not_float(cmocka_tostring(function), \
4180 cmocka_tostring(parameter), \
4181 __FILE__, \
4182 __LINE__, \
4183 cast_to_float_type(value), \
4184 cast_to_float_type(epsilon), \
4185 count)
4186#endif
4187
4188#ifdef DOXYGEN
4206void expect_double(#function, #parameter, double value, double epsilon);
4207#else
4208#define expect_double(function, parameter, value, epsilon) \
4209 expect_double_count(function, \
4210 parameter, \
4211 cast_to_double_type(value), \
4212 cast_to_double_type(epsilon), \
4213 1)
4214#endif
4215
4216#ifdef DOXYGEN
4238void expect_double_count(#function,
4239 #parameter,
4240 double value,
4241 double epsilon,
4242 size_t count);
4243#else
4244#define expect_double_count(function, parameter, value, epsilon, count) \
4245 _expect_double(cmocka_tostring(function), \
4246 cmocka_tostring(parameter), \
4247 __FILE__, \
4248 __LINE__, \
4249 cast_to_double_type(value), \
4250 cast_to_double_type(epsilon), \
4251 count)
4252#endif
4253
4254#ifdef DOXYGEN
4272void expect_not_double(#function, #parameter, double value, double epsilon);
4273#else
4274#define expect_not_double(function, parameter, value, epsilon) \
4275 expect_not_double_count(function, \
4276 parameter, \
4277 cast_to_double_type(value), \
4278 cast_to_double_type(epsilon), \
4279 1)
4280#endif
4281
4282#ifdef DOXYGEN
4305 #parameter,
4306 double value,
4307 double epsilon,
4308 size_t count);
4309#else
4310#define expect_not_double_count(function, parameter, value, epsilon, count) \
4311 _expect_not_double(cmocka_tostring(function), \
4312 cmocka_tostring(parameter), \
4313 __FILE__, \
4314 __LINE__, \
4315 cast_to_double_type(value), \
4316 cast_to_double_type(epsilon), \
4317 count)
4318#endif
4319
4320#ifdef DOXYGEN
4335void expect_string(#function, #parameter, const char *string);
4336#else
4337#define expect_string(function, parameter, string) \
4338 expect_string_count(function, parameter, string, 1)
4339#endif
4340
4341#ifdef DOXYGEN
4360void expect_string_count(#function, #parameter, const char *string, size_t count);
4361#else
4362#define expect_string_count(function, parameter, string, count) \
4363 _expect_string(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4364 (const char*)(string), count)
4365#endif
4366
4367#ifdef DOXYGEN
4382void expect_not_string(#function, #parameter, const char *string);
4383#else
4384#define expect_not_string(function, parameter, string) \
4385 expect_not_string_count(function, parameter, string, 1)
4386#endif
4387
4388#ifdef DOXYGEN
4407void expect_not_string_count(#function, #parameter, const char *string, size_t count);
4408#else
4409#define expect_not_string_count(function, parameter, string, count) \
4410 _expect_not_string(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4411 (const char*)(string), count)
4412#endif
4413
4414#ifdef DOXYGEN
4430void expect_memory(#function, #parameter, void *memory, size_t size);
4431#else
4432#define expect_memory(function, parameter, memory, size) \
4433 expect_memory_count(function, parameter, memory, size, 1)
4434#endif
4435
4436#ifdef DOXYGEN
4457void expect_memory_count(#function, #parameter, void *memory, size_t size, size_t count);
4458#else
4459#define expect_memory_count(function, parameter, memory, size, count) \
4460 _expect_memory(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4461 (const void*)(memory), size, count)
4462#endif
4463
4464#ifdef DOXYGEN
4481void expect_not_memory(#function, #parameter, void *memory, size_t size);
4482#else
4483#define expect_not_memory(function, parameter, memory, size) \
4484 expect_not_memory_count(function, parameter, memory, size, 1)
4485#endif
4486
4487#ifdef DOXYGEN
4508void expect_not_memory_count(#function, #parameter, void *memory, size_t size, size_t count);
4509#else
4510#define expect_not_memory_count(function, parameter, memory, size, count) \
4511 _expect_not_memory(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4512 (const void*)(memory), size, count)
4513#endif
4514
4515
4516#ifdef DOXYGEN
4528void expect_any(#function, #parameter);
4529#else
4530#define expect_any(function, parameter) \
4531 expect_any_count(function, parameter, 1)
4532#endif
4533
4534#ifdef DOXYGEN
4546void expect_any_always(#function, #parameter);
4547#else
4548#define expect_any_always(function, parameter) \
4549 expect_any_count(function, parameter, WILL_RETURN_ALWAYS)
4550#endif
4551
4552#ifdef DOXYGEN
4569void expect_any_count(#function, #parameter, size_t count);
4570#else
4571#define expect_any_count(function, parameter, count) \
4572 _expect_any(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, count)
4573#endif
4574
4575#ifdef DOXYGEN
4580void check_expected(#parameter);
4581#else
4582#define check_expected(parameter) \
4583 do { \
4584 CMOCKA_DEPRECATION_WARNING( \
4585 "check_expected: use check_expected_int or " \
4586 "check_expected_uint instead") \
4587 _check_expected(__func__, \
4588 #parameter, \
4589 __FILE__, \
4590 __LINE__, \
4591 cast_int_to_cmocka_value(parameter)); \
4592 } while (0)
4593#endif
4594
4595#ifdef DOXYGEN
4623void check_expected_any(#parameter);
4624#else
4625#define check_expected_any(parameter) \
4626 _check_expected(__func__, #parameter, __FILE__, __LINE__, \
4627 cast_ptr_to_cmocka_value(&(parameter)))
4628#endif
4629
4630#ifdef DOXYGEN
4641void check_expected_ptr(#parameter);
4642#else
4643#define check_expected_ptr(parameter) \
4644 _check_expected(__func__, #parameter, __FILE__, __LINE__, \
4645 cast_ptr_to_cmocka_value(parameter))
4646#endif
4647
4648#ifdef DOXYGEN
4659void check_expected_int(#parameter);
4660#else
4661#define check_expected_int(parameter) \
4662 _check_expected(__func__, \
4663 #parameter, \
4664 __FILE__, \
4665 __LINE__, \
4666 assign_int_to_cmocka_value(parameter))
4667#endif
4668
4669#ifdef DOXYGEN
4680void check_expected_uint(#parameter);
4681#else
4682#define check_expected_uint(parameter) \
4683 _check_expected(__func__, \
4684 #parameter, \
4685 __FILE__, \
4686 __LINE__, \
4687 assign_uint_to_cmocka_value(parameter))
4688#endif
4689
4690#ifdef DOXYGEN
4706void check_expected_float(#parameter);
4707#else
4708#define check_expected_float(parameter) \
4709 _check_expected(__func__, \
4710 #parameter, \
4711 __FILE__, \
4712 __LINE__, \
4713 assign_float_to_cmocka_value(parameter))
4714#endif
4715
4716#ifdef DOXYGEN
4732void check_expected_double(#parameter);
4733#else
4734#define check_expected_double(parameter) \
4735 _check_expected(__func__, \
4736 #parameter, \
4737 __FILE__, \
4738 __LINE__, \
4739 assign_double_to_cmocka_value(parameter))
4740#endif
4741 /* cmocka_param */
4743
4766
4767#ifdef DOXYGEN
4780void assert_true(scalar expression);
4781#else
4782#define assert_true(c) _assert_true(cast_to_uintmax_type(c), #c, \
4783 __FILE__, __LINE__)
4784#endif
4785
4786#ifdef DOXYGEN
4798void assert_false(scalar expression);
4799#else
4800#define assert_false(c) _assert_false(cast_to_uintmax_type(c), #c, \
4801 __FILE__, __LINE__)
4802#endif
4803
4804#ifdef DOXYGEN
4817void assert_return_code(intmax_t rc, int32_t error);
4818#else
4819#define assert_return_code(rc, error) \
4820 _assert_return_code((rc), \
4821 (error), \
4822 #rc, __FILE__, __LINE__)
4823#endif
4824
4825#ifdef DOXYGEN
4836void assert_non_null(void *pointer);
4837#else
4838#define assert_non_null(c) assert_ptr_not_equal((c), NULL)
4839#endif
4840
4841#ifdef DOXYGEN
4854void assert_non_null_msg(void *pointer, const char *const message);
4855#else
4856#define assert_non_null_msg(c, msg) assert_ptr_not_equal_msg((c), NULL, (msg))
4857#endif
4858
4859#ifdef DOXYGEN
4870void assert_null(void *pointer);
4871#else
4872#define assert_null(c) assert_ptr_equal((c), NULL)
4873#endif
4874
4875#ifdef DOXYGEN
4888void assert_null_msg(void *pointer, const char *const message);
4889#else
4890#define assert_null_msg(c, msg) assert_ptr_equal_msg((c), NULL, (msg))
4891#endif
4892
4893#ifdef DOXYGEN
4904void assert_ptr_equal(void *a, void *b);
4905#else
4906#define assert_ptr_equal(a, b) assert_ptr_equal_msg((a), (b), NULL)
4907#endif
4908
4909#ifdef DOXYGEN
4922void assert_ptr_equal_msg(void *a, void *b, const char *const msg);
4923#else
4924#define assert_ptr_equal_msg(a, b, msg) \
4925 _assert_ptr_equal_msg(cast_to_void_pointer(a), \
4926 cast_to_void_pointer(b), \
4927 __FILE__, __LINE__, (msg))
4928#endif
4929
4930#ifdef DOXYGEN
4941void assert_ptr_not_equal(void *a, void *b);
4942#else
4943#define assert_ptr_not_equal(a, b) \
4944 assert_ptr_not_equal_msg((a), (b), NULL)
4945#endif
4946
4947#ifdef DOXYGEN
4960void assert_ptr_not_equal_msg(void *a, void *b, const char *const msg);
4961#else /* DOXYGEN */
4962
4963#if defined(__has_builtin)
4964
4965#if __has_builtin(__builtin_unreachable)
4966#define assert_ptr_not_equal_msg(a, b, msg) \
4967 do { \
4968 const void *cmocka_p1 = cast_to_void_pointer(a), \
4969 *cmocka_p2 = cast_to_void_pointer(b); \
4970 _assert_ptr_not_equal_msg( \
4971 cmocka_p1, cmocka_p2, __FILE__, __LINE__, (msg)); \
4972 if (cmocka_p1 == cmocka_p2) { \
4973 __builtin_unreachable(); \
4974 } \
4975 } while (0)
4976#else /* __has_builtin(__builtin_unreachable) */
4977#define assert_ptr_not_equal_msg(a, b, msg) \
4978_assert_ptr_not_equal_msg(cast_to_void_pointer(a), \
4979 cast_to_void_pointer(b), \
4980 __FILE__, \
4981 __LINE__, \
4982 (msg))
4983#endif /* __has_builtin(__builtin_unreachable) */
4984
4985#else /* defined(__has_builtin) */
4986#define assert_ptr_not_equal_msg(a, b, msg) \
4987_assert_ptr_not_equal_msg(cast_to_void_pointer(a), \
4988 cast_to_void_pointer(b), \
4989 __FILE__, \
4990 __LINE__, \
4991 (msg))
4992#endif /* __has_builtin(__builtin_unreachable) */
4993
4994#endif /* DOXYGEN */
4995
4996#ifdef DOXYGEN
5007void assert_int_equal(intmax_t a, intmax_t b);
5008#else
5009#define assert_int_equal(a, b) \
5010 _assert_int_equal(cast_to_intmax_type(a), \
5011 cast_to_intmax_type(b), \
5012 __FILE__, __LINE__)
5013#endif
5014
5015#ifdef DOXYGEN
5026void assert_uint_equal(uintmax_t a, uintmax_t b);
5027#else
5028#define assert_uint_equal(a, b) \
5029 _assert_uint_equal(cast_to_uintmax_type(a), \
5030 cast_to_uintmax_type(b), \
5031 __FILE__, __LINE__)
5032#endif
5033
5034#ifdef DOXYGEN
5047void assert_int_not_equal(intmax_t a, intmax_t b);
5048#else
5049#define assert_int_not_equal(a, b) \
5050 _assert_int_not_equal(cast_to_intmax_type(a), \
5051 cast_to_intmax_type(b), \
5052 __FILE__, __LINE__)
5053#endif
5054
5055#ifdef DOXYGEN
5066void assert_uint_not_equal(uintmax_t a, uintmax_t b);
5067#else
5068#define assert_uint_not_equal(a, b) \
5069 _assert_uint_not_equal(cast_to_uintmax_type(a), \
5070 cast_to_uintmax_type(b), \
5071 __FILE__, __LINE__)
5072#endif
5073
5074#ifdef DOXYGEN
5087void assert_float_equal(float a, float b, float epsilon);
5088#else
5089#define assert_float_equal(a, b, epsilon) \
5090 _assert_float_equal((float)a, \
5091 (float)b, \
5092 (float)epsilon, \
5093 __FILE__, __LINE__)
5094#endif
5095
5096#ifdef DOXYGEN
5109void assert_float_not_equal(float a, float b, float epsilon);
5110#else
5111#define assert_float_not_equal(a, b, epsilon) \
5112 _assert_float_not_equal((float)a, \
5113 (float)b, \
5114 (float)epsilon, \
5115 __FILE__, __LINE__)
5116#endif
5117
5118#ifdef DOXYGEN
5131void assert_double_equal(double a, double b, double epsilon);
5132#else
5133#define assert_double_equal(a, b, epsilon) \
5134 _assert_double_equal((double)a, \
5135 (double)b, \
5136 (double)epsilon, \
5137 __FILE__, __LINE__)
5138#endif
5139
5140#ifdef DOXYGEN
5153void assert_double_not_equal(double a, double b, double epsilon);
5154#else
5155#define assert_double_not_equal(a, b, epsilon) \
5156 _assert_double_not_equal((double)a, \
5157 (double)b, \
5158 (double)epsilon, \
5159 __FILE__, __LINE__)
5160#endif
5161
5162
5163#ifdef DOXYGEN
5174void assert_string_equal(const char *a, const char *b);
5175#else
5176#define assert_string_equal(a, b) \
5177 _assert_string_equal((a), (b), __FILE__, __LINE__)
5178#endif
5179
5180#ifdef DOXYGEN
5191void assert_string_not_equal(const char *a, const char *b);
5192#else
5193#define assert_string_not_equal(a, b) \
5194 _assert_string_not_equal((a), (b), __FILE__, __LINE__)
5195#endif
5196
5197#ifdef DOXYGEN
5212void assert_memory_equal(const void *a, const void *b, size_t size);
5213#else
5214#define assert_memory_equal(a, b, size) \
5215 _assert_memory_equal((const void*)(a), (const void*)(b), size, __FILE__, \
5216 __LINE__)
5217#endif
5218
5219#ifdef DOXYGEN
5234void assert_memory_not_equal(const void *a, const void *b, size_t size);
5235#else
5236#define assert_memory_not_equal(a, b, size) \
5237 _assert_memory_not_equal((const void*)(a), (const void*)(b), size, \
5238 __FILE__, __LINE__)
5239#endif
5240
5241#ifdef DOXYGEN
5255void assert_int_in_range(intmax_t value, intmax_t minimum, intmax_t maximum);
5256#else
5257#define assert_int_in_range(value, minimum, maximum) \
5258 _assert_int_in_range( \
5259 cast_to_intmax_type(value), \
5260 cast_to_intmax_type(minimum), \
5261 cast_to_intmax_type(maximum), __FILE__, __LINE__)
5262#endif
5263
5264#ifdef DOXYGEN
5278void assert_uint_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum);
5279#else
5280#define assert_uint_in_range(value, minimum, maximum) \
5281 _assert_uint_in_range( \
5282 cast_to_intmax_type(value), \
5283 cast_to_intmax_type(minimum), \
5284 cast_to_intmax_type(maximum), __FILE__, __LINE__)
5285#endif
5286
5287#ifdef DOXYGEN
5304void assert_int_not_in_range(intmax_t value,
5305 intmax_t minimum,
5306 intmax_t maximum);
5307#else
5308#define assert_int_not_in_range(value, minimum, maximum) \
5309 _assert_int_not_in_range(cast_to_intmax_type(value), \
5310 cast_to_intmax_type(minimum), \
5311 cast_to_intmax_type(maximum), \
5312 __FILE__, \
5313 __LINE__)
5314#endif
5315
5316#ifdef DOXYGEN
5333void assert_uint_not_in_range(uintmax_t value,
5334 uintmax_t minimum,
5335 uintmax_t maximum);
5336#else
5337#define assert_uint_not_in_range(value, minimum, maximum) \
5338 _assert_uint_not_in_range(cast_to_uintmax_type(value), \
5339 cast_to_uintmax_type(minimum), \
5340 cast_to_uintmax_type(maximum), \
5341 __FILE__, \
5342 __LINE__)
5343#endif
5344
5345#ifdef DOXYGEN
5349void assert_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum);
5350#else
5351#define assert_in_range(value, minimum, maximum) \
5352 do { \
5353 CMOCKA_DEPRECATION_WARNING( \
5354 "assert_in_range: use assert_int_in_range or " \
5355 "assert_uint_in_range instead") \
5356 _assert_uint_in_range(cast_to_uintmax_type(value), \
5357 cast_to_uintmax_type(minimum), \
5358 cast_to_uintmax_type(maximum), \
5359 __FILE__, \
5360 __LINE__); \
5361 } while (0)
5362#endif
5363
5364#ifdef DOXYGEN
5368void assert_not_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum);
5369#else
5370#define assert_not_in_range(value, minimum, maximum) \
5371 do { \
5372 CMOCKA_DEPRECATION_WARNING( \
5373 "assert_not_in_range: use assert_int_not_in_range or " \
5374 "assert_uint_not_in_range instead") \
5375 _assert_uint_not_in_range(cast_to_uintmax_type(value), \
5376 cast_to_uintmax_type(minimum), \
5377 cast_to_uintmax_type(maximum), \
5378 __FILE__, \
5379 __LINE__); \
5380 } while (0)
5381#endif
5382
5383#ifdef DOXYGEN
5402void assert_float_not_in_range(double value, double minimum, double maximum, double epsilon);
5403#else
5404#define assert_float_not_in_range(value, minimum, maximum, epsilon) \
5405 _assert_float_not_in_range(cast_to_double_type(value), \
5406 cast_to_double_type(minimum), \
5407 cast_to_double_type(maximum), \
5408 cast_to_double_type(epsilon), \
5409 __FILE__, \
5410 __LINE__)
5411#endif
5412
5413#ifdef DOXYGEN
5429void assert_float_in_range(double value, double minimum, double maximum, double epsilon);
5430#else
5431#define assert_float_in_range(value, minimum, maximum, epsilon) \
5432 _assert_float_in_range( \
5433 cast_to_double_type(value), \
5434 cast_to_double_type(minimum), \
5435 cast_to_double_type(maximum), \
5436 cast_to_double_type(epsilon), __FILE__, __LINE__)
5437#endif
5438
5439#ifdef DOXYGEN
5443void assert_in_set(uintmax_t value, uintmax_t values[], size_t count);
5444#else
5445#define assert_in_set(value, values, number_of_values) \
5446 do { \
5447 CMOCKA_DEPRECATION_WARNING("assert_in_set: use assert_int_in_set or " \
5448 "assert_uint_in_set instead") \
5449 _assert_uint_in_set( \
5450 value, values, number_of_values, __FILE__, __LINE__); \
5451 } while (0)
5452#endif
5453
5454#ifdef DOXYGEN
5467void assert_not_in_set(uintmax_t value, uintmax_t values[], size_t count);
5468#else
5469#define assert_not_in_set(value, values, number_of_values) \
5470 _assert_not_in_set(value, values, number_of_values, __FILE__, __LINE__)
5471#endif
5472
5473#ifdef DOXYGEN
5486void assert_int_in_set(intmax_t value, intmax_t values[], size_t count);
5487#else
5488#define assert_int_in_set(value, values, number_of_values) \
5489 if (number_of_values > 0) { \
5490 intmax_t _cmocka_set[number_of_values]; \
5491 for (size_t _i = 0; _i < number_of_values; _i++) { \
5492 _cmocka_set[_i] = values[_i]; \
5493 } \
5494 _assert_int_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5495 }
5496#endif
5497
5498#ifdef DOXYGEN
5511void assert_int_not_in_set(intmax_t value, intmax_t values[], size_t count);
5512#else
5513#define assert_int_not_in_set(value, values, number_of_values) \
5514 if (number_of_values > 0) { \
5515 intmax_t _cmocka_set[number_of_values]; \
5516 for (size_t _i = 0; _i < number_of_values; _i++) { \
5517 _cmocka_set[_i] = values[_i]; \
5518 } \
5519 _assert_int_not_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5520 }
5521#endif
5522
5523#ifdef DOXYGEN
5536void assert_uint_in_set(uintmax_t value, uintmax_t values[], size_t count);
5537#else
5538#define assert_uint_in_set(value, values, number_of_values) \
5539 if (number_of_values > 0) { \
5540 uintmax_t _cmocka_set[number_of_values]; \
5541 for (size_t _i = 0; _i < number_of_values; _i++) { \
5542 _cmocka_set[_i] = values[_i]; \
5543 } \
5544 _assert_uint_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5545 }
5546#endif
5547
5548#ifdef DOXYGEN
5561void assert_uint_not_in_set(uintmax_t value, uintmax_t values[], size_t count);
5562#else
5563#define assert_uint_not_in_set(value, values, number_of_values) \
5564 if (number_of_values > 0) { \
5565 uintmax_t _cmocka_set[number_of_values]; \
5566 for (size_t _i = 0; _i < number_of_values; _i++) { \
5567 _cmocka_set[_i] = values[_i]; \
5568 } \
5569 _assert_uint_not_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5570 }
5571#endif
5572
5573#ifdef DOXYGEN
5588void assert_float_in_set(double value, double values[], size_t count, double epsilon);
5589#else
5590#define assert_float_in_set(value, values, number_of_values, epsilon) \
5591 if (number_of_values > 0) { \
5592 double _cmocka_set[number_of_values]; \
5593 for (size_t _i = 0; _i < number_of_values; _i++) { \
5594 _cmocka_set[_i] = values[_i]; \
5595 } \
5596 _assert_float_in_set(value, _cmocka_set, number_of_values, epsilon, __FILE__, __LINE__); \
5597 }
5598#endif
5599
5600#ifdef DOXYGEN
5615void assert_float_not_in_set(double value, double values[], size_t count, double epsilon);
5616#else
5617#define assert_float_not_in_set(value, values, number_of_values, epsilon) \
5618 if (number_of_values > 0) { \
5619 double _cmocka_set[number_of_values]; \
5620 for (size_t _i = 0; _i < number_of_values; _i++) { \
5621 _cmocka_set[_i] = values[_i]; \
5622 } \
5623 _assert_float_not_in_set(value, _cmocka_set, number_of_values, epsilon, __FILE__, __LINE__); \
5624 }
5625#endif
5626 /* cmocka_asserts */
5628
5692
5693#ifdef DOXYGEN
5701#else
5702#define function_called() _function_called(__func__, __FILE__, __LINE__)
5703#endif
5704
5705#ifdef DOXYGEN
5716void expect_function_calls(#function, const int times);
5717#else
5718#define expect_function_calls(function, times) \
5719 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, times)
5720#endif
5721
5722#ifdef DOXYGEN
5731void expect_function_call(#function);
5732#else
5733#define expect_function_call(function) \
5734 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, 1)
5735#endif
5736
5737#ifdef DOXYGEN
5746#else
5747#define expect_function_call_any(function) \
5748 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, -1)
5749#endif
5750
5751#ifdef DOXYGEN
5760#else
5761#define ignore_function_calls(function) \
5762 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, -2)
5763#endif
5764 /* cmocka_call_order */
5766
5798
5799#ifdef DOXYGEN
5803void fail(void);
5804#else
5805#define fail() _fail(__FILE__, __LINE__)
5806#endif
5807
5808#ifdef DOXYGEN
5812void skip(void);
5813#else
5814#define skip() _skip(__FILE__, __LINE__)
5815#endif
5816
5817#ifdef DOXYGEN
5826void stop(void);
5827#else
5828#define stop() _stop()
5829#endif
5830
5831#ifdef DOXYGEN
5846void fail_msg(const char *msg, ...);
5847#else
5848#define fail_msg(msg, ...) do { \
5849 cmocka_print_error("ERROR: " msg "\n", ##__VA_ARGS__); \
5850 fail(); \
5851} while (0)
5852#endif
5853
5854static inline void _unit_test_dummy(void **state) {
5855 (void)state;
5856}
5857
5862#define unit_test(f) \
5863 (CMOCKA_DEPRECATION_WARNING("unit_test: use cmocka_unit_test instead")( \
5864 UnitTest){#f, f, UNIT_TEST_FUNCTION_TYPE_TEST})
5865
5867#define _unit_test_setup(test, setup) \
5868 { #test "_" #setup, setup, UNIT_TEST_FUNCTION_TYPE_SETUP }
5870
5875#define unit_test_setup(test, setup) \
5876 CMOCKA_DEPRECATION_WARNING( \
5877 "unit_test_setup: use cmocka_unit_test_setup instead") \
5878 _unit_test_setup(test, setup), unit_test(test), \
5879 _unit_test_teardown(test, _unit_test_dummy)
5880
5882#define _unit_test_teardown(test, teardown) \
5883 { #test "_" #teardown, teardown, UNIT_TEST_FUNCTION_TYPE_TEARDOWN }
5885
5890#define unit_test_teardown(test, teardown) \
5891 CMOCKA_DEPRECATION_WARNING( \
5892 "unit_test_teardown: use cmocka_unit_test_teardown instead") \
5893 _unit_test_setup(test, _unit_test_dummy), unit_test(test), \
5894 _unit_test_teardown(test, teardown)
5895
5900#define group_test_setup(setup) \
5901 (CMOCKA_DEPRECATION_WARNING( \
5902 "group_test_setup: use cmocka_run_group_tests instead")(UnitTest){ \
5903 "group_" #setup, setup, UNIT_TEST_FUNCTION_TYPE_GROUP_SETUP})
5904
5909#define group_test_teardown(teardown) \
5910 (CMOCKA_DEPRECATION_WARNING( \
5911 "group_test_teardown: use cmocka_run_group_tests instead")(UnitTest){ \
5912 "group_" #teardown, teardown, UNIT_TEST_FUNCTION_TYPE_GROUP_TEARDOWN})
5913
5921#define unit_test_setup_teardown(test, setup, teardown) \
5922 CMOCKA_DEPRECATION_WARNING("unit_test_setup_teardown: use " \
5923 "cmocka_unit_test_setup_teardown instead") \
5924 _unit_test_setup(test, setup), unit_test(test), \
5925 _unit_test_teardown(test, teardown)
5926
5928#define cmocka_unit_test(f) { #f, f, NULL, NULL, NULL }
5929
5931#define cmocka_unit_test_setup(f, setup) { #f, f, setup, NULL, NULL }
5932
5934#define cmocka_unit_test_teardown(f, teardown) { #f, f, NULL, teardown, NULL }
5935
5940#define cmocka_unit_test_setup_teardown(f, setup, teardown) { #f, f, setup, teardown, NULL }
5941
5949#define cmocka_unit_test_prestate(f, state) { #f, f, NULL, NULL, state }
5950
5958#define cmocka_unit_test_prestate_setup_teardown(f, setup, teardown, state) { #f, f, setup, teardown, state }
5959
5960#ifdef DOXYGEN
6017int cmocka_run_group_tests(const struct CMUnitTest group_tests[],
6018 CMFixtureFunction group_setup,
6019 CMFixtureFunction group_teardown);
6020#else
6021# define cmocka_run_group_tests(group_tests, group_setup, group_teardown) \
6022 _cmocka_run_group_tests(#group_tests, group_tests, sizeof(group_tests) / sizeof((group_tests)[0]), group_setup, group_teardown)
6023#endif
6024
6025#ifdef DOXYGEN
6085int cmocka_run_group_tests_name(const char *group_name,
6086 const struct CMUnitTest group_tests[],
6087 CMFixtureFunction group_setup,
6088 CMFixtureFunction group_teardown);
6089#else
6090# define cmocka_run_group_tests_name(group_name, group_tests, group_setup, group_teardown) \
6091 _cmocka_run_group_tests(group_name, group_tests, sizeof(group_tests) / sizeof((group_tests)[0]), group_setup, group_teardown)
6092#endif
6093 /* cmocka_exec */
6095
6155
6156#ifdef DOXYGEN
6179void *test_malloc(size_t size);
6180#else
6181#define test_malloc(size) _test_malloc(size, __FILE__, __LINE__)
6182#endif
6183
6184#ifdef DOXYGEN
6198void *test_calloc(size_t nmemb, size_t size);
6199#else
6200#define test_calloc(num, size) _test_calloc(num, size, __FILE__, __LINE__)
6201#endif
6202
6203#ifdef DOXYGEN
6214void *test_realloc(void *ptr, size_t size);
6215#else
6216#define test_realloc(ptr, size) _test_realloc(ptr, size, __FILE__, __LINE__)
6217#endif
6218
6219#ifdef DOXYGEN
6227void test_free(void *ptr);
6228#else
6229#define test_free(ptr) _test_free(ptr, __FILE__, __LINE__)
6230#endif
6231
6232#if defined(UNIT_TESTING) && defined(ALLOCATION_TESTING)
6233#define malloc test_malloc
6234#define realloc test_realloc
6235#define calloc test_calloc
6236#define free test_free
6237#endif /* UNIT_TESTING && ALLOCATION_TESTING */
6238 /* cmocka_alloc */
6240
6258
6292void mock_assert(const int result, const char* const expression,
6293 const char * const file, const int line);
6294
6295#ifdef DOXYGEN
6318void expect_assert_failure(function fn_call);
6319#else
6320#define expect_assert_failure(function_call) \
6321 { \
6322 global_expecting_assert = 1; \
6323 if (setjmp(global_expect_assert_env) != 0) { \
6324 print_message("Expected assertion %s occurred\n", \
6325 global_last_failed_assert); \
6326 global_expecting_assert = 0; \
6327 } else { \
6328 function_call ; \
6329 global_expecting_assert = 0; \
6330 print_error("Expected assert in %s\n", #function_call); \
6331 _fail(__FILE__, __LINE__); \
6332 } \
6333 }
6334#endif
6335 /* cmocka_mock_assert */
6337
6346typedef union {
6348 intmax_t int_val;
6350 uintmax_t uint_val;
6354 double real_val; // TODO: Should we use `long double` instead
6356 void *ptr;
6358 const void *const_ptr;
6359 // The following aren't used by CMocka currently, but are added to avoid
6360 // breaking ABI compatibility in the future
6362 void *(*func)(void);
6364
6365#ifndef DOXYGEN
6370#define LargestIntegralType uintmax_t
6371
6375#if defined(__GNUC__)
6376#define cast_ptr_to_largest_integral_type(value) \
6377 __extension__({ \
6378 CMOCKA_DEPRECATION_WARNING( \
6379 "cast_ptr_to_largest_integral_type: " \
6380 "use cast_ptr_to_uintmax_type instead"); \
6381 cast_ptr_to_uintmax_type(value); \
6382 })
6383#else
6384#define cast_ptr_to_largest_integral_type(value) \
6385 cast_ptr_to_uintmax_type(value)
6386#endif
6387#endif
6388
6394typedef void (*UnitTestFunction)(void **state);
6395
6401typedef int (*CheckParameterValue)(const uintmax_t value,
6402 const uintmax_t check_value_data);
6403
6409typedef int (*CheckParameterValueData)(const CMockaValueData value,
6410 const CMockaValueData check_value_data);
6411
6417typedef int (*CheckIntParameterValue)(const intmax_t value,
6418 const intmax_t check_value_data);
6419
6425typedef int (*CheckUintParameterValue)(const uintmax_t value,
6426 const uintmax_t check_value_data);
6427
6434 UNIT_TEST_FUNCTION_TYPE_TEST = 0,
6435 UNIT_TEST_FUNCTION_TYPE_SETUP,
6436 UNIT_TEST_FUNCTION_TYPE_TEARDOWN,
6437 UNIT_TEST_FUNCTION_TYPE_GROUP_SETUP,
6438 UNIT_TEST_FUNCTION_TYPE_GROUP_TEARDOWN,
6440
6448typedef struct UnitTest {
6449 const char* name;
6450 UnitTestFunction function;
6451 UnitTestFunctionType function_type;
6453
6457typedef struct GroupTest {
6458 UnitTestFunction setup;
6459 UnitTestFunction teardown;
6460 const UnitTest *tests;
6461 const size_t number_of_tests;
6462} GroupTest;
6463
6469typedef void (*CMUnitTestFunction)(void **state);
6470
6476typedef int (*CMFixtureFunction)(void **state);
6477
6482 const char *name;
6483 CMUnitTestFunction test_func;
6484 CMFixtureFunction setup_func;
6485 CMFixtureFunction teardown_func;
6486 void *initial_state;
6487};
6488
6494typedef struct SourceLocation {
6495 const char* file;
6496 int line;
6498
6504typedef struct CheckParameterEvent {
6505 SourceLocation location;
6506 const char *parameter_name;
6507 CheckParameterValue check_value;
6508 uintmax_t check_value_data;
6510
6517 SourceLocation location;
6518 const char *parameter_name;
6519 CheckParameterValueData check_value;
6520 CMockaValueData check_value_data;
6522
6536
6537/* Standard output and error print methods. */
6538void print_message(const char* const format, ...) CMOCKA_PRINTF_ATTRIBUTE(1, 2);
6539void print_error(const char* const format, ...) CMOCKA_PRINTF_ATTRIBUTE(1, 2);
6540void vprint_message(const char* const format, va_list args) CMOCKA_PRINTF_ATTRIBUTE(1, 0);
6541void vprint_error(const char* const format, va_list args) CMOCKA_PRINTF_ATTRIBUTE(1, 0);
6542
6557 void (*vprint_message)(const char * const format, va_list args);
6558
6566 void (*vprint_error)(const char * const format, va_list args);
6567};
6568
6583void cmocka_set_callbacks(const struct CMCallbacks *f_callbacks);
6584
6597 CM_OUTPUT_STDOUT = 0x00000001,
6599 CM_OUTPUT_SUBUNIT = 0x00000002,
6601 CM_OUTPUT_TAP = 0x00000004,
6603 CM_OUTPUT_XML = 0x00000008,
6604};
6605
6606#ifdef DOXYGEN
6610void cm_print_error(const char* const format, ...);
6611#else
6612#define cm_print_error(format, ...) \
6613 do { \
6614 CMOCKA_DEPRECATION_WARNING( \
6615 "cm_print_error: use cmocka_print_error instead") \
6616 cmocka_print_error(format, ##__VA_ARGS__); \
6617 } while (0)
6618#endif
6619
6632void cmocka_print_error(const char* const format, ...) CMOCKA_PRINTF_ATTRIBUTE(1, 2);
6633
6650void cmocka_set_message_output(uint32_t output);
6651
6652
6668void cmocka_set_test_filter(const char *pattern);
6669
6685void cmocka_set_skip_filter(const char *pattern);
6686 /* cmocka_config */
6688
6698
6699/* Used by expect_assert_failure() and mock_assert(). */
6700CMOCKA_DLLEXTERN extern int global_expecting_assert;
6701CMOCKA_DLLEXTERN extern jmp_buf global_expect_assert_env;
6702CMOCKA_DLLEXTERN extern const char * global_last_failed_assert;
6703
6704/* Retrieves a value for the given function, as set by "will_return". */
6705CMockaValueData _mock(const char *const function,
6706 const char *const file,
6707 const int line,
6708 const char *name);
6709
6710CMockaValueData _mock_parameter(const char *const function,
6711 const char *name,
6712 const char *const file,
6713 const int line,
6714 const char *type);
6715
6716bool _has_mock(const char *const function);
6717
6718void _expect_function_call(
6719 const char * const function_name,
6720 const char * const file,
6721 const int line,
6722 const int count);
6723
6724void _function_called(const char * const function, const char* const file,
6725 const int line);
6726
6727/* Old API function using uintmax_t */
6728void _expect_check(
6729 const char* const function, const char* const parameter,
6730 const char* const file, const int line,
6731 const CheckParameterValue check_function,
6732 const uintmax_t check_data, CheckParameterEvent * const event,
6733 const int count) CMOCKA_DEPRECATED;
6734
6735/* New API function using CMockaValueData */
6736void _expect_check_data(
6737 const char* const function, const char* const parameter,
6738 const char* const file, const int line,
6739 const CheckParameterValueData check_function,
6740 const CMockaValueData check_data, CheckParameterEventData * const event,
6741 const int count);
6742
6743void _expect_int_in_set(const char *const function,
6744 const char *const parameter,
6745 const char *const file,
6746 const size_t line,
6747 const intmax_t values[],
6748 const size_t number_of_values,
6749 const size_t count);
6750void _expect_uint_in_set(const char *const function,
6751 const char *const parameter,
6752 const char *const file,
6753 const size_t line,
6754 const uintmax_t values[],
6755 const size_t number_of_values,
6756 const size_t count);
6757
6758void _expect_float_in_set(const char *const function,
6759 const char *const parameter,
6760 const char *const file,
6761 const size_t line,
6762 const double values[],
6763 const size_t number_of_values,
6764 const double epsilon,
6765 const size_t count);
6766
6767void _expect_not_in_set(
6768 const char* const function, const char* const parameter,
6769 const char* const file, const int line, const uintmax_t values[],
6770 const size_t number_of_values, const int count);
6771void _expect_int_not_in_set(const char *const function,
6772 const char *const parameter,
6773 const char *const file,
6774 const size_t line,
6775 const intmax_t values[],
6776 const size_t number_of_values,
6777 const size_t count);
6778void _expect_uint_not_in_set(const char *const function,
6779 const char *const parameter,
6780 const char *const file,
6781 const size_t line,
6782 const uintmax_t values[],
6783 const size_t number_of_values,
6784 const size_t count);
6785
6786void _expect_float_not_in_set(
6787 const char* const function, const char* const parameter,
6788 const char* const file, const size_t line, const double values[],
6789 const size_t number_of_values, const double epsilon, const size_t count);
6790
6791void _expect_in_range(const char *const function,
6792 const char *const parameter,
6793 const char *const file,
6794 const int line,
6795 const uintmax_t minimum,
6796 const uintmax_t maximum,
6797 const int count) CMOCKA_DEPRECATED;
6798void _expect_int_in_range(const char *const function,
6799 const char *const parameter,
6800 const char *const file,
6801 const size_t line,
6802 const intmax_t minimum,
6803 const intmax_t maximum,
6804 const size_t count);
6805void _expect_uint_in_range(const char *const function,
6806 const char *const parameter,
6807 const char *const file,
6808 const size_t line,
6809 const uintmax_t minimum,
6810 const uintmax_t maximum,
6811 const size_t count);
6812void _expect_not_in_range(
6813 const char* const function, const char* const parameter,
6814 const char* const file, const int line,
6815 const uintmax_t minimum,
6816 const uintmax_t maximum, const int count);
6817void _expect_int_not_in_range(const char *const function,
6818 const char *const parameter,
6819 const char *const file,
6820 const size_t line,
6821 const intmax_t minimum,
6822 const intmax_t maximum,
6823 const size_t count);
6824void _expect_uint_not_in_range(const char *const function,
6825 const char *const parameter,
6826 const char *const file,
6827 const size_t line,
6828 const uintmax_t minimum,
6829 const uintmax_t maximum,
6830 const size_t count);
6831void _expect_float_in_range(
6832 const char* const function, const char* const parameter,
6833 const char* const file, const int line,
6834 const double minimum, const double maximum, const double epsilon,
6835 const int count);
6836void _expect_float_not_in_range(
6837 const char* const function, const char* const parameter,
6838 const char* const file, const int line,
6839 const double minimum, const double maximum, const double epsilon,
6840 const int count);
6841
6842void _expect_value(
6843 const char* const function, const char* const parameter,
6844 const char* const file, const int line, const uintmax_t value,
6845 const int count);
6846void _expect_int_value(const char *const function,
6847 const char *const parameter,
6848 const char *const file,
6849 const size_t line,
6850 const intmax_t value,
6851 const size_t count);
6852void _expect_uint_value(const char *const function,
6853 const char *const parameter,
6854 const char *const file,
6855 const size_t line,
6856 const uintmax_t value,
6857 const size_t count);
6858void _expect_int_not_value(const char *const function,
6859 const char *const parameter,
6860 const char *const file,
6861 const size_t line,
6862 const intmax_t value,
6863 const size_t count);
6864void _expect_uint_not_value(const char *const function,
6865 const char *const parameter,
6866 const char *const file,
6867 const size_t line,
6868 const uintmax_t value,
6869 const size_t count);
6870void _expect_not_value(
6871 const char* const function, const char* const parameter,
6872 const char* const file, const int line, const uintmax_t value,
6873 const int count);
6874
6875void _expect_float(
6876 const char* const function, const char* const parameter,
6877 const char* const file, const int line, const double value,
6878 const double epsilon, const int count);
6879void _expect_not_float(
6880 const char* const function, const char* const parameter,
6881 const char* const file, const int line, const double value,
6882 const double epsilon, const int count);
6883
6884void _expect_double(const char *const function,
6885 const char *const parameter,
6886 const char *const file,
6887 const int line,
6888 const double value,
6889 const double epsilon,
6890 const int count);
6891void _expect_not_double(const char *const function,
6892 const char *const parameter,
6893 const char *const file,
6894 const int line,
6895 const double value,
6896 const double epsilon,
6897 const int count);
6898
6899void _expect_string(
6900 const char* const function, const char* const parameter,
6901 const char* const file, const int line, const char* string,
6902 const int count);
6903void _expect_not_string(
6904 const char* const function, const char* const parameter,
6905 const char* const file, const int line, const char* string,
6906 const int count);
6907
6908void _expect_memory(
6909 const char* const function, const char* const parameter,
6910 const char* const file, const int line, const void* const memory,
6911 const size_t size, const int count);
6912void _expect_not_memory(
6913 const char* const function, const char* const parameter,
6914 const char* const file, const int line, const void* const memory,
6915 const size_t size, const int count);
6916
6917void _expect_any(
6918 const char* const function, const char* const parameter,
6919 const char* const file, const int line, const int count);
6920
6921void _check_expected(
6922 const char * const function_name, const char * const parameter_name,
6923 const char* file, const int line, const CMockaValueData value);
6924
6925void _will_return(const char *const function_name,
6926 const char *const file,
6927 const int line,
6928 const char *name,
6929 const CMockaValueData value,
6930 const int count);
6931void _will_set_parameter(const char *const function_name,
6932 const char *name,
6933 const char *const file,
6934 const int line,
6935 const char *type,
6936 const CMockaValueData value,
6937 const int count);
6938void _assert_true(const uintmax_t result,
6939 const char* const expression,
6940 const char * const file, const int line);
6941void _assert_false(const uintmax_t result,
6942 const char * const expression,
6943 const char * const file, const int line);
6944void _assert_return_code(const intmax_t result,
6945 const int32_t error,
6946 const char * const expression,
6947 const char * const file,
6948 const int line);
6949void _assert_float_equal(const float a, const float n,
6950 const float epsilon, const char* const file,
6951 const int line);
6952void _assert_float_not_equal(const float a, const float n,
6953 const float epsilon, const char* const file,
6954 const int line);
6955void _assert_double_equal(const double a, const double n,
6956 const double epsilon, const char* const file,
6957 const int line);
6958void _assert_double_not_equal(const double a, const double n,
6959 const double epsilon, const char* const file,
6960 const int line);
6961void _assert_int_equal(const intmax_t a,
6962 const intmax_t b,
6963 const char * const file,
6964 const int line);
6965void _assert_int_not_equal(const intmax_t a,
6966 const intmax_t b,
6967 const char * const file,
6968 const int line);
6969void _assert_uint_equal(const uintmax_t a,
6970 const uintmax_t b,
6971 const char * const file,
6972 const int line);
6973void _assert_uint_not_equal(const uintmax_t a,
6974 const uintmax_t b,
6975 const char * const file,
6976 const int line);
6977CMOCKA_NO_ACCESS_ATTRIBUTE
6978void _assert_ptr_equal_msg(const void *a,
6979 const void *b,
6980 const char *const file,
6981 const int line,
6982 const char *const msg);
6983CMOCKA_NO_ACCESS_ATTRIBUTE
6984void _assert_ptr_not_equal_msg(const void *a,
6985 const void *b,
6986 const char *const file,
6987 const int line,
6988 const char *const msg);
6989void _assert_string_equal(const char * const a, const char * const b,
6990 const char * const file, const int line);
6991void _assert_string_not_equal(const char * const a, const char * const b,
6992 const char *file, const int line);
6993void _assert_memory_equal(const void * const a, const void * const b,
6994 const size_t size, const char* const file,
6995 const int line);
6996void _assert_memory_not_equal(const void * const a, const void * const b,
6997 const size_t size, const char* const file,
6998 const int line);
6999void _assert_int_in_range(const intmax_t value,
7000 const intmax_t minimum,
7001 const intmax_t maximum,
7002 const char* const file,
7003 const int line);
7004void _assert_int_not_in_range(const intmax_t value,
7005 const intmax_t minimum,
7006 const intmax_t maximum,
7007 const char *const file,
7008 const int line);
7009void _assert_uint_in_range(const uintmax_t value,
7010 const uintmax_t minimum,
7011 const uintmax_t maximum,
7012 const char* const file,
7013 const int line);
7014void _assert_uint_not_in_range(const uintmax_t value,
7015 const uintmax_t minimum,
7016 const uintmax_t maximum,
7017 const char* const file,
7018 const int line);
7019void _assert_float_in_range(const double value,
7020 const double minimum,
7021 const double maximum,
7022 const double epsilon,
7023 const char* const file,
7024 const int line);
7025void _assert_float_not_in_range(const double value,
7026 const double minimum,
7027 const double maximum,
7028 const double epsilon,
7029 const char* const file,
7030 const int line);
7031void _assert_not_in_set(
7032 const uintmax_t value, const uintmax_t values[],
7033 const size_t number_of_values, const char* const file, const int line);
7034void _assert_int_in_set(const intmax_t value,
7035 const intmax_t values[],
7036 const size_t number_of_values,
7037 const char *const file,
7038 const int line);
7039void _assert_int_not_in_set(const intmax_t value,
7040 const intmax_t values[],
7041 const size_t number_of_values,
7042 const char *const file,
7043 const int line);
7044void _assert_uint_in_set(const uintmax_t value,
7045 const uintmax_t values[],
7046 const size_t number_of_values,
7047 const char *const file,
7048 const int line);
7049void _assert_uint_not_in_set(const uintmax_t value,
7050 const uintmax_t values[],
7051 const size_t number_of_values,
7052 const char *const file,
7053 const int line);
7054void _assert_float_in_set(const double value,
7055 const double values[],
7056 const size_t number_of_values,
7057 const double epsilon,
7058 const char *const file,
7059 const int line);
7060void _assert_float_not_in_set(const double value,
7061 const double values[],
7062 const size_t number_of_values,
7063 const double epsilon,
7064 const char *const file,
7065 const int line);
7066
7067void* _test_malloc(const size_t size, const char* file, const int line);
7068void* _test_realloc(void *ptr, const size_t size, const char* file, const int line);
7069void* _test_calloc(const size_t number_of_elements, const size_t size,
7070 const char* file, const int line);
7071void _test_free(void* const ptr, const char* file, const int line);
7072
7073CMOCKA_NORETURN void _fail(const char * const file, const int line);
7074
7075CMOCKA_NORETURN void _skip(const char * const file, const int line);
7076
7077CMOCKA_NORETURN void _stop(void);
7078
7079/* Test runner */
7080int _cmocka_run_group_tests(const char *group_name,
7081 const struct CMUnitTest * const tests,
7082 const size_t num_tests,
7083 CMFixtureFunction group_setup,
7084 CMFixtureFunction group_teardown);
7085
7087
7088#ifdef __cplusplus
7089} /* extern "C" */
7090#endif
7091
7092#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_ptr_equal(void *a, void *b)
Assert that the two given pointers are equal.
void assert_int_equal(intmax_t a, intmax_t b)
Assert that the two given integers are equal.
void assert_int_in_set(intmax_t value, intmax_t values[], size_t count)
Assert that the specified integer value is within a set.
void assert_not_in_set(uintmax_t value, uintmax_t values[], size_t count)
Assert that the specified value is not within a set.
void assert_int_not_in_set(intmax_t value, intmax_t values[], size_t count)
Assert that the specified value is not within a set.
void assert_string_equal(const char *a, const char *b)
Assert that the two given strings are equal.
void assert_null(void *pointer)
Assert that the given pointer is NULL.
void assert_not_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum)
void assert_float_not_in_range(double value, double minimum, double maximum, double epsilon)
Assert that the specified float value is smaller than the minimum or greater than the maximum.
void assert_memory_not_equal(const void *a, const void *b, size_t size)
Assert that the two given areas of memory are not equal.
void assert_float_not_in_set(double value, double values[], size_t count, double epsilon)
Assert that the specified float value is not within a set.
void assert_ptr_not_equal(void *a, void *b)
Assert that the two given pointers are not equal.
void assert_double_equal(double a, double b, double epsilon)
Assert that the two given double are equal given an epsilon.
void assert_ptr_not_equal_msg(void *a, void *b, const char *const msg)
Assert that the two given pointers are not equal.
void assert_float_in_range(double value, double minimum, double maximum, double epsilon)
Assert that the specified float value is not smaller than the minimum and and not greater than the ma...
void assert_float_in_set(double value, double values[], size_t count, double epsilon)
Assert that the specified float value is within a set.
void assert_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum)
void assert_uint_equal(uintmax_t a, uintmax_t b)
Assert that the two given unsigned integers are equal.
void assert_non_null(void *pointer)
Assert that the given pointer is non-NULL.
void assert_null_msg(void *pointer, const char *const message)
Assert that the given pointer is NULL.
void assert_true(scalar expression)
Assert that the given expression is true.
void assert_ptr_equal_msg(void *a, void *b, const char *const msg)
Assert that the two given pointers are equal.
void assert_false(scalar expression)
Assert that the given expression is false.
void assert_in_set(uintmax_t value, uintmax_t values[], size_t count)
void assert_int_in_range(intmax_t value, intmax_t minimum, intmax_t maximum)
Assert that the specified integer value is not smaller than the minimum and and not greater than the ...
void assert_uint_not_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum)
Assert that the specified value is smaller than the minimum or greater than the maximum.
void assert_int_not_equal(intmax_t a, intmax_t b)
Assert that the two given integers are not equal.
void assert_uint_not_equal(uintmax_t a, uintmax_t b)
Assert that the two given unsigned integers are not equal.
void assert_memory_equal(const void *a, const void *b, size_t size)
Assert that the two given areas of memory are equal, otherwise fail.
void assert_float_equal(float a, float b, float epsilon)
Assert that the two given float are equal given an epsilon.
void assert_double_not_equal(double a, double b, double epsilon)
Assert that the two given double are not equal given an epsilon.
void assert_string_not_equal(const char *a, const char *b)
Assert that the two given strings are not equal.
void assert_int_not_in_range(intmax_t value, intmax_t minimum, intmax_t maximum)
Assert that the specified value is smaller than the minimum or greater than the maximum.
void assert_uint_not_in_set(uintmax_t value, uintmax_t values[], size_t count)
Assert that the specified unsigned integer value is not within a set.
void assert_uint_in_set(uintmax_t value, uintmax_t values[], size_t count)
Assert that the specified unsigned integer value is within a set.
void assert_float_not_equal(float a, float b, float epsilon)
Assert that the two given float are not equal given an epsilon.
void assert_non_null_msg(void *pointer, const char *const message)
Assert that the given pointer is non-NULL.
void assert_uint_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum)
Assert that the specified unsigned integer value is not smaller than the minimum and and not greater ...
void assert_return_code(intmax_t rc, int32_t error)
Assert that the return_code is greater than or equal to 0.
void ignore_function_calls(#function)
Ignores function_called() invocations from given mock function.
void expect_function_call_any(#function)
Expects function_called() from given mock at least once.
void expect_function_call(#function)
Store expected single call to a mock to be checked by function_called() later.
void function_called(void)
Check that current mocked function is being called in the expected order.
void expect_function_calls(#function, const int times)
Store expected call(s) to a mock to be checked by function_called() later.
void cmocka_set_message_output(uint32_t output)
Function to set the output format for a test.
Definition cmocka.c:4795
void cm_print_error(const char *const format,...)
void cmocka_set_callbacks(const struct CMCallbacks *f_callbacks)
Set callback functions for CMocka.
Definition cmocka.c:154
cm_message_output
Output format options for test results.
Definition cmocka.h:6593
void cmocka_set_skip_filter(const char *pattern)
Set a pattern to skip tests matching the pattern.
Definition cmocka.c:4855
void cmocka_set_test_filter(const char *pattern)
Set a pattern to only run the test matching the pattern.
Definition cmocka.c:4838
@ CM_OUTPUT_TAP
Definition cmocka.h:6601
@ CM_OUTPUT_STDOUT
Definition cmocka.h:6597
@ CM_OUTPUT_SUBUNIT
Definition cmocka.h:6599
@ CM_OUTPUT_STANDARD
Definition cmocka.h:6595
@ CM_OUTPUT_XML
Definition cmocka.h:6603
void(*) CMUnitTestFunction(void **state)
Definition cmocka.h:6469
int(*) CMFixtureFunction(void **state)
Definition cmocka.h:6476
int cmocka_run_group_tests(const struct CMUnitTest group_tests[], CMFixtureFunction group_setup, CMFixtureFunction group_teardown)
Run tests specified by an array of CMUnitTest structures.
void fail(void)
Forces the test to fail immediately and quit.
void stop(void)
Forces the test to be stopped immediately.
void(*) UnitTestFunction(void **state)
Definition cmocka.h:6394
UnitTestFunctionType
Definition cmocka.h:6433
void fail_msg(const char *msg,...)
Forces the test to fail immediately and quit, printing the reason.
int cmocka_run_group_tests_name(const char *group_name, const struct CMUnitTest group_tests[], CMFixtureFunction group_setup, CMFixtureFunction group_teardown)
Run tests specified by an array of CMUnitTest structures and specify a name.
void skip(void)
Forces the test to not be executed, but marked as skipped.
void mock_assert(const int result, const char *const expression, const char *const file, const int line)
Function to replace assert(3) in tested code.
Definition cmocka.c:3446
void expect_assert_failure(function fn_call)
Ensure that mock_assert() is called.
void will_return_int(#function, intmax_t value)
Store an integer value to be returned by mock() later.
void will_set_parameter_float_always(#function, #name, float value)
Store a named float value that will always be returned by mock_parameter_float().
uintmax_t mock_parameter(#name)
Retrieve a named value for the current function.
void will_return_float_maybe(#function, float value)
Store a float value that may always be returned by mock_float().
void will_set_parameter_int(#function, #name, intmax_t value)
Store a named integer value to be returned by mock_parameter() later.
intmax_t mock_int()
Retrieve an integer return value of the current function.
void will_return_float_always(#function, float value)
Store a float value that will always be returned by mock_float().
void will_set_parameter_int_count(#function, #name, intmax_t value, int count)
Store a named integer value to be returned a specified number of times by mock_parameter_int() later.
void will_return_double_count(#function, double value, int count)
Store a double precision floating point value to be returned a specified number of times by mock() la...
void will_set_parameter_double_count(#function, #name, double value, int count)
Store a named double value to be returned a specified number of times by mock_parameter_double() late...
void will_set_parameter_uint(#function, #name, uintmax_t value)
Store a named unsigned integer value to be returned by mock_parameter() later.
void will_set_parameter_float_maybe(#function, #name, float value)
Store a named float value that may always be returned by mock_parameter_float().
void * mock_parameter_ptr(#name)
Retrieve a named pointer for the current function.
void will_return_count(#function, uintmax_t value, int count)
void will_set_parameter(#function, #name, uintmax_t value)
Store a named value to be returned by mock_parameter() later.
void will_return_int_maybe(#function, intmax_t value)
Store an integer value that may always be returned by mock_int().
void will_set_parameter_ptr_type(#function, #name, void *value, #type)
Store a named pointer value to be returned by mock_parameter() later.
void will_set_parameter_ptr(#function, #name, void *value)
Store a named pointer value to be returned by mock_parameter() later.
void will_return(#function, uintmax_t value)
Store a value to be returned by mock() later.
void will_return_ptr_type(#function, void *value, type)
Store a pointer value to be returned by mock_ptr_type_checked() later.
void will_return_double_always(#function, double value)
Store a double value that will always be returned by mock_double().
void will_set_errno_always(#function, intmax_t value)
Store an integer value to set errno to by mock_errno() later, for a specified number of times.
type mock_parameter_ptr_type(#name, #type)
Retrieve a named pointer for the current function.
double mock_double(void)
Retrieve a double precision floating point return value of the current function.
void will_return_uint_maybe(#function, uintmax_t value)
Store an unsigned integer value that may always be returned by mock_uint().
void will_set_errno_count(#function, intmax_t value, size_t count)
Store an integer value to always set errno to by mock_errno().
void will_return_uint_always(#function, uintmax_t value)
Store an unsigned integer value that will always be returned by mock_uint().
void will_set_parameter_double_maybe(#function, #name, double value)
Store a named double value that may always be returned by mock_parameter_double().
void will_set_parameter_int_maybe(#function, #name, intmax_t value)
Store a named integer value that may always be returned by mock_parameter_int().
void will_set_errno_maybe(#function, intmax_t value)
Store an integer value to set errno to by mock_errno() later, for a specified number of times.
void will_return_uint_count(#function, uintmax_t value, int count)
Store an unsigned integer value to be returned a specified number of times by mock() later.
void will_return_double_maybe(#function, double value)
Store a double value that may always be returned by mock_double().
uintmax_t mock_uint(void)
Retrieve an unsigned integer return value of the current function.
void will_set_parameter_double(#function, #name, double value)
Store a named double precision floating point value to be returned by mock_parameter() later.
void will_set_parameter_ptr_always(#function, #name, void *value)
Store a named pointer value that will be always returned by mock_parameter_ptr().
void will_return_always(#function, uintmax_t value)
void will_return_ptr(#function, void *value)
Store a pointer value to be returned by mock_ptr_type() later.
void will_return_ptr_always(#function, void *value)
Store a value that will be always returned by mock_ptr_type().
void will_return_int_always(#function, intmax_t value)
Store an integer value that will always be returned by mock_int().
type mock_type(#type)
Retrieve a value of the current function and cast it to given type.
void will_set_parameter_float(#function, #name, float value)
Store a named float value to be returned by mock_parameter() later.
void will_set_parameter_double_always(#function, #name, double value)
Store a named double value that will always be returned by mock_parameter_double().
bool has_mock(void)
Check if data is available for the current mock function.
float mock_parameter_float(#name)
Retrieve a named float value for the current function.
void will_set_parameter_uint_maybe(#function, #name, uintmax_t value)
Store a named unsigned integer value that may always be returned by mock_parameter_uint().
void will_set_parameter_int_always(#function, #name, intmax_t value)
Store a named integer value that will always be returned by mock_parameter_int().
void will_return_maybe(#function, uintmax_t value)
void will_set_parameter_always(#function, #name, uintmax_t value)
void will_set_parameter_count(#function, #name, uintmax_t value, int count)
void will_return_int_count(#function, intmax_t value, int count)
Store an integer value to be returned a specified number of times by mock() later.
void will_set_parameter_float_count(#function, #name, float value, int count)
Store a named float value to be returned a specified number of times by mock_parameter_float() later.
void will_return_ptr_count(#function, void *value, int count)
Store a pointer value to be returned by mock_ptr_type() later.
void will_set_parameter_uint_always(#function, #name, uintmax_t value)
Store a named unsigned integer value that will always be returned by mock_parameter_uint().
void will_set_parameter_maybe(#function, #name, uintmax_t value)
uintmax_t mock_parameter_uint(#name)
Retrieve an unsigned integer return value of the current function.
void will_return_uint(#function, uintmax_t value)
Store a unsigned integer value to be returned by mock() later.
void will_return_float(#function, float value)
Store a float value to be returned by mock() later.
void will_set_errno(#function, intmax_t value)
Store an integer value to set errno to by mock_errno() later.
void will_return_float_count(#function, float value, int count)
Store a float value to be returned a specified number of times by mock() later.
type mock_ptr_type(#type)
Retrieve a typed return value of the current function.
void will_set_parameter_ptr_count(#function, #name, void *value, int count)
Store a named pointer value to be returned a specified number of times by mock_parameter_ptr() later.
float mock_float(void)
Retrieve a float return value of the current function.
uintmax_t mock(void)
Retrieve a return value of the current function.
void mock_errno(void)
set errno for the current function.
intmax_t mock_parameter_int(#name)
Retrieve a named value for the current function and cast it to given type.
void will_return_double(#function, double value)
Store a double precision floating point value to be returned by mock() later.
void will_set_parameter_ptr_maybe(#function, #name, void *value)
Store a named pointer value that may be always returned by mock_parameter_ptr().
void will_return_ptr_maybe(#function, void *value)
Store a value that may be always returned by mock_ptr_type().
void will_set_parameter_uint_count(#function, uintmax_t value, int count)
Store a named unsigned integer value to be returned a specified number of times by mock_parameter_uin...
double mock_parameter_double(#name)
Retrieve a named double precision floating point value for the current function.
type mock_ptr_type_checked(#type)
Retrieve a typed return value of the current function with type checking.
void expect_float_not_in_set(#function, #parameter, double value_array[], double epsilon)
Add an event to check if the float parameter value is not part of the provided array.
void expect_not_in_range_count(#function, #parameter, uintmax_t minimum, uintmax_t maximum, size_t count)
Add an event to repeatedly check a parameter is outside a numerical range. The check would succeed if...
void expect_float_not_in_range_count(#function, #parameter, double minimum, double maximum, double epsilon, size_t count)
Add an event to repeatedly check a parameter is outside a numerical range. The check would succeed if...
void expect_uint_not_in_range_count(#function, uintmax_t minimum, uintmax_t maximum, size_t count)
Add an event to repeatedly check an unsigned integer parameter is outside a numerical range....
int(*) CheckUintParameterValue(const uintmax_t value, const uintmax_t check_value_data)
Definition cmocka.h:6425
void expect_float_not_in_set_count(#function, #parameter, double value_array[], double epsilon, size_t count)
Add an event to check if the float parameter value is not part of the provided integer array.
void expect_uint_not_in_range(#function, uintmax_t minimum, uintmax_t maximum)
Add an event to check an unsigned integer parameter is outside a numerical range. The check would suc...
void expect_any_count(#function, #parameter, size_t count)
Add an event to repeatedly check if a parameter (of any value) has been passed.
void expect_not_string(#function, #parameter, const char *string)
Add an event to check if the parameter value isn't equal to the provided string.
void check_expected_ptr(#parameter)
Determine whether a function parameter is correct.
void expect_in_set_count(#function, #parameter, uintmax_t value_array[], size_t count)
void expect_not_in_set_count(#function, #parameter, uintmax_t value_array[], size_t count)
void check_expected(#parameter)
void expect_not_string_count(#function, #parameter, const char *string, size_t count)
Add an event to check if the parameter value isn't equal to the provided string.
void expect_in_range_count(#function, #parameter, uintmax_t minimum, uintmax_t maximum, size_t count)
void expect_not_memory_count(#function, #parameter, void *memory, size_t size, size_t count)
Add an event to repeatedly check if the parameter doesn't match an area of memory.
void expect_int_in_set_count(#function, #parameter, intmax_t value_array[], size_t count)
Add an event to check if the parameter value is part of the provided integer array.
void expect_check_data(function, parameter, CheckParameterValueData check_function, CMockaValueData check_data)
Add a custom parameter checking function using CMockaValueData (new API).
void expect_in_range(#function, #parameter, uintmax_t minimum, uintmax_t maximum)
void expect_float_in_set_count(#function, #parameter, double value_array[], double epsilon, size_t count)
Add an event to check if the float parameter value is part of the provided integer array.
void expect_float(#function, #parameter, double value, double epsilon)
Add an event to check if a parameter is the given floating point value.
void expect_uint_in_range_count(#function, uintmax_t minimum, uintmax_t maximum, size_t count)
Add an event to repeatedly check an unsigned integer parameter is inside a numerical range....
void check_expected_float(#parameter)
Determine whether a function parameter is correct.
void expect_float_in_range(#function, #parameter, double minimum, double maximum, double epsilon)
Add an event to check a parameter is inside a numerical range. The check would succeed if minimum <= ...
void expect_double(#function, #parameter, double value, double epsilon)
Add an event to check if a parameter is the given double precision floating point value.
void expect_int_not_value_count(#function, intmax_t value, size_t count)
Add an event to repeatedly check if a parameter (int) isn't the given value.
void expect_string(#function, #parameter, const char *string)
Add an event to check if the parameter value is equal to the provided string.
void expect_int_value(#function, #parameter, intmax_t value)
Add an event to check if an integer parameter is the given value.
void expect_int_not_in_set(#function, #parameter, intmax_t value_array[])
Add an event to check if the integer parameter value is not part of the provided integer array.
int(*) CheckParameterValue(const uintmax_t value, const uintmax_t check_value_data)
Definition cmocka.h:6401
void expect_any_always(#function, #parameter)
Add an event to always check if a parameter (of any value) has been passed.
void expect_uint_in_range(#function, uintmax_t minimum, uintmax_t maximum)
Add an event to check an unsigned integer parameter is inside a numerical range. The check would succ...
void expect_not_memory(#function, #parameter, void *memory, size_t size)
Add an event to check if the parameter doesn't match an area of memory.
void expect_memory_count(#function, #parameter, void *memory, size_t size, size_t count)
Add an event to repeatedly check if the parameter does match an area of memory.
void expect_not_in_range(#function, #parameter, uintmax_t minimum, uintmax_t maximum)
Add an event to check a parameter is outside a numerical range. The check would succeed if minimum > ...
void expect_float_in_range_count(#function, #parameter, double minimum, double maximum, double epsilon, size_t count)
Add an event to repeatedly check a parameter is inside a numerical range. The check would succeed if ...
void expect_int_value_count(#function, intmax_t value, size_t count)
Add an event to repeatedly check if an integer parameter is the given value.
void expect_uint_value(#function, #parameter, uintmax_t value)
Add an event to check if an unsigned integer parameter is the given value.
void expect_uint_value_count(#function, uintmax_t value, size_t count)
Add an event to repeatedly check if an unsigned integer parameter is the given value.
void check_expected_int(#parameter)
Determine whether a function parameter is correct.
void expect_int_not_in_range_count(#function, intmax_t minimum, intmax_t maximum, size_t count)
Add an event to repeatedly check an integer parameter is outside a numerical range....
void check_expected_double(#parameter)
Determine whether a function parameter is correct.
void expect_not_value(#function, #parameter, uintmax_t value)
void expect_memory(#function, #parameter, void *memory, size_t size)
Add an event to check if the parameter does match an area of memory.
void expect_int_in_range(#function, intmax_t minimum, intmax_t maximum)
Add an event to check an integer parameter is inside a numerical range. The check would succeed if mi...
void expect_not_float(#function, #parameter, double value, double epsilon)
Add an event to check if a parameter isn't the given floating point value.
void check_expected_uint(#parameter)
Determine whether a function parameter is correct.
void expect_uint_not_value_count(#function, uintmax_t value, size_t count)
Add an event to repeatedly check if a parameter (uint) isn't the given value.
void expect_uint_not_in_set_count(#function, uintmax_t value_array[], size_t count)
Add an event to check if the unsigned integer parameter value is not part of the provided unsigned in...
void expect_check_data_count(function, parameter, CheckParameterValueData check_function, CMockaValueData check_data, size_t count)
Add a custom parameter checking function using CMockaValueData with count (new API).
void expect_any(#function, #parameter)
Add an event to check if a parameter (of any value) has been passed.
void expect_check_count(function, parameter, CheckParameterValue check_function, const void *check_data, size_t count)
void expect_int_in_range_count(#function, intmax_t minimum, intmax_t maximum, size_t count)
Add an event to repeatedly check an integer parameter is inside a numerical range....
void expect_float_in_set(#function, #parameter, double value_array[], double epsilon)
Add an event to check if the float parameter value is part of the provided array.
void expect_not_in_set(#function, #parameter, uintmax_t value_array[])
void expect_float_not_in_range(#function, #parameter, double minimum, double maximum, double epsilon)
Add an event to check a parameter is outside a numerical range. The check would succeed if minimum > ...
void expect_float_count(#function, #parameter, double value, double epsilon, size_t count)
Add an event to repeatedly check if a parameter is the given floating point value.
void check_expected_any(#parameter)
Check that any parameter value matches the next value in the queue.
void expect_value(#function, #parameter, uintmax_t value)
void expect_double_count(#function, double value, double epsilon, size_t count)
Add an event to repeatedly check if a parameter is the given double precision floating point value.
void expect_uint_in_set_count(#function, #parameter, uintmax_t value_array[], size_t count)
Add an event to check if the parameter value is part of the provided unsigned integer array.
int(*) CheckIntParameterValue(const intmax_t value, const intmax_t check_value_data)
Definition cmocka.h:6417
void expect_check(function, parameter, CheckParameterValue check_function, const void *check_data)
void expect_string_count(#function, #parameter, const char *string, size_t count)
Add an event to check if the parameter value is equal to the provided string.
void expect_not_double_count(#function, double value, double epsilon, size_t count)
Add an event to repeatedly check if a parameter isn't the double precision floating point value.
void expect_not_float_count(#function, #parameter, double value, double epsilon, size_t count)
Add an event to repeatedly check if a parameter isn't the floating point value.
void expect_not_double(#function, #parameter, double value, double epsilon)
Add an event to check if a parameter isn't the given double precision floating point value.
void expect_uint_not_value(#function, #parameter, uintmax_t value)
Add an event to check if a parameter (uint) isn't the given value.
void expect_int_not_value(#function, #parameter, intmax_t value)
Add an event to check if a parameter (int) isn't the given value.
void expect_value_count(#function, #parameter, uintmax_t value, size_t count)
void expect_not_value_count(#function, #parameter, uintmax_t value, size_t count)
void expect_in_set(#function, #parameter, uintmax_t value_array[])
int(*) CheckParameterValueData(const CMockaValueData value, const CMockaValueData check_value_data)
Definition cmocka.h:6409
void expect_uint_not_in_set(#function, #parameter, uintmax_t value_array[])
Add an event to check if the unsigned integer parameter value is not part of the provided unsigned in...
void expect_int_not_in_range(#function, intmax_t minimum, intmax_t maximum)
Add an event to check an integer parameter is outside a numerical range. The check would succeed if m...
void expect_int_not_in_set_count(#function, intmax_t value_array[], size_t count)
Add an event to check if the integer parameter value is not part of the provided integer array.
Definition cmocka.h:6549
void(*) vprint_message(const char *const format, va_list args)
Definition cmocka.h:6557
void(*) vprint_error(const char *const format, va_list args)
Definition cmocka.h:6566
Definition cmocka.h:6481
Definition cmocka.h:6516
Definition cmocka.h:6504
Definition cmocka.h:6457
Definition cmocka.h:6494
Definition cmocka.h:6448
Definition cmocka.h:6346
double real_val
Definition cmocka.h:6354
float float_val
Definition cmocka.h:6352
const void * const_ptr
Definition cmocka.h:6358
void * ptr
Definition cmocka.h:6356
intmax_t int_val
Definition cmocka.h:6348
uintmax_t uint_val
Definition cmocka.h:6350