cmocka 2.0.0
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 .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(__GNUC__)
203#define CMOCKA_DEPRECATED __attribute__ ((deprecated))
204#else
205/* MSVC requires __declspec(deprecated) before the function declaration,
206 * not after it. Since we already use CMOCKA_DEPRECATION_WARNING() in
207 * the macro wrappers, we don't need function-level deprecation for MSVC. */
208#define CMOCKA_DEPRECATED
209#endif
210
211/* Deprecation warnings for macros */
212#if defined(__GNUC__) || defined(__clang__)
213/* Use a deprecated typedef in a statement expression to generate warnings
214 * that work even when the header is included as a system header (-isystem).
215 */
216#define CMOCKA_DEPRECATION_WARNING(msg) \
217 __extension__({ \
218 typedef int cmocka_macro __attribute__((deprecated(msg))); \
219 cmocka_macro cmocka_deprecated_var __attribute__((unused)) = 0; \
220 (void)sizeof(cmocka_deprecated_var); \
221 });
222#elif defined(_MSC_VER)
223#define CMOCKA_DEPRECATION_WARNING(msg) __pragma(message("warning: " msg))
224#else
225#define CMOCKA_DEPRECATION_WARNING(msg)
226#endif
227
228#if defined(__GNUC__)
229#define CMOCKA_NORETURN __attribute__ ((noreturn))
230#elif defined(_MSC_VER)
231#define CMOCKA_NORETURN __declspec(noreturn)
232#else
233#define CMOCKA_NORETURN
234#endif
235
236/* Function attribute that tells the compiler that we never access the value
237 * of a/b, just the pointer address.
238 *
239 * Without this, newer compilers like GCC-12 will print
240 * `-Wmaybe-uninitialized` warnings.
241 *
242 * See:
243 * https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Common-Function-Attributes.html#Common-Function-Attributes
244 */
245#ifdef __has_attribute
246#if __has_attribute(access)
247#define CMOCKA_NO_ACCESS_ATTRIBUTE \
248 __attribute__((access(none, 1), access(none, 2)))
249#endif
250#endif
251#ifndef CMOCKA_NO_ACCESS_ATTRIBUTE
252#define CMOCKA_NO_ACCESS_ATTRIBUTE
253#endif
255 /* cmocka_util */
257
309
322#define WILL_RETURN_ALWAYS -1
323
335#define WILL_RETURN_ONCE -2
336
346#define EXPECT_ALWAYS -1
347
357#define EXPECT_MAYBE -2
358
359#ifdef DOXYGEN
367uintmax_t mock(void);
368#else
369#define mock() (_mock(__func__, __FILE__, __LINE__, NULL)).uint_val
370#endif
371
372
373#ifdef DOXYGEN
394type mock_type(#type);
395#else
396#define mock_type(type) ((type) mock())
397#endif
398
399#ifdef DOXYGEN
425bool has_mock(void);
426#else
427#define has_mock() _has_mock(__func__)
428#endif
429
430#ifdef DOXYGEN
444intmax_t mock_int();
445#else
446/* TODO: Enable type safety check by passing intmax_t instead of NULL */
447#define mock_int() (_mock(__func__, __FILE__, __LINE__, NULL)).int_val
448#endif
449
450
451#ifdef DOXYGEN
465uintmax_t mock_uint(void);
466#else
467#define mock_uint() (_mock(__func__, __FILE__, __LINE__, "uintmax_t")).uint_val
468#endif
469
470
471#ifdef DOXYGEN
479float mock_float(void);
480#else
481#define mock_float() (_mock(__func__, __FILE__, __LINE__, NULL)).float_val
482#endif
483
484#ifdef DOXYGEN
493double mock_double(void);
494#else
495#define mock_double() (_mock(__func__, __FILE__, __LINE__, NULL)).real_val
496#endif
497
498#ifdef DOXYGEN
519type mock_ptr_type(#type);
520#else
521#define mock_ptr_type(type) \
522 ((type)(_mock(__func__, __FILE__, __LINE__, NULL)).ptr)
523#endif
524
525#ifdef DOXYGEN
548#else
549#define mock_ptr_type_checked(type) \
550 ((type)(_mock(__func__, __FILE__, __LINE__, #type)).ptr)
551#endif
552
553#ifdef DOXYGEN
587uintmax_t mock_parameter(#name);
588#else
589#define mock_parameter(name) \
590 (_mock_parameter(__func__, #name, __FILE__, __LINE__, NULL)).uint_val
591#endif
592
593#ifdef DOXYGEN
616#type mock_parameter_type(#name, #type);
617#else
618#define mock_parameter_type(name, type) ((type) mock_parameter(#name))
619#endif
620
621#ifdef DOXYGEN
639intmax_t mock_parameter_int(#name);
640#else
641#define mock_parameter_int(name) \
642 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "intmax_t")).int_val
643#endif
644
645#ifdef DOXYGEN
663uintmax_t mock_parameter_uint(#name);
664#else
665#define mock_parameter_uint(name) \
666 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "uintmax_t")).uint_val
667#endif
668
669#ifdef DOXYGEN
688#else
689#define mock_parameter_float(name) \
690 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "float")).float_val
691#endif
692
693#ifdef DOXYGEN
712#else
713#define mock_parameter_double(name) \
714 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "double")).real_val
715#endif
716
717#ifdef DOXYGEN
735#else
736#define mock_parameter_ptr(name) \
737 ((_mock_parameter(__func__, #name, __FILE__, __LINE__, NULL)).ptr)
738#endif
739
740#ifdef DOXYGEN
761type mock_parameter_ptr_type(#name, #type);
762#else
763#define mock_parameter_ptr_type(name, type) \
764 ((type)(_mock_parameter(__func__, #name, __FILE__, __LINE__, #type)).ptr)
765#endif
766
767#ifdef DOXYGEN
775void mock_errno(void);
776#else
777#define mock_errno() \
778 do { \
779 intmax_t err = (_mock_parameter( \
780 __func__, \
781 "/errno", \
782 __FILE__, \
783 __LINE__, \
784 "errno")).int_val; \
785 if (err != 0) { \
786 errno = err; \
787 } \
788 } while (0)
789#endif
790
791#ifdef DOXYGEN
825void will_return(#function, uintmax_t value);
826#else
827#define will_return(function, value) \
828 _will_return(cmocka_tostring(function), \
829 __FILE__, \
830 __LINE__, \
831 NULL, \
832 cast_int_to_cmocka_value(value), \
833 1)
834#endif
835
836#ifdef DOXYGEN
860void will_return_int(#function, intmax_t value);
861#else
862#define will_return_int(function, value) \
863 _will_return(#function, \
864 __FILE__, \
865 __LINE__, \
866 "intmax_t", \
867 assign_int_to_cmocka_value(value), \
868 1)
869#endif
870
871#ifdef DOXYGEN
905void will_return_int_count(#function, intmax_t value, int count);
906#else
907#define will_return_int_count(function, value, count) \
908 _will_return(#function, \
909 __FILE__, \
910 __LINE__, \
911 "intmax_t", \
912 assign_int_to_cmocka_value(value), \
913 count)
914#endif
915
916#ifdef DOXYGEN
941void will_return_uint(#function, uintmax_t value);
942#else
943#define will_return_uint(function, value) \
944 _will_return(#function, \
945 __FILE__, \
946 __LINE__, \
947 "uintmax_t", \
948 assign_uint_to_cmocka_value(value), \
949 1)
950#endif
951
952#ifdef DOXYGEN
986void will_return_uint_count(#function, uintmax_t value, int count);
987#else
988#define will_return_uint_count(function, value, count) \
989 _will_return(#function, \
990 __FILE__, \
991 __LINE__, \
992 "uintmax_t", \
993 assign_uint_to_cmocka_value(value), \
994 count)
995#endif
996
997#ifdef DOXYGEN
1022void will_return_float(#function, float value);
1023#else
1024#define will_return_float(function, value) \
1025 _will_return(#function, \
1026 __FILE__, \
1027 __LINE__, \
1028 "float", \
1029 assign_float_to_cmocka_value(value), \
1030 1)
1031#endif
1032
1033#ifdef DOXYGEN
1067void will_return_float_count(#function, float value, int count);
1068#else
1069#define will_return_float_count(function, value, count) \
1070 _will_return(#function, \
1071 __FILE__, \
1072 __LINE__, \
1073 "float", \
1074 assign_float_to_cmocka_value(value), \
1075 count)
1076#endif
1077
1078#ifdef DOXYGEN
1103void will_return_double(#function, double value);
1104#else
1105#define will_return_double(function, value) \
1106 _will_return(#function, \
1107 __FILE__, \
1108 __LINE__, \
1109 "double", \
1110 assign_double_to_cmocka_value(value), \
1111 1)
1112#endif
1113
1114#ifdef DOXYGEN
1148void will_return_double_count(#function, double value, int count);
1149#else
1150#define will_return_double_count(function, value, count) \
1151 _will_return(#function, \
1152 __FILE__, \
1153 __LINE__, \
1154 "double", \
1155 assign_double_to_cmocka_value(value), \
1156 count)
1157#endif
1158
1159#ifdef DOXYGEN
1175void will_return_int_always(#function, intmax_t value);
1176#else
1177#define will_return_int_always(function, value) \
1178 will_return_int_count(function, (value), WILL_RETURN_ALWAYS)
1179#endif
1180
1181#ifdef DOXYGEN
1198void will_return_uint_always(#function, uintmax_t value);
1199#else
1200#define will_return_uint_always(function, value) \
1201 will_return_uint_count(function, (value), WILL_RETURN_ALWAYS)
1202#endif
1203
1204#ifdef DOXYGEN
1220void will_return_float_always(#function, float value);
1221#else
1222#define will_return_float_always(function, value) \
1223 will_return_float_count(function, (value), WILL_RETURN_ALWAYS)
1224#endif
1225
1226#ifdef DOXYGEN
1242void will_return_double_always(#function, double value);
1243#else
1244#define will_return_double_always(function, value) \
1245 will_return_double_count(function, (value), WILL_RETURN_ALWAYS)
1246#endif
1247
1248#ifdef DOXYGEN
1252void will_return_count(#function, uintmax_t value, int count);
1253#else
1254#define will_return_count(function, value, count) \
1255 do { \
1256 CMOCKA_DEPRECATION_WARNING( \
1257 "will_return_count: use will_return_int_count or " \
1258 "will_return_uint_count instead") \
1259 _will_return(cmocka_tostring(function), \
1260 __FILE__, \
1261 __LINE__, \
1262 NULL, \
1263 cast_int_to_cmocka_value(value), \
1264 count); \
1265 } while (0)
1266#endif
1267
1268#ifdef DOXYGEN
1272void will_return_always(#function, uintmax_t value);
1273#else
1274#define will_return_always(function, value) \
1275 do { \
1276 CMOCKA_DEPRECATION_WARNING( \
1277 "will_return_always: use will_return_int_always or " \
1278 "will_return_uint_always instead") \
1279 will_return_count(function, (value), WILL_RETURN_ALWAYS); \
1280 } while (0)
1281#endif
1282
1283#ifdef DOXYGEN
1305void will_return_int_maybe(#function, intmax_t value);
1306#else
1307#define will_return_int_maybe(function, value) \
1308 will_return_int_count(function, (value), WILL_RETURN_ONCE)
1309#endif
1310
1311#ifdef DOXYGEN
1334void will_return_uint_maybe(#function, uintmax_t value);
1335#else
1336#define will_return_uint_maybe(function, value) \
1337 will_return_uint_count(function, (value), WILL_RETURN_ONCE)
1338#endif
1339
1340#ifdef DOXYGEN
1362void will_return_float_maybe(#function, float value);
1363#else
1364#define will_return_float_maybe(function, value) \
1365 will_return_float_count(function, (value), WILL_RETURN_ONCE)
1366#endif
1367
1368#ifdef DOXYGEN
1390void will_return_double_maybe(#function, double value);
1391#else
1392#define will_return_double_maybe(function, value) \
1393 will_return_double_count(function, (value), WILL_RETURN_ONCE)
1394#endif
1395
1396#ifdef DOXYGEN
1400void will_return_maybe(#function, uintmax_t value);
1401#else
1402#define will_return_maybe(function, value) \
1403 do { \
1404 CMOCKA_DEPRECATION_WARNING( \
1405 "will_return_maybe: use will_return_int_maybe or " \
1406 "will_return_uint_maybe instead") \
1407 will_return_count(function, (value), WILL_RETURN_ONCE); \
1408 } while (0)
1409#endif
1410
1411#ifdef DOXYGEN
1436void will_return_ptr(#function, void *value);
1437#else
1438#define will_return_ptr(function, value) \
1439 _will_return(#function, \
1440 __FILE__, \
1441 __LINE__, \
1442 NULL, \
1443 cast_ptr_to_cmocka_value(value), \
1444 1)
1445#endif
1446
1447#ifdef DOXYGEN
1476void will_return_ptr_type(#function, void *value, type);
1477#else
1478#define will_return_ptr_type(function, value, type) \
1479 _will_return(#function, \
1480 __FILE__, \
1481 __LINE__, \
1482 #type, \
1483 cast_ptr_to_cmocka_value(value), \
1484 1)
1485#endif
1486
1487#ifdef DOXYGEN
1503void will_return_ptr_count(#function, void *value, int count);
1504#else
1505#define will_return_ptr_count(function, value, count) \
1506 _will_return(#function, \
1507 __FILE__, \
1508 __LINE__, \
1509 NULL, \
1510 cast_ptr_to_cmocka_value(value), \
1511 count)
1512#endif
1513
1514#ifdef DOXYGEN
1530void will_return_ptr_always(#function, void *value);
1531#else
1532#define will_return_ptr_always(function, value) \
1533 will_return_ptr_count(function, (value), WILL_RETURN_ALWAYS)
1534#endif
1535
1536#ifdef DOXYGEN
1558void will_return_ptr_maybe(#function, void *value);
1559#else
1560#define will_return_ptr_maybe(function, value) \
1561 will_return_ptr_count(function, (value), WILL_RETURN_ONCE)
1562#endif
1563
1564#ifdef DOXYGEN
1609void will_set_parameter(#function, #name, uintmax_t value);
1610#else
1611#define will_set_parameter(function, name, value) \
1612 _will_set_parameter(cmocka_tostring(function), \
1613 #name, \
1614 __FILE__, \
1615 __LINE__, \
1616 NULL, \
1617 cast_int_to_cmocka_value(value), \
1618 1)
1619#endif
1620
1621#ifdef DOXYGEN
1653void will_set_parameter_int(#function, #name, intmax_t value);
1654#else
1655#define will_set_parameter_int(function, name, value) \
1656 _will_set_parameter(#function, \
1657 #name, \
1658 __FILE__, \
1659 __LINE__, \
1660 "intmax_t", \
1661 assign_int_to_cmocka_value(value), \
1662 1)
1663#endif
1664
1665#ifdef DOXYGEN
1699void will_set_parameter_uint(#function, #name, uintmax_t value);
1700#else
1701#define will_set_parameter_uint(function, name, value) \
1702 _will_set_parameter(#function, \
1703 #name, \
1704 __FILE__, \
1705 __LINE__, \
1706 "uintmax_t", \
1707 assign_uint_to_cmocka_value(value), \
1708 1)
1709#endif
1710
1711#ifdef DOXYGEN
1744void will_set_parameter_float(#function, #name, float value);
1745#else
1746#define will_set_parameter_float(function, name, value) \
1747 _will_set_parameter(#function, \
1748 #name, \
1749 __FILE__, \
1750 __LINE__, \
1751 "float", \
1752 assign_float_to_cmocka_value(value), \
1753 1)
1754#endif
1755
1756#ifdef DOXYGEN
1790void will_set_parameter_double(#function, #name, double value);
1791#else
1792#define will_set_parameter_double(function, name, value) \
1793 _will_set_parameter(#function, \
1794 #name, \
1795 __FILE__, \
1796 __LINE__, \
1797 "double", \
1798 assign_double_to_cmocka_value(value), \
1799 1)
1800#endif
1801
1802#ifdef DOXYGEN
1822void will_set_parameter_int_count(#function, #name, intmax_t value, int count);
1823#else
1824#define will_set_parameter_int_count(function, name, value, count) \
1825 _will_set_parameter(#function, \
1826 #name, \
1827 __FILE__, \
1828 __LINE__, \
1829 "intmax_t", \
1830 assign_int_to_cmocka_value(value), \
1831 count)
1832#endif
1833
1834#ifdef DOXYGEN
1855 #name,
1856 uintmax_t value,
1857 int count);
1858#else
1859#define will_set_parameter_uint_count(function, name, value, count) \
1860 _will_set_parameter(#function, \
1861 #name, \
1862 __FILE__, \
1863 __LINE__, \
1864 "uintmax_t", \
1865 assign_uint_to_cmocka_value(value), \
1866 count)
1867#endif
1868
1869#ifdef DOXYGEN
1889void will_set_parameter_float_count(#function, #name, float value, int count);
1890#else
1891#define will_set_parameter_float_count(function, name, value, count) \
1892 _will_set_parameter(#function, \
1893 #name, \
1894 __FILE__, \
1895 __LINE__, \
1896 "float", \
1897 assign_float_to_cmocka_value(value), \
1898 count)
1899#endif
1900
1901#ifdef DOXYGEN
1921void will_set_parameter_double_count(#function, #name, double value, int count);
1922#else
1923#define will_set_parameter_double_count(function, name, value, count) \
1924 _will_set_parameter(#function, \
1925 #name, \
1926 __FILE__, \
1927 __LINE__, \
1928 "double", \
1929 assign_double_to_cmocka_value(value), \
1930 count)
1931#endif
1932
1933#ifdef DOXYGEN
1938void will_set_parameter_count(#function, #name, uintmax_t value, int count);
1939#else
1940#define will_set_parameter_count(function, name, value, count) \
1941 do { \
1942 CMOCKA_DEPRECATION_WARNING( \
1943 "will_set_parameter_count: use will_set_parameter_int_count or " \
1944 "will_set_parameter_uint_count instead") \
1945 _will_set_parameter(cmocka_tostring(function), \
1946 #name, \
1947 __FILE__, \
1948 __LINE__, \
1949 NULL, \
1950 cast_int_to_cmocka_value(value), \
1951 count); \
1952 } while (0)
1953#endif
1954
1955#ifdef DOXYGEN
1975void will_set_parameter_int_always(#function, #name, intmax_t value);
1976#else
1977#define will_set_parameter_int_always(function, name, value) \
1978 will_set_parameter_int_count(function, name, (value), WILL_RETURN_ALWAYS)
1979#endif
1980
1981#ifdef DOXYGEN
2001void will_set_parameter_uint_always(#function, #name, uintmax_t value);
2002#else
2003#define will_set_parameter_uint_always(function, name, value) \
2004 will_set_parameter_uint_count(function, name, (value), WILL_RETURN_ALWAYS)
2005#endif
2006
2007#ifdef DOXYGEN
2027void will_set_parameter_float_always(#function, #name, float value);
2028#else
2029#define will_set_parameter_float_always(function, name, value) \
2030 will_set_parameter_float_count(function, name, (value), WILL_RETURN_ALWAYS)
2031#endif
2032
2033#ifdef DOXYGEN
2053void will_set_parameter_double_always(#function, #name, double value);
2054#else
2055#define will_set_parameter_double_always(function, name, value) \
2056 will_set_parameter_double_count(function, name, (value), WILL_RETURN_ALWAYS)
2057#endif
2058
2059#ifdef DOXYGEN
2064void will_set_parameter_always(#function, #name, uintmax_t value);
2065#else
2066#define will_set_parameter_always(function, name, value) \
2067 do { \
2068 CMOCKA_DEPRECATION_WARNING( \
2069 "will_set_parameter_always: use will_set_parameter_int_always or " \
2070 "will_set_parameter_uint_always instead") \
2071 will_set_parameter_count(function, name, (value), WILL_RETURN_ALWAYS); \
2072 } while (0)
2073#endif
2074
2075#ifdef DOXYGEN
2096void will_set_parameter_int_maybe(#function, #name, intmax_t value);
2097#else
2098#define will_set_parameter_int_maybe(function, name, value) \
2099 will_set_parameter_int_count(function, name, (value), WILL_RETURN_ONCE)
2100#endif
2101
2102#ifdef DOXYGEN
2123void will_set_parameter_uint_maybe(#function, #name, uintmax_t value);
2124#else
2125#define will_set_parameter_uint_maybe(function, name, value) \
2126 will_set_parameter_uint_count(function, name, (value), WILL_RETURN_ONCE)
2127#endif
2128
2129#ifdef DOXYGEN
2150void will_set_parameter_float_maybe(#function, #name, float value);
2151#else
2152#define will_set_parameter_float_maybe(function, name, value) \
2153 will_set_parameter_float_count(function, name, (value), WILL_RETURN_ONCE)
2154#endif
2155
2156#ifdef DOXYGEN
2177void will_set_parameter_double_maybe(#function, #name, double value);
2178#else
2179#define will_set_parameter_double_maybe(function, name, value) \
2180 will_set_parameter_double_count(function, name, (value), WILL_RETURN_ONCE)
2181#endif
2182
2183#ifdef DOXYGEN
2188void will_set_parameter_maybe(#function, #name, uintmax_t value);
2189#else
2190#define will_set_parameter_maybe(function, name, value) \
2191 do { \
2192 CMOCKA_DEPRECATION_WARNING( \
2193 "will_set_parameter_maybe: use will_set_parameter_int_maybe or " \
2194 "will_set_parameter_uint_maybe instead") \
2195 will_set_parameter_count(function, name, (value), WILL_RETURN_ONCE); \
2196 } while (0)
2197#endif
2198
2199#ifdef DOXYGEN
2228void will_set_parameter_ptr(#function, #name, void *value);
2229#else
2230#define will_set_parameter_ptr(function, name, value) \
2231 _will_set_parameter(#function, \
2232 #name, \
2233 __FILE__, \
2234 __LINE__, \
2235 NULL, \
2236 cast_ptr_to_cmocka_value(value), \
2237 1)
2238#endif
2239
2240#ifdef DOXYGEN
2274void will_set_parameter_ptr_type(#function, #name, void *value, #type);
2275#else
2276#define will_set_parameter_ptr_type(function, name, value, type) \
2277 _will_set_parameter(#function, \
2278 #name, \
2279 __FILE__, \
2280 __LINE__, \
2281 #type, \
2282 cast_ptr_to_cmocka_value(value), \
2283 1)
2284#endif
2285
2286#ifdef DOXYGEN
2325void will_set_parameter_ptr_count(#function, #name, void *value, int count);
2326#else
2327#define will_set_parameter_ptr_count(function, name, value, count) \
2328 _will_set_parameter(#function, \
2329 #name, \
2330 __FILE__, \
2331 __LINE__, \
2332 NULL, \
2333 cast_ptr_to_cmocka_value(value), \
2334 count)
2335#endif
2336
2337#ifdef DOXYGEN
2364void will_set_parameter_ptr_always(#function, #name, void *value);
2365#else
2366#define will_set_parameter_ptr_always(function, name, value) \
2367 will_set_parameter_ptr_count(function, name, (value), WILL_RETURN_ALWAYS)
2368#endif
2369
2370#ifdef DOXYGEN
2399void will_set_parameter_ptr_maybe(#function, #name, void *value);
2400#else
2401#define will_set_parameter_ptr_maybe(function, name, value) \
2402 will_set_parameter_ptr_count(function, name, (value), WILL_RETURN_ONCE)
2403#endif
2404
2405#ifdef DOXYGEN
2430void will_set_errno(#function, intmax_t value);
2431#else
2432#define will_set_errno(function, value) \
2433 _will_set_parameter(#function, \
2434 "/errno", \
2435 __FILE__, \
2436 __LINE__, \
2437 "errno", \
2438 assign_int_to_cmocka_value(value), \
2439 1)
2440#endif
2441
2442#ifdef DOXYGEN
2481void will_set_errno_count(#function, intmax_t value, size_t count);
2482#else
2483#define will_set_errno_count(function, value, count) \
2484 _will_set_parameter(#function, \
2485 "/errno", \
2486 __FILE__, \
2487 __LINE__, \
2488 "errno", \
2489 assign_int_to_cmocka_value(value), \
2490 (count))
2491#endif
2492
2493#ifdef DOXYGEN
2516void will_set_errno_always(#function, intmax_t value);
2517#else
2518#define will_set_errno_always(function, value) \
2519 will_set_errno_count(function, (value), WILL_RETURN_ALWAYS);
2520#endif
2521
2522#ifdef DOXYGEN
2545void will_set_errno_maybe(#function, intmax_t value);
2546#else
2547#define will_set_errno_maybe(function, value) \
2548 will_set_errno_count(function, (value), WILL_RETURN_ONCE);
2549#endif
2550 /* cmocka_mock */
2552
2597
2598
2599#ifdef DOXYGEN
2603void expect_check(function,
2604 parameter,
2605 CheckParameterValue check_function,
2606 const void *check_data);
2607#else
2608#define expect_check(function, parameter, check_function, check_data) \
2609 do { \
2610 CMOCKA_DEPRECATION_WARNING( \
2611 "expect_check: use expect_check_data instead") \
2612 _expect_check(cmocka_tostring(function), \
2613 cmocka_tostring(parameter), \
2614 __FILE__, \
2615 __LINE__, \
2616 check_function, \
2617 cast_to_uintmax_type(check_data), \
2618 NULL, \
2619 1); \
2620 } while (0)
2621#endif
2622
2623
2624#ifdef DOXYGEN
2629 parameter,
2630 CheckParameterValue check_function,
2631 const void *check_data,
2632 size_t count);
2633#else
2634#define expect_check_count( \
2635 function, parameter, check_function, check_data, count) \
2636 do { \
2637 CMOCKA_DEPRECATION_WARNING( \
2638 "expect_check_count: use expect_check_data_count instead") \
2639 _expect_check(cmocka_tostring(function), \
2640 cmocka_tostring(parameter), \
2641 __FILE__, \
2642 __LINE__, \
2643 check_function, \
2644 cast_to_uintmax_type(check_data), \
2645 NULL, \
2646 count); \
2647 } while (0)
2648#endif
2649
2650#ifdef DOXYGEN
2806void expect_check_data(function,
2807 parameter,
2808 CheckParameterValueData check_function,
2809 CMockaValueData check_data);
2810#else
2811#define expect_check_data(function, parameter, check_function, check_data) \
2812 _expect_check_data(cmocka_tostring(function), \
2813 cmocka_tostring(parameter), \
2814 __FILE__, \
2815 __LINE__, \
2816 check_function, \
2817 check_data, \
2818 NULL, \
2819 1)
2820#endif
2821
2822#ifdef DOXYGEN
2888 parameter,
2889 CheckParameterValueData check_function,
2890 CMockaValueData check_data,
2891 size_t count);
2892#else
2893#define expect_check_data_count(function, \
2894 parameter, \
2895 check_function, \
2896 check_data, \
2897 count) \
2898 _expect_check_data(cmocka_tostring(function), \
2899 cmocka_tostring(parameter), \
2900 __FILE__, \
2901 __LINE__, \
2902 check_function, \
2903 check_data, \
2904 NULL, \
2905 count)
2906#endif
2907
2908#ifdef DOXYGEN
2912void expect_in_set(#function, #parameter, uintmax_t value_array[]);
2913#else
2914#define expect_in_set(function, parameter, value_array) \
2915 do { \
2916 CMOCKA_DEPRECATION_WARNING("expect_in_set: use expect_int_in_set or " \
2917 "expect_uint_in_set instead") \
2918 expect_in_set_count(function, parameter, value_array, 1); \
2919 } while (0)
2920#endif
2921
2922#ifdef DOXYGEN
2937void expect_in_set(#function, #parameter, intmax_t value_array[]);
2938#else
2939#define expect_int_in_set(function, parameter, value_array) \
2940 expect_int_in_set_count(function, parameter, value_array, 1)
2941#endif
2942
2943#ifdef DOXYGEN
2958void expect_in_set(#function, #parameter, intmax_t value_array[]);
2959#else
2960#define expect_uint_in_set(function, parameter, value_array) \
2961 expect_uint_in_set_count(function, parameter, value_array, 1)
2962#endif
2963
2964#ifdef DOXYGEN
2968void expect_in_set_count(#function, #parameter, uintmax_t value_array[], size_t count);
2969#else
2970#define expect_in_set_count(function, parameter, value_array, count) \
2971 do { \
2972 CMOCKA_DEPRECATION_WARNING( \
2973 "expect_in_set_count: use expect_int_in_set_count or " \
2974 "expect_uint_in_set_count instead") \
2975 _expect_uint_in_set(cmocka_tostring(function), \
2976 cmocka_tostring(parameter), \
2977 __FILE__, \
2978 __LINE__, \
2979 value_array, \
2980 sizeof(value_array) / sizeof((value_array)[0]), \
2981 count); \
2982 } while (0)
2983#endif
2984
2985#ifdef DOXYGEN
3004void expect_int_in_set_count(#function, #parameter, intmax_t value_array[], size_t count);
3005#else
3006#define expect_int_in_set_count(function, parameter, value_array, count) \
3007 _expect_int_in_set(cmocka_tostring(function), \
3008 cmocka_tostring(parameter), \
3009 __FILE__, \
3010 __LINE__, \
3011 value_array, \
3012 sizeof(value_array) / sizeof((value_array)[0]), \
3013 count)
3014#endif
3015
3016#ifdef DOXYGEN
3035void expect_uint_in_set_count(#function, #parameter, uintmax_t value_array[], size_t count);
3036#else
3037#define expect_uint_in_set_count(function, parameter, value_array, count) \
3038 _expect_uint_in_set(cmocka_tostring(function), \
3039 cmocka_tostring(parameter), \
3040 __FILE__, \
3041 __LINE__, \
3042 value_array, \
3043 sizeof(value_array) / sizeof((value_array)[0]), \
3044 count)
3045#endif
3046
3047#ifdef DOXYGEN
3051void expect_not_in_set(#function, #parameter, uintmax_t value_array[]);
3052#else
3053#define expect_not_in_set(function, parameter, value_array) \
3054 do { \
3055 CMOCKA_DEPRECATION_WARNING( \
3056 "expect_not_in_set: use expect_int_not_in_set or " \
3057 "expect_uint_not_in_set instead") \
3058 expect_not_in_set_count(function, parameter, value_array, 1); \
3059 } while (0)
3060#endif
3061
3062#ifdef DOXYGEN
3066void expect_not_in_set_count(#function, #parameter, uintmax_t value_array[], size_t count);
3067#else
3068#define expect_not_in_set_count(function, parameter, value_array, count) \
3069 do { \
3070 CMOCKA_DEPRECATION_WARNING( \
3071 "expect_not_in_set_count: use expect_int_not_in_set_count or " \
3072 "expect_uint_not_in_set_count instead") \
3073 _expect_not_in_set(cmocka_tostring(function), \
3074 cmocka_tostring(parameter), \
3075 __FILE__, \
3076 __LINE__, \
3077 value_array, \
3078 sizeof(value_array) / sizeof((value_array)[0]), \
3079 count); \
3080 } while (0)
3081#endif
3082
3083#ifdef DOXYGEN
3098void expect_int_not_in_set(#function, #parameter, intmax_t value_array[]);
3099#else
3100#define expect_int_not_in_set(function, parameter, value_array) \
3101 expect_int_not_in_set_count(function, parameter, value_array, 1)
3102#endif
3103
3104#ifdef DOXYGEN
3124 #parameter,
3125 intmax_t value_array[],
3126 size_t count);
3127#else
3128#define expect_int_not_in_set_count(function, parameter, value_array, count) \
3129 _expect_int_not_in_set(cmocka_tostring(function), \
3130 cmocka_tostring(parameter), \
3131 __FILE__, \
3132 __LINE__, \
3133 value_array, \
3134 sizeof(value_array) / sizeof((value_array)[0]), \
3135 count)
3136#endif
3137
3138#ifdef DOXYGEN
3153void expect_uint_not_in_set(#function, #parameter, uintmax_t value_array[]);
3154#else
3155#define expect_uint_not_in_set(function, parameter, value_array) \
3156 expect_uint_not_in_set_count(function, parameter, value_array, 1)
3157#endif
3158
3159#ifdef DOXYGEN
3179 #parameter,
3180 uintmax_t value_array[],
3181 size_t count);
3182#else
3183#define expect_uint_not_in_set_count(function, parameter, value_array, count) \
3184 _expect_uint_not_in_set(cmocka_tostring(function), \
3185 cmocka_tostring(parameter), \
3186 __FILE__, \
3187 __LINE__, \
3188 value_array, \
3189 sizeof(value_array) / sizeof((value_array)[0]), \
3190 count)
3191#endif
3192
3193#ifdef DOXYGEN
3210void expect_float_in_set(#function, #parameter, double value_array[], double epsilon);
3211#else
3212#define expect_float_in_set(function, parameter, value_array, epsilon) \
3213 expect_float_in_set_count(function, parameter, value_array, epsilon, 1)
3214#endif
3215
3216#ifdef DOXYGEN
3237void expect_float_in_set_count(#function, #parameter, double value_array[], double epsilon, size_t count);
3238#else
3239#define expect_float_in_set_count(function, parameter, value_array, epsilon, count) \
3240 _expect_float_in_set(cmocka_tostring(function), \
3241 cmocka_tostring(parameter), \
3242 __FILE__, \
3243 __LINE__, \
3244 value_array, \
3245 sizeof(value_array) / sizeof((value_array)[0]), \
3246 epsilon, \
3247 count)
3248#endif
3249
3250#ifdef DOXYGEN
3267void expect_float_not_in_set(#function, #parameter, double value_array[], double epsilon);
3268#else
3269#define expect_float_not_in_set(function, parameter, value_array, epsilon) \
3270 expect_float_not_in_set_count(function, parameter, value_array, epsilon, 1)
3271#endif
3272
3273#ifdef DOXYGEN
3294void expect_float_not_in_set_count(#function, #parameter, double value_array[], double epsilon, size_t count);
3295#else
3296#define expect_float_not_in_set_count(function, parameter, value_array, epsilon, count) \
3297 _expect_float_not_in_set(cmocka_tostring(function), \
3298 cmocka_tostring(parameter), \
3299 __FILE__, \
3300 __LINE__, \
3301 value_array, \
3302 sizeof(value_array) / sizeof((value_array)[0]), \
3303 epsilon, \
3304 count)
3305#endif
3306
3307
3308#ifdef DOXYGEN
3312void expect_in_range(#function, #parameter, uintmax_t minimum, uintmax_t maximum);
3313#else
3314#define expect_in_range(function, parameter, minimum, maximum) \
3315 do { \
3316 CMOCKA_DEPRECATION_WARNING( \
3317 "expect_in_range: use expect_int_in_range or " \
3318 "expect_uint_in_range instead") \
3319 expect_in_range_count(function, parameter, minimum, maximum, 1); \
3320 } while (0)
3321#endif
3322
3323#ifdef DOXYGEN
3327void expect_in_range_count(#function, #parameter, uintmax_t minimum, uintmax_t maximum, size_t count);
3328#else
3329#define expect_in_range_count(function, parameter, minimum, maximum, count) \
3330 do { \
3331 CMOCKA_DEPRECATION_WARNING( \
3332 "expect_in_range_count: use expect_int_in_range_count or " \
3333 "expect_uint_in_range_count instead") \
3334 _expect_in_range(cmocka_tostring(function), \
3335 cmocka_tostring(parameter), \
3336 __FILE__, \
3337 __LINE__, \
3338 minimum, \
3339 maximum, \
3340 count); \
3341 } while (0)
3342#endif
3343
3344#ifdef DOXYGEN
3361void expect_int_in_range(#function,
3362#parameter,
3363 intmax_t minimum,
3364 intmax_t maximum);
3365#else
3366#define expect_int_in_range(function, parameter, minimum, maximum) \
3367 expect_int_in_range_count(function, parameter, minimum, maximum, 1)
3368#endif
3369
3370#ifdef DOXYGEN
3392#parameter,
3393 intmax_t minimum,
3394 intmax_t maximum,
3395 size_t count);
3396#else
3397#define expect_int_in_range_count( \
3398 function, parameter, minimum, maximum, count) \
3399 _expect_int_in_range(cmocka_tostring(function), \
3400 cmocka_tostring(parameter), \
3401 __FILE__, \
3402 __LINE__, \
3403 minimum, \
3404 maximum, \
3405 count)
3406#endif
3407
3408#ifdef DOXYGEN
3426#parameter,
3427 uintmax_t minimum,
3428 uintmax_t maximum);
3429#else
3430#define expect_uint_in_range(function, parameter, minimum, maximum) \
3431 expect_uint_in_range_count(function, parameter, minimum, maximum, 1)
3432#endif
3433
3434#ifdef DOXYGEN
3457#parameter,
3458 uintmax_t minimum,
3459 uintmax_t maximum,
3460 size_t count);
3461#else
3462#define expect_uint_in_range_count( \
3463 function, parameter, minimum, maximum, count) \
3464 _expect_uint_in_range(cmocka_tostring(function), \
3465 cmocka_tostring(parameter), \
3466 __FILE__, \
3467 __LINE__, \
3468 minimum, \
3469 maximum, \
3470 count)
3471#endif
3472
3473#ifdef DOXYGEN
3490void expect_not_in_range(#function, #parameter, uintmax_t minimum, uintmax_t maximum);
3491#else
3492#define expect_not_in_range(function, parameter, minimum, maximum) \
3493 expect_not_in_range_count(function, parameter, minimum, maximum, 1)
3494#endif
3495
3496#ifdef DOXYGEN
3517void expect_not_in_range_count(#function, #parameter, uintmax_t minimum, uintmax_t maximum, size_t count);
3518#else
3519#define expect_not_in_range_count(function, parameter, minimum, maximum, \
3520 count) \
3521 _expect_not_in_range(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
3522 minimum, maximum, count)
3523#endif
3524
3525#ifdef DOXYGEN
3543 #parameter,
3544 intmax_t minimum,
3545 intmax_t maximum);
3546#else
3547#define expect_int_not_in_range(function, parameter, minimum, maximum) \
3548 expect_int_not_in_range_count(function, parameter, minimum, maximum, 1)
3549#endif
3550
3551#ifdef DOXYGEN
3573 #parameter,
3574 intmax_t minimum,
3575 intmax_t maximum,
3576 size_t count);
3577#else
3578#define expect_int_not_in_range_count( \
3579 function, parameter, minimum, maximum, count) \
3580 _expect_int_not_in_range(cmocka_tostring(function), \
3581 cmocka_tostring(parameter), \
3582 __FILE__, \
3583 __LINE__, \
3584 minimum, \
3585 maximum, \
3586 count)
3587#endif
3588
3589#ifdef DOXYGEN
3607 #parameter,
3608 uintmax_t minimum,
3609 uintmax_t maximum);
3610#else
3611#define expect_uint_not_in_range(function, parameter, minimum, maximum) \
3612 expect_uint_not_in_range_count(function, parameter, minimum, maximum, 1)
3613#endif
3614
3615#ifdef DOXYGEN
3638 #parameter,
3639 uintmax_t minimum,
3640 uintmax_t maximum,
3641 size_t count);
3642#else
3643#define expect_uint_not_in_range_count( \
3644 function, parameter, minimum, maximum, count) \
3645 _expect_uint_not_in_range(cmocka_tostring(function), \
3646 cmocka_tostring(parameter), \
3647 __FILE__, \
3648 __LINE__, \
3649 minimum, \
3650 maximum, \
3651 count)
3652#endif
3653
3654#ifdef DOXYGEN
3673void expect_float_in_range(#function, #parameter, double minimum, double maximum, double epsilon);
3674#else
3675#define expect_float_in_range(function, parameter, minimum, maximum, epsilon) \
3676 expect_float_in_range_count(function, parameter, minimum, maximum, epsilon, 1)
3677#endif
3678
3679#ifdef DOXYGEN
3702void expect_float_in_range_count(#function, #parameter, double minimum, double maximum, double epsilon, size_t count);
3703#else
3704#define expect_float_in_range_count(function, parameter, minimum, maximum, epsilon, count) \
3705 _expect_float_in_range(cmocka_tostring(function), \
3706 cmocka_tostring(parameter), \
3707 __FILE__, \
3708 __LINE__, \
3709 cast_to_double_type(minimum), \
3710 cast_to_double_type(maximum), \
3711 cast_to_double_type(epsilon), \
3712 count)
3713#endif
3714
3715#ifdef DOXYGEN
3734void expect_float_not_in_range(#function, #parameter, double minimum, double maximum, double epsilon);
3735#else
3736#define expect_float_not_in_range(function, parameter, minimum, maximum, epsilon) \
3737 expect_float_not_in_range_count(function, parameter, minimum, maximum, epsilon, 1)
3738#endif
3739
3740#ifdef DOXYGEN
3763void expect_float_not_in_range_count(#function, #parameter, double minimum, double maximum, double epsilon, size_t count);
3764#else
3765#define expect_float_not_in_range_count(function, parameter, minimum, maximum, \
3766 epsilon, count) \
3767 _expect_float_not_in_range(cmocka_tostring(function), \
3768 cmocka_tostring(parameter), \
3769 __FILE__, \
3770 __LINE__, \
3771 cast_to_double_type(minimum), \
3772 cast_to_double_type(maximum), \
3773 cast_to_double_type(epsilon), \
3774 count)
3775#endif
3776
3777#ifdef DOXYGEN
3781void expect_value(#function, #parameter, uintmax_t value);
3782#else
3783#define expect_value(function, parameter, value) \
3784 do { \
3785 CMOCKA_DEPRECATION_WARNING("expect_value: use expect_int_value or " \
3786 "expect_uint_value instead") \
3787 expect_value_count(function, parameter, value, 1); \
3788 } while (0)
3789#endif
3790
3791#ifdef DOXYGEN
3795void expect_value_count(#function, #parameter, uintmax_t value, size_t count);
3796#else
3797#define expect_value_count(function, parameter, value, count) \
3798 do { \
3799 CMOCKA_DEPRECATION_WARNING( \
3800 "expect_value_count: use expect_int_value_count or " \
3801 "expect_uint_value_count instead") \
3802 _expect_value(cmocka_tostring(function), \
3803 cmocka_tostring(parameter), \
3804 __FILE__, \
3805 __LINE__, \
3806 cast_to_uintmax_type(value), \
3807 count); \
3808 } while (0)
3809#endif
3810
3811#ifdef DOXYGEN
3825void expect_int_value(#function, #parameter, intmax_t value);
3826#else
3827#define expect_int_value(function, parameter, value) \
3828 expect_int_value_count(function, parameter, value, 1)
3829#endif
3830
3831#ifdef DOXYGEN
3851#parameter,
3852 intmax_t value,
3853 size_t count);
3854#else
3855#define expect_int_value_count(function, parameter, value, count) \
3856 _expect_int_value(cmocka_tostring(function), \
3857 cmocka_tostring(parameter), \
3858 __FILE__, \
3859 __LINE__, \
3860 value, \
3861 count)
3862#endif
3863
3864#ifdef DOXYGEN
3879void expect_uint_value(#function, #parameter, uintmax_t value);
3880#else
3881#define expect_uint_value(function, parameter, value) \
3882 expect_uint_value_count(function, parameter, value, 1)
3883#endif
3884
3885#ifdef DOXYGEN
3905#parameter,
3906 uintmax_t value,
3907 size_t count);
3908#else
3909#define expect_uint_value_count(function, parameter, value, count) \
3910 _expect_uint_value(cmocka_tostring(function), \
3911 cmocka_tostring(parameter), \
3912 __FILE__, \
3913 __LINE__, \
3914 value, \
3915 count)
3916#endif
3917
3918#ifdef DOXYGEN
3932void expect_int_not_value(#function, #parameter, intmax_t value);
3933#else
3934#define expect_int_not_value(function, parameter, value) \
3935 expect_int_not_value_count(function, parameter, value, 1)
3936#endif
3937
3938#ifdef DOXYGEN
3958 #parameter,
3959 intmax_t value,
3960 size_t count);
3961#else
3962#define expect_int_not_value_count(function, parameter, value, count) \
3963 _expect_int_not_value(cmocka_tostring(function), \
3964 cmocka_tostring(parameter), \
3965 __FILE__, \
3966 __LINE__, \
3967 value, \
3968 count)
3969#endif
3970
3971#ifdef DOXYGEN
3985void expect_uint_not_value(#function, #parameter, uintmax_t value);
3986#else
3987#define expect_uint_not_value(function, parameter, value) \
3988 expect_uint_not_value_count(function, parameter, value, 1)
3989#endif
3990
3991#ifdef DOXYGEN
4011 #parameter,
4012 uintmax_t value,
4013 size_t count);
4014#else
4015#define expect_uint_not_value_count(function, parameter, value, count) \
4016 _expect_uint_not_value(cmocka_tostring(function), \
4017 cmocka_tostring(parameter), \
4018 __FILE__, \
4019 __LINE__, \
4020 value, \
4021 count)
4022#endif
4023
4024#ifdef DOXYGEN
4028void expect_not_value(#function, #parameter, uintmax_t value);
4029#else
4030#define expect_not_value(function, parameter, value) \
4031 do { \
4032 CMOCKA_DEPRECATION_WARNING( \
4033 "expect_not_value: use expect_int_not_value or " \
4034 "expect_uint_not_value instead") \
4035 expect_not_value_count(function, parameter, value, 1); \
4036 } while (0)
4037#endif
4038
4039#ifdef DOXYGEN
4043void expect_not_value_count(#function, #parameter, uintmax_t value, size_t count);
4044#else
4045#define expect_not_value_count(function, parameter, value, count) \
4046 do { \
4047 CMOCKA_DEPRECATION_WARNING( \
4048 "expect_not_value_count: use expect_int_not_value_count or " \
4049 "expect_uint_not_value_count instead") \
4050 _expect_not_value(cmocka_tostring(function), \
4051 cmocka_tostring(parameter), \
4052 __FILE__, \
4053 __LINE__, \
4054 cast_to_uintmax_type(value), \
4055 count); \
4056 } while (0)
4057#endif
4058
4059#ifdef DOXYGEN
4078void expect_float(#function, #parameter, double value, double epsilon);
4079#else
4080#define expect_float(function, parameter, value, epsilon) \
4081 expect_float_count(function, parameter, cast_to_double_type(value), \
4082 cast_to_double_type(epsilon), 1)
4083#endif
4084
4085#ifdef DOXYGEN
4108void expect_float_count(#function, #parameter, double value, double epsilon, size_t count);
4109#else
4110#define expect_float_count(function, parameter, value, epsilon, count) \
4111 _expect_float(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4112 cast_to_double_type(value), cast_to_double_type(epsilon), count)
4113#endif
4114
4115#ifdef DOXYGEN
4135void expect_not_float(#function, #parameter, double value, double epsilon);
4136#else
4137#define expect_not_float(function, parameter, value, epsilon) \
4138 expect_not_float_count(function, \
4139 parameter, \
4140 cast_to_float_type(value), \
4141 cast_to_float_type(epsilon), \
4142 1)
4143#endif
4144
4145#ifdef DOXYGEN
4168void expect_not_float_count(#function, #parameter, double value, double epsilon, size_t count);
4169#else
4170#define expect_not_float_count(function, parameter, value, epsilon, count) \
4171 _expect_not_float(cmocka_tostring(function), \
4172 cmocka_tostring(parameter), \
4173 __FILE__, \
4174 __LINE__, \
4175 cast_to_float_type(value), \
4176 cast_to_float_type(epsilon), \
4177 count)
4178#endif
4179
4180#ifdef DOXYGEN
4198void expect_double(#function, #parameter, double value, double epsilon);
4199#else
4200#define expect_double(function, parameter, value, epsilon) \
4201 expect_double_count(function, \
4202 parameter, \
4203 cast_to_double_type(value), \
4204 cast_to_double_type(epsilon), \
4205 1)
4206#endif
4207
4208#ifdef DOXYGEN
4230void expect_double_count(#function,
4231 #parameter,
4232 double value,
4233 double epsilon,
4234 size_t count);
4235#else
4236#define expect_double_count(function, parameter, value, epsilon, count) \
4237 _expect_double(cmocka_tostring(function), \
4238 cmocka_tostring(parameter), \
4239 __FILE__, \
4240 __LINE__, \
4241 cast_to_double_type(value), \
4242 cast_to_double_type(epsilon), \
4243 count)
4244#endif
4245
4246#ifdef DOXYGEN
4264void expect_not_double(#function, #parameter, double value, double epsilon);
4265#else
4266#define expect_not_double(function, parameter, value, epsilon) \
4267 expect_not_double_count(function, \
4268 parameter, \
4269 cast_to_double_type(value), \
4270 cast_to_double_type(epsilon), \
4271 1)
4272#endif
4273
4274#ifdef DOXYGEN
4297 #parameter,
4298 double value,
4299 double epsilon,
4300 size_t count);
4301#else
4302#define expect_not_double_count(function, parameter, value, epsilon, count) \
4303 _expect_not_double(cmocka_tostring(function), \
4304 cmocka_tostring(parameter), \
4305 __FILE__, \
4306 __LINE__, \
4307 cast_to_double_type(value), \
4308 cast_to_double_type(epsilon), \
4309 count)
4310#endif
4311
4312#ifdef DOXYGEN
4327void expect_string(#function, #parameter, const char *string);
4328#else
4329#define expect_string(function, parameter, string) \
4330 expect_string_count(function, parameter, string, 1)
4331#endif
4332
4333#ifdef DOXYGEN
4352void expect_string_count(#function, #parameter, const char *string, size_t count);
4353#else
4354#define expect_string_count(function, parameter, string, count) \
4355 _expect_string(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4356 (const char*)(string), count)
4357#endif
4358
4359#ifdef DOXYGEN
4374void expect_not_string(#function, #parameter, const char *string);
4375#else
4376#define expect_not_string(function, parameter, string) \
4377 expect_not_string_count(function, parameter, string, 1)
4378#endif
4379
4380#ifdef DOXYGEN
4399void expect_not_string_count(#function, #parameter, const char *string, size_t count);
4400#else
4401#define expect_not_string_count(function, parameter, string, count) \
4402 _expect_not_string(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4403 (const char*)(string), count)
4404#endif
4405
4406#ifdef DOXYGEN
4422void expect_memory(#function, #parameter, void *memory, size_t size);
4423#else
4424#define expect_memory(function, parameter, memory, size) \
4425 expect_memory_count(function, parameter, memory, size, 1)
4426#endif
4427
4428#ifdef DOXYGEN
4449void expect_memory_count(#function, #parameter, void *memory, size_t size, size_t count);
4450#else
4451#define expect_memory_count(function, parameter, memory, size, count) \
4452 _expect_memory(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4453 (const void*)(memory), size, count)
4454#endif
4455
4456#ifdef DOXYGEN
4473void expect_not_memory(#function, #parameter, void *memory, size_t size);
4474#else
4475#define expect_not_memory(function, parameter, memory, size) \
4476 expect_not_memory_count(function, parameter, memory, size, 1)
4477#endif
4478
4479#ifdef DOXYGEN
4500void expect_not_memory_count(#function, #parameter, void *memory, size_t size, size_t count);
4501#else
4502#define expect_not_memory_count(function, parameter, memory, size, count) \
4503 _expect_not_memory(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, \
4504 (const void*)(memory), size, count)
4505#endif
4506
4507
4508#ifdef DOXYGEN
4520void expect_any(#function, #parameter);
4521#else
4522#define expect_any(function, parameter) \
4523 expect_any_count(function, parameter, 1)
4524#endif
4525
4526#ifdef DOXYGEN
4538void expect_any_always(#function, #parameter);
4539#else
4540#define expect_any_always(function, parameter) \
4541 expect_any_count(function, parameter, WILL_RETURN_ALWAYS)
4542#endif
4543
4544#ifdef DOXYGEN
4561void expect_any_count(#function, #parameter, size_t count);
4562#else
4563#define expect_any_count(function, parameter, count) \
4564 _expect_any(cmocka_tostring(function), cmocka_tostring(parameter), __FILE__, __LINE__, count)
4565#endif
4566
4567#ifdef DOXYGEN
4572void check_expected(#parameter);
4573#else
4574#define check_expected(parameter) \
4575 do { \
4576 CMOCKA_DEPRECATION_WARNING( \
4577 "check_expected: use check_expected_int or " \
4578 "check_expected_uint instead") \
4579 _check_expected(__func__, \
4580 #parameter, \
4581 __FILE__, \
4582 __LINE__, \
4583 cast_int_to_cmocka_value(parameter)); \
4584 } while (0)
4585#endif
4586
4587#ifdef DOXYGEN
4615void check_expected_any(#parameter);
4616#else
4617#define check_expected_any(parameter) \
4618 _check_expected(__func__, #parameter, __FILE__, __LINE__, \
4619 cast_ptr_to_cmocka_value(&(parameter)))
4620#endif
4621
4622#ifdef DOXYGEN
4633void check_expected_ptr(#parameter);
4634#else
4635#define check_expected_ptr(parameter) \
4636 _check_expected(__func__, #parameter, __FILE__, __LINE__, \
4637 cast_ptr_to_cmocka_value(parameter))
4638#endif
4639
4640#ifdef DOXYGEN
4651void check_expected_int(#parameter);
4652#else
4653#define check_expected_int(parameter) \
4654 _check_expected(__func__, \
4655 #parameter, \
4656 __FILE__, \
4657 __LINE__, \
4658 assign_int_to_cmocka_value(parameter))
4659#endif
4660
4661#ifdef DOXYGEN
4672void check_expected_uint(#parameter);
4673#else
4674#define check_expected_uint(parameter) \
4675 _check_expected(__func__, \
4676 #parameter, \
4677 __FILE__, \
4678 __LINE__, \
4679 assign_uint_to_cmocka_value(parameter))
4680#endif
4681
4682#ifdef DOXYGEN
4698void check_expected_float(#parameter);
4699#else
4700#define check_expected_float(parameter) \
4701 _check_expected(__func__, \
4702 #parameter, \
4703 __FILE__, \
4704 __LINE__, \
4705 assign_float_to_cmocka_value(parameter))
4706#endif
4707
4708#ifdef DOXYGEN
4724void check_expected_double(#parameter);
4725#else
4726#define check_expected_double(parameter) \
4727 _check_expected(__func__, \
4728 #parameter, \
4729 __FILE__, \
4730 __LINE__, \
4731 assign_double_to_cmocka_value(parameter))
4732#endif
4733 /* cmocka_param */
4735
4758
4759#ifdef DOXYGEN
4772void assert_true(scalar expression);
4773#else
4774#define assert_true(c) _assert_true(cast_to_uintmax_type(c), #c, \
4775 __FILE__, __LINE__)
4776#endif
4777
4778#ifdef DOXYGEN
4790void assert_false(scalar expression);
4791#else
4792#define assert_false(c) _assert_false(cast_to_uintmax_type(c), #c, \
4793 __FILE__, __LINE__)
4794#endif
4795
4796#ifdef DOXYGEN
4809void assert_return_code(intmax_t rc, int32_t error);
4810#else
4811#define assert_return_code(rc, error) \
4812 _assert_return_code((rc), \
4813 (error), \
4814 #rc, __FILE__, __LINE__)
4815#endif
4816
4817#ifdef DOXYGEN
4828void assert_non_null(void *pointer);
4829#else
4830#define assert_non_null(c) assert_ptr_not_equal((c), NULL)
4831#endif
4832
4833#ifdef DOXYGEN
4846void assert_non_null_msg(void *pointer, const char *const message);
4847#else
4848#define assert_non_null_msg(c, msg) assert_ptr_not_equal_msg((c), NULL, (msg))
4849#endif
4850
4851#ifdef DOXYGEN
4862void assert_null(void *pointer);
4863#else
4864#define assert_null(c) assert_ptr_equal((c), NULL)
4865#endif
4866
4867#ifdef DOXYGEN
4880void assert_null_msg(void *pointer, const char *const message);
4881#else
4882#define assert_null_msg(c, msg) assert_ptr_equal_msg((c), NULL, (msg))
4883#endif
4884
4885#ifdef DOXYGEN
4896void assert_ptr_equal(void *a, void *b);
4897#else
4898#define assert_ptr_equal(a, b) assert_ptr_equal_msg((a), (b), NULL)
4899#endif
4900
4901#ifdef DOXYGEN
4914void assert_ptr_equal_msg(void *a, void *b, const char *const msg);
4915#else
4916#define assert_ptr_equal_msg(a, b, msg) \
4917 _assert_ptr_equal_msg(cast_to_void_pointer(a), \
4918 cast_to_void_pointer(b), \
4919 __FILE__, __LINE__, (msg))
4920#endif
4921
4922#ifdef DOXYGEN
4933void assert_ptr_not_equal(void *a, void *b);
4934#else
4935#define assert_ptr_not_equal(a, b) \
4936 assert_ptr_not_equal_msg((a), (b), NULL)
4937#endif
4938
4939#ifdef DOXYGEN
4952void assert_ptr_not_equal_msg(void *a, void *b, const char *const msg);
4953#else /* DOXYGEN */
4954
4955#if defined(__has_builtin)
4956
4957#if __has_builtin(__builtin_unreachable)
4958#define assert_ptr_not_equal_msg(a, b, msg) \
4959 do { \
4960 const void *cmocka_p1 = cast_to_void_pointer(a), \
4961 *cmocka_p2 = cast_to_void_pointer(b); \
4962 _assert_ptr_not_equal_msg( \
4963 cmocka_p1, cmocka_p2, __FILE__, __LINE__, (msg)); \
4964 if (cmocka_p1 == cmocka_p2) { \
4965 __builtin_unreachable(); \
4966 } \
4967 } while (0)
4968#else /* __has_builtin(__builtin_unreachable) */
4969#define assert_ptr_not_equal_msg(a, b, msg) \
4970_assert_ptr_not_equal_msg(cast_to_void_pointer(a), \
4971 cast_to_void_pointer(b), \
4972 __FILE__, \
4973 __LINE__, \
4974 (msg))
4975#endif /* __has_builtin(__builtin_unreachable) */
4976
4977#else /* defined(__has_builtin) */
4978#define assert_ptr_not_equal_msg(a, b, msg) \
4979_assert_ptr_not_equal_msg(cast_to_void_pointer(a), \
4980 cast_to_void_pointer(b), \
4981 __FILE__, \
4982 __LINE__, \
4983 (msg))
4984#endif /* __has_builtin(__builtin_unreachable) */
4985
4986#endif /* DOXYGEN */
4987
4988#ifdef DOXYGEN
4999void assert_int_equal(intmax_t a, intmax_t b);
5000#else
5001#define assert_int_equal(a, b) \
5002 _assert_int_equal(cast_to_intmax_type(a), \
5003 cast_to_intmax_type(b), \
5004 __FILE__, __LINE__)
5005#endif
5006
5007#ifdef DOXYGEN
5018void assert_uint_equal(uintmax_t a, uintmax_t b);
5019#else
5020#define assert_uint_equal(a, b) \
5021 _assert_uint_equal(cast_to_uintmax_type(a), \
5022 cast_to_uintmax_type(b), \
5023 __FILE__, __LINE__)
5024#endif
5025
5026#ifdef DOXYGEN
5039void assert_int_not_equal(intmax_t a, intmax_t b);
5040#else
5041#define assert_int_not_equal(a, b) \
5042 _assert_int_not_equal(cast_to_intmax_type(a), \
5043 cast_to_intmax_type(b), \
5044 __FILE__, __LINE__)
5045#endif
5046
5047#ifdef DOXYGEN
5058void assert_uint_not_equal(uintmax_t a, uintmax_t b);
5059#else
5060#define assert_uint_not_equal(a, b) \
5061 _assert_uint_not_equal(cast_to_uintmax_type(a), \
5062 cast_to_uintmax_type(b), \
5063 __FILE__, __LINE__)
5064#endif
5065
5066#ifdef DOXYGEN
5079void assert_float_equal(float a, float b, float epsilon);
5080#else
5081#define assert_float_equal(a, b, epsilon) \
5082 _assert_float_equal((float)a, \
5083 (float)b, \
5084 (float)epsilon, \
5085 __FILE__, __LINE__)
5086#endif
5087
5088#ifdef DOXYGEN
5101void assert_float_not_equal(float a, float b, float epsilon);
5102#else
5103#define assert_float_not_equal(a, b, epsilon) \
5104 _assert_float_not_equal((float)a, \
5105 (float)b, \
5106 (float)epsilon, \
5107 __FILE__, __LINE__)
5108#endif
5109
5110#ifdef DOXYGEN
5123void assert_double_equal(double a, double b, double epsilon);
5124#else
5125#define assert_double_equal(a, b, epsilon) \
5126 _assert_double_equal((double)a, \
5127 (double)b, \
5128 (double)epsilon, \
5129 __FILE__, __LINE__)
5130#endif
5131
5132#ifdef DOXYGEN
5145void assert_double_not_equal(double a, double b, double epsilon);
5146#else
5147#define assert_double_not_equal(a, b, epsilon) \
5148 _assert_double_not_equal((double)a, \
5149 (double)b, \
5150 (double)epsilon, \
5151 __FILE__, __LINE__)
5152#endif
5153
5154
5155#ifdef DOXYGEN
5166void assert_string_equal(const char *a, const char *b);
5167#else
5168#define assert_string_equal(a, b) \
5169 _assert_string_equal((a), (b), __FILE__, __LINE__)
5170#endif
5171
5172#ifdef DOXYGEN
5183void assert_string_not_equal(const char *a, const char *b);
5184#else
5185#define assert_string_not_equal(a, b) \
5186 _assert_string_not_equal((a), (b), __FILE__, __LINE__)
5187#endif
5188
5189#ifdef DOXYGEN
5204void assert_memory_equal(const void *a, const void *b, size_t size);
5205#else
5206#define assert_memory_equal(a, b, size) \
5207 _assert_memory_equal((const void*)(a), (const void*)(b), size, __FILE__, \
5208 __LINE__)
5209#endif
5210
5211#ifdef DOXYGEN
5226void assert_memory_not_equal(const void *a, const void *b, size_t size);
5227#else
5228#define assert_memory_not_equal(a, b, size) \
5229 _assert_memory_not_equal((const void*)(a), (const void*)(b), size, \
5230 __FILE__, __LINE__)
5231#endif
5232
5233#ifdef DOXYGEN
5247void assert_int_in_range(intmax_t value, intmax_t minimum, intmax_t maximum);
5248#else
5249#define assert_int_in_range(value, minimum, maximum) \
5250 _assert_int_in_range( \
5251 cast_to_intmax_type(value), \
5252 cast_to_intmax_type(minimum), \
5253 cast_to_intmax_type(maximum), __FILE__, __LINE__)
5254#endif
5255
5256#ifdef DOXYGEN
5270void assert_uint_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum);
5271#else
5272#define assert_uint_in_range(value, minimum, maximum) \
5273 _assert_uint_in_range( \
5274 cast_to_intmax_type(value), \
5275 cast_to_intmax_type(minimum), \
5276 cast_to_intmax_type(maximum), __FILE__, __LINE__)
5277#endif
5278
5279#ifdef DOXYGEN
5296void assert_int_not_in_range(intmax_t value,
5297 intmax_t minimum,
5298 intmax_t maximum);
5299#else
5300#define assert_int_not_in_range(value, minimum, maximum) \
5301 _assert_int_not_in_range(cast_to_intmax_type(value), \
5302 cast_to_intmax_type(minimum), \
5303 cast_to_intmax_type(maximum), \
5304 __FILE__, \
5305 __LINE__)
5306#endif
5307
5308#ifdef DOXYGEN
5325void assert_uint_not_in_range(uintmax_t value,
5326 uintmax_t minimum,
5327 uintmax_t maximum);
5328#else
5329#define assert_uint_not_in_range(value, minimum, maximum) \
5330 _assert_uint_not_in_range(cast_to_uintmax_type(value), \
5331 cast_to_uintmax_type(minimum), \
5332 cast_to_uintmax_type(maximum), \
5333 __FILE__, \
5334 __LINE__)
5335#endif
5336
5337#ifdef DOXYGEN
5341void assert_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum);
5342#else
5343#define assert_in_range(value, minimum, maximum) \
5344 do { \
5345 CMOCKA_DEPRECATION_WARNING( \
5346 "assert_in_range: use assert_int_in_range or " \
5347 "assert_uint_in_range instead") \
5348 _assert_uint_in_range(cast_to_uintmax_type(value), \
5349 cast_to_uintmax_type(minimum), \
5350 cast_to_uintmax_type(maximum), \
5351 __FILE__, \
5352 __LINE__); \
5353 } while (0)
5354#endif
5355
5356#ifdef DOXYGEN
5360void assert_not_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum);
5361#else
5362#define assert_not_in_range(value, minimum, maximum) \
5363 do { \
5364 CMOCKA_DEPRECATION_WARNING( \
5365 "assert_not_in_range: use assert_int_not_in_range or " \
5366 "assert_uint_not_in_range instead") \
5367 _assert_uint_not_in_range(cast_to_uintmax_type(value), \
5368 cast_to_uintmax_type(minimum), \
5369 cast_to_uintmax_type(maximum), \
5370 __FILE__, \
5371 __LINE__); \
5372 } while (0)
5373#endif
5374
5375#ifdef DOXYGEN
5394void assert_float_not_in_range(double value, double minimum, double maximum, double epsilon);
5395#else
5396#define assert_float_not_in_range(value, minimum, maximum, epsilon) \
5397 _assert_float_not_in_range(cast_to_double_type(value), \
5398 cast_to_double_type(minimum), \
5399 cast_to_double_type(maximum), \
5400 cast_to_double_type(epsilon), \
5401 __FILE__, \
5402 __LINE__)
5403#endif
5404
5405#ifdef DOXYGEN
5421void assert_float_in_range(double value, double minimum, double maximum, double epsilon);
5422#else
5423#define assert_float_in_range(value, minimum, maximum, epsilon) \
5424 _assert_float_in_range( \
5425 cast_to_double_type(value), \
5426 cast_to_double_type(minimum), \
5427 cast_to_double_type(maximum), \
5428 cast_to_double_type(epsilon), __FILE__, __LINE__)
5429#endif
5430
5431#ifdef DOXYGEN
5435void assert_in_set(uintmax_t value, uintmax_t values[], size_t count);
5436#else
5437#define assert_in_set(value, values, number_of_values) \
5438 do { \
5439 CMOCKA_DEPRECATION_WARNING("assert_in_set: use assert_int_in_set or " \
5440 "assert_uint_in_set instead") \
5441 _assert_uint_in_set( \
5442 value, values, number_of_values, __FILE__, __LINE__); \
5443 } while (0)
5444#endif
5445
5446#ifdef DOXYGEN
5459void assert_not_in_set(uintmax_t value, uintmax_t values[], size_t count);
5460#else
5461#define assert_not_in_set(value, values, number_of_values) \
5462 _assert_not_in_set(value, values, number_of_values, __FILE__, __LINE__)
5463#endif
5464
5465#ifdef DOXYGEN
5478void assert_int_in_set(intmax_t value, intmax_t values[], size_t count);
5479#else
5480#define assert_int_in_set(value, values, number_of_values) \
5481 if (number_of_values > 0) { \
5482 intmax_t _cmocka_set[number_of_values]; \
5483 for (size_t _i = 0; _i < number_of_values; _i++) { \
5484 _cmocka_set[_i] = values[_i]; \
5485 } \
5486 _assert_int_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5487 }
5488#endif
5489
5490#ifdef DOXYGEN
5503void assert_int_not_in_set(intmax_t value, intmax_t values[], size_t count);
5504#else
5505#define assert_int_not_in_set(value, values, number_of_values) \
5506 if (number_of_values > 0) { \
5507 intmax_t _cmocka_set[number_of_values]; \
5508 for (size_t _i = 0; _i < number_of_values; _i++) { \
5509 _cmocka_set[_i] = values[_i]; \
5510 } \
5511 _assert_int_not_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5512 }
5513#endif
5514
5515#ifdef DOXYGEN
5528void assert_uint_in_set(uintmax_t value, uintmax_t values[], size_t count);
5529#else
5530#define assert_uint_in_set(value, values, number_of_values) \
5531 if (number_of_values > 0) { \
5532 uintmax_t _cmocka_set[number_of_values]; \
5533 for (size_t _i = 0; _i < number_of_values; _i++) { \
5534 _cmocka_set[_i] = values[_i]; \
5535 } \
5536 _assert_uint_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5537 }
5538#endif
5539
5540#ifdef DOXYGEN
5553void assert_uint_not_in_set(uintmax_t value, uintmax_t values[], size_t count);
5554#else
5555#define assert_uint_not_in_set(value, values, number_of_values) \
5556 if (number_of_values > 0) { \
5557 uintmax_t _cmocka_set[number_of_values]; \
5558 for (size_t _i = 0; _i < number_of_values; _i++) { \
5559 _cmocka_set[_i] = values[_i]; \
5560 } \
5561 _assert_uint_not_in_set(value, _cmocka_set, number_of_values, __FILE__, __LINE__); \
5562 }
5563#endif
5564
5565#ifdef DOXYGEN
5580void assert_float_in_set(double value, double values[], size_t count, double epsilon);
5581#else
5582#define assert_float_in_set(value, values, number_of_values, epsilon) \
5583 if (number_of_values > 0) { \
5584 double _cmocka_set[number_of_values]; \
5585 for (size_t _i = 0; _i < number_of_values; _i++) { \
5586 _cmocka_set[_i] = values[_i]; \
5587 } \
5588 _assert_float_in_set(value, _cmocka_set, number_of_values, epsilon, __FILE__, __LINE__); \
5589 }
5590#endif
5591
5592#ifdef DOXYGEN
5607void assert_float_not_in_set(double value, double values[], size_t count, double epsilon);
5608#else
5609#define assert_float_not_in_set(value, values, number_of_values, epsilon) \
5610 if (number_of_values > 0) { \
5611 double _cmocka_set[number_of_values]; \
5612 for (size_t _i = 0; _i < number_of_values; _i++) { \
5613 _cmocka_set[_i] = values[_i]; \
5614 } \
5615 _assert_float_not_in_set(value, _cmocka_set, number_of_values, epsilon, __FILE__, __LINE__); \
5616 }
5617#endif
5618 /* cmocka_asserts */
5620
5684
5685#ifdef DOXYGEN
5693#else
5694#define function_called() _function_called(__func__, __FILE__, __LINE__)
5695#endif
5696
5697#ifdef DOXYGEN
5708void expect_function_calls(#function, const int times);
5709#else
5710#define expect_function_calls(function, times) \
5711 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, times)
5712#endif
5713
5714#ifdef DOXYGEN
5723void expect_function_call(#function);
5724#else
5725#define expect_function_call(function) \
5726 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, 1)
5727#endif
5728
5729#ifdef DOXYGEN
5738#else
5739#define expect_function_call_any(function) \
5740 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, -1)
5741#endif
5742
5743#ifdef DOXYGEN
5752#else
5753#define ignore_function_calls(function) \
5754 _expect_function_call(cmocka_tostring(function), __FILE__, __LINE__, -2)
5755#endif
5756 /* cmocka_call_order */
5758
5790
5791#ifdef DOXYGEN
5795void fail(void);
5796#else
5797#define fail() _fail(__FILE__, __LINE__)
5798#endif
5799
5800#ifdef DOXYGEN
5804void skip(void);
5805#else
5806#define skip() _skip(__FILE__, __LINE__)
5807#endif
5808
5809#ifdef DOXYGEN
5818void stop(void);
5819#else
5820#define stop() _stop()
5821#endif
5822
5823#ifdef DOXYGEN
5838void fail_msg(const char *msg, ...);
5839#else
5840#define fail_msg(msg, ...) do { \
5841 cmocka_print_error("ERROR: " msg "\n", ##__VA_ARGS__); \
5842 fail(); \
5843} while (0)
5844#endif
5845
5846static inline void _unit_test_dummy(void **state) {
5847 (void)state;
5848}
5849
5854#define unit_test(f) \
5855 (CMOCKA_DEPRECATION_WARNING("unit_test: use cmocka_unit_test instead")( \
5856 UnitTest){#f, f, UNIT_TEST_FUNCTION_TYPE_TEST})
5857
5859#define _unit_test_setup(test, setup) \
5860 { #test "_" #setup, setup, UNIT_TEST_FUNCTION_TYPE_SETUP }
5862
5867#define unit_test_setup(test, setup) \
5868 CMOCKA_DEPRECATION_WARNING( \
5869 "unit_test_setup: use cmocka_unit_test_setup instead") \
5870 _unit_test_setup(test, setup), unit_test(test), \
5871 _unit_test_teardown(test, _unit_test_dummy)
5872
5874#define _unit_test_teardown(test, teardown) \
5875 { #test "_" #teardown, teardown, UNIT_TEST_FUNCTION_TYPE_TEARDOWN }
5877
5882#define unit_test_teardown(test, teardown) \
5883 CMOCKA_DEPRECATION_WARNING( \
5884 "unit_test_teardown: use cmocka_unit_test_teardown instead") \
5885 _unit_test_setup(test, _unit_test_dummy), unit_test(test), \
5886 _unit_test_teardown(test, teardown)
5887
5892#define group_test_setup(setup) \
5893 (CMOCKA_DEPRECATION_WARNING( \
5894 "group_test_setup: use cmocka_run_group_tests instead")(UnitTest){ \
5895 "group_" #setup, setup, UNIT_TEST_FUNCTION_TYPE_GROUP_SETUP})
5896
5901#define group_test_teardown(teardown) \
5902 (CMOCKA_DEPRECATION_WARNING( \
5903 "group_test_teardown: use cmocka_run_group_tests instead")(UnitTest){ \
5904 "group_" #teardown, teardown, UNIT_TEST_FUNCTION_TYPE_GROUP_TEARDOWN})
5905
5913#define unit_test_setup_teardown(test, setup, teardown) \
5914 CMOCKA_DEPRECATION_WARNING("unit_test_setup_teardown: use " \
5915 "cmocka_unit_test_setup_teardown instead") \
5916 _unit_test_setup(test, setup), unit_test(test), \
5917 _unit_test_teardown(test, teardown)
5918
5920#define cmocka_unit_test(f) { #f, f, NULL, NULL, NULL }
5921
5923#define cmocka_unit_test_setup(f, setup) { #f, f, setup, NULL, NULL }
5924
5926#define cmocka_unit_test_teardown(f, teardown) { #f, f, NULL, teardown, NULL }
5927
5932#define cmocka_unit_test_setup_teardown(f, setup, teardown) { #f, f, setup, teardown, NULL }
5933
5941#define cmocka_unit_test_prestate(f, state) { #f, f, NULL, NULL, state }
5942
5950#define cmocka_unit_test_prestate_setup_teardown(f, setup, teardown, state) { #f, f, setup, teardown, state }
5951
5952#ifdef DOXYGEN
6009int cmocka_run_group_tests(const struct CMUnitTest group_tests[],
6010 CMFixtureFunction group_setup,
6011 CMFixtureFunction group_teardown);
6012#else
6013# define cmocka_run_group_tests(group_tests, group_setup, group_teardown) \
6014 _cmocka_run_group_tests(#group_tests, group_tests, sizeof(group_tests) / sizeof((group_tests)[0]), group_setup, group_teardown)
6015#endif
6016
6017#ifdef DOXYGEN
6077int cmocka_run_group_tests_name(const char *group_name,
6078 const struct CMUnitTest group_tests[],
6079 CMFixtureFunction group_setup,
6080 CMFixtureFunction group_teardown);
6081#else
6082# define cmocka_run_group_tests_name(group_name, group_tests, group_setup, group_teardown) \
6083 _cmocka_run_group_tests(group_name, group_tests, sizeof(group_tests) / sizeof((group_tests)[0]), group_setup, group_teardown)
6084#endif
6085 /* cmocka_exec */
6087
6147
6148#ifdef DOXYGEN
6171void *test_malloc(size_t size);
6172#else
6173#define test_malloc(size) _test_malloc(size, __FILE__, __LINE__)
6174#endif
6175
6176#ifdef DOXYGEN
6190void *test_calloc(size_t nmemb, size_t size);
6191#else
6192#define test_calloc(num, size) _test_calloc(num, size, __FILE__, __LINE__)
6193#endif
6194
6195#ifdef DOXYGEN
6206void *test_realloc(void *ptr, size_t size);
6207#else
6208#define test_realloc(ptr, size) _test_realloc(ptr, size, __FILE__, __LINE__)
6209#endif
6210
6211#ifdef DOXYGEN
6219void test_free(void *ptr);
6220#else
6221#define test_free(ptr) _test_free(ptr, __FILE__, __LINE__)
6222#endif
6223
6224#if defined(UNIT_TESTING) && defined(ALLOCATION_TESTING)
6225#define malloc test_malloc
6226#define realloc test_realloc
6227#define calloc test_calloc
6228#define free test_free
6229#endif /* UNIT_TESTING && ALLOCATION_TESTING */
6230 /* cmocka_alloc */
6232
6250
6284void mock_assert(const int result, const char* const expression,
6285 const char * const file, const int line);
6286
6287#ifdef DOXYGEN
6310void expect_assert_failure(function fn_call);
6311#else
6312#define expect_assert_failure(function_call) \
6313 { \
6314 global_expecting_assert = 1; \
6315 if (setjmp(global_expect_assert_env) != 0) { \
6316 print_message("Expected assertion %s occurred\n", \
6317 global_last_failed_assert); \
6318 global_expecting_assert = 0; \
6319 } else { \
6320 function_call ; \
6321 global_expecting_assert = 0; \
6322 print_error("Expected assert in %s\n", #function_call); \
6323 _fail(__FILE__, __LINE__); \
6324 } \
6325 }
6326#endif
6327 /* cmocka_mock_assert */
6329
6338typedef union {
6340 intmax_t int_val;
6342 uintmax_t uint_val;
6346 double real_val; // TODO: Should we use `long double` instead
6348 const void *ptr;
6349 // The following aren't used by CMocka currently, but are added to avoid
6350 // breaking ABI compatibility in the future
6352 void *(*func)(void);
6354
6355#ifndef DOXYGEN
6360#define LargestIntegralType uintmax_t
6361
6365#if defined(__GNUC__)
6366#define cast_ptr_to_largest_integral_type(value) \
6367 __extension__({ \
6368 CMOCKA_DEPRECATION_WARNING( \
6369 "cast_ptr_to_largest_integral_type: " \
6370 "use cast_ptr_to_uintmax_type instead"); \
6371 cast_ptr_to_uintmax_type(value); \
6372 })
6373#else
6374#define cast_ptr_to_largest_integral_type(value) \
6375 cast_ptr_to_uintmax_type(value)
6376#endif
6377#endif
6378
6384typedef void (*UnitTestFunction)(void **state);
6385
6391typedef int (*CheckParameterValue)(const uintmax_t value,
6392 const uintmax_t check_value_data);
6393
6399typedef int (*CheckParameterValueData)(const CMockaValueData value,
6400 const CMockaValueData check_value_data);
6401
6407typedef int (*CheckIntParameterValue)(const intmax_t value,
6408 const intmax_t check_value_data);
6409
6415typedef int (*CheckUintParameterValue)(const uintmax_t value,
6416 const uintmax_t check_value_data);
6417
6424 UNIT_TEST_FUNCTION_TYPE_TEST = 0,
6425 UNIT_TEST_FUNCTION_TYPE_SETUP,
6426 UNIT_TEST_FUNCTION_TYPE_TEARDOWN,
6427 UNIT_TEST_FUNCTION_TYPE_GROUP_SETUP,
6428 UNIT_TEST_FUNCTION_TYPE_GROUP_TEARDOWN,
6430
6438typedef struct UnitTest {
6439 const char* name;
6440 UnitTestFunction function;
6441 UnitTestFunctionType function_type;
6443
6447typedef struct GroupTest {
6448 UnitTestFunction setup;
6449 UnitTestFunction teardown;
6450 const UnitTest *tests;
6451 const size_t number_of_tests;
6452} GroupTest;
6453
6459typedef void (*CMUnitTestFunction)(void **state);
6460
6466typedef int (*CMFixtureFunction)(void **state);
6467
6472 const char *name;
6473 CMUnitTestFunction test_func;
6474 CMFixtureFunction setup_func;
6475 CMFixtureFunction teardown_func;
6476 void *initial_state;
6477};
6478
6484typedef struct SourceLocation {
6485 const char* file;
6486 int line;
6488
6494typedef struct CheckParameterEvent {
6495 SourceLocation location;
6496 const char *parameter_name;
6497 CheckParameterValue check_value;
6498 uintmax_t check_value_data;
6500
6507 SourceLocation location;
6508 const char *parameter_name;
6509 CheckParameterValueData check_value;
6510 CMockaValueData check_value_data;
6512
6526
6527/* Standard output and error print methods. */
6528void print_message(const char* const format, ...) CMOCKA_PRINTF_ATTRIBUTE(1, 2);
6529void print_error(const char* const format, ...) CMOCKA_PRINTF_ATTRIBUTE(1, 2);
6530void vprint_message(const char* const format, va_list args) CMOCKA_PRINTF_ATTRIBUTE(1, 0);
6531void vprint_error(const char* const format, va_list args) CMOCKA_PRINTF_ATTRIBUTE(1, 0);
6532
6547 void (*vprint_message)(const char * const format, va_list args);
6548
6556 void (*vprint_error)(const char * const format, va_list args);
6557};
6558
6573void cmocka_set_callbacks(const struct CMCallbacks *f_callbacks);
6574
6587 CM_OUTPUT_STDOUT = 0x00000001,
6589 CM_OUTPUT_SUBUNIT = 0x00000002,
6591 CM_OUTPUT_TAP = 0x00000004,
6593 CM_OUTPUT_XML = 0x00000008,
6594};
6595
6596#ifdef DOXYGEN
6600void cm_print_error(const char* const format, ...);
6601#else
6602#define cm_print_error(format, ...) \
6603 do { \
6604 CMOCKA_DEPRECATION_WARNING( \
6605 "cm_print_error: use cmocka_print_error instead") \
6606 cmocka_print_error(format, ##__VA_ARGS__); \
6607 } while (0)
6608#endif
6609
6622void cmocka_print_error(const char* const format, ...) CMOCKA_PRINTF_ATTRIBUTE(1, 2);
6623
6640void cmocka_set_message_output(uint32_t output);
6641
6642
6658void cmocka_set_test_filter(const char *pattern);
6659
6675void cmocka_set_skip_filter(const char *pattern);
6676 /* cmocka_config */
6678
6688
6689/* Used by expect_assert_failure() and mock_assert(). */
6690CMOCKA_DLLEXTERN extern int global_expecting_assert;
6691CMOCKA_DLLEXTERN extern jmp_buf global_expect_assert_env;
6692CMOCKA_DLLEXTERN extern const char * global_last_failed_assert;
6693
6694/* Retrieves a value for the given function, as set by "will_return". */
6695CMockaValueData _mock(const char *const function,
6696 const char *const file,
6697 const int line,
6698 const char *name);
6699
6700CMockaValueData _mock_parameter(const char *const function,
6701 const char *name,
6702 const char *const file,
6703 const int line,
6704 const char *type);
6705
6706bool _has_mock(const char *const function);
6707
6708void _expect_function_call(
6709 const char * const function_name,
6710 const char * const file,
6711 const int line,
6712 const int count);
6713
6714void _function_called(const char * const function, const char* const file,
6715 const int line);
6716
6717/* Old API function using uintmax_t */
6718void _expect_check(
6719 const char* const function, const char* const parameter,
6720 const char* const file, const int line,
6721 const CheckParameterValue check_function,
6722 const uintmax_t check_data, CheckParameterEvent * const event,
6723 const int count) CMOCKA_DEPRECATED;
6724
6725/* New API function using CMockaValueData */
6726void _expect_check_data(
6727 const char* const function, const char* const parameter,
6728 const char* const file, const int line,
6729 const CheckParameterValueData check_function,
6730 const CMockaValueData check_data, CheckParameterEventData * const event,
6731 const int count);
6732
6733void _expect_int_in_set(const char *const function,
6734 const char *const parameter,
6735 const char *const file,
6736 const size_t line,
6737 const intmax_t values[],
6738 const size_t number_of_values,
6739 const size_t count);
6740void _expect_uint_in_set(const char *const function,
6741 const char *const parameter,
6742 const char *const file,
6743 const size_t line,
6744 const uintmax_t values[],
6745 const size_t number_of_values,
6746 const size_t count);
6747
6748void _expect_float_in_set(const char *const function,
6749 const char *const parameter,
6750 const char *const file,
6751 const size_t line,
6752 const double values[],
6753 const size_t number_of_values,
6754 const double epsilon,
6755 const size_t count);
6756
6757void _expect_not_in_set(
6758 const char* const function, const char* const parameter,
6759 const char* const file, const int line, const uintmax_t values[],
6760 const size_t number_of_values, const int count);
6761void _expect_int_not_in_set(const char *const function,
6762 const char *const parameter,
6763 const char *const file,
6764 const size_t line,
6765 const intmax_t values[],
6766 const size_t number_of_values,
6767 const size_t count);
6768void _expect_uint_not_in_set(const char *const function,
6769 const char *const parameter,
6770 const char *const file,
6771 const size_t line,
6772 const uintmax_t values[],
6773 const size_t number_of_values,
6774 const size_t count);
6775
6776void _expect_float_not_in_set(
6777 const char* const function, const char* const parameter,
6778 const char* const file, const size_t line, const double values[],
6779 const size_t number_of_values, const double epsilon, const size_t count);
6780
6781void _expect_in_range(const char *const function,
6782 const char *const parameter,
6783 const char *const file,
6784 const int line,
6785 const uintmax_t minimum,
6786 const uintmax_t maximum,
6787 const int count) CMOCKA_DEPRECATED;
6788void _expect_int_in_range(const char *const function,
6789 const char *const parameter,
6790 const char *const file,
6791 const size_t line,
6792 const intmax_t minimum,
6793 const intmax_t maximum,
6794 const size_t count);
6795void _expect_uint_in_range(const char *const function,
6796 const char *const parameter,
6797 const char *const file,
6798 const size_t line,
6799 const uintmax_t minimum,
6800 const uintmax_t maximum,
6801 const size_t count);
6802void _expect_not_in_range(
6803 const char* const function, const char* const parameter,
6804 const char* const file, const int line,
6805 const uintmax_t minimum,
6806 const uintmax_t maximum, const int count);
6807void _expect_int_not_in_range(const char *const function,
6808 const char *const parameter,
6809 const char *const file,
6810 const size_t line,
6811 const intmax_t minimum,
6812 const intmax_t maximum,
6813 const size_t count);
6814void _expect_uint_not_in_range(const char *const function,
6815 const char *const parameter,
6816 const char *const file,
6817 const size_t line,
6818 const uintmax_t minimum,
6819 const uintmax_t maximum,
6820 const size_t count);
6821void _expect_float_in_range(
6822 const char* const function, const char* const parameter,
6823 const char* const file, const int line,
6824 const double minimum, const double maximum, const double epsilon,
6825 const int count);
6826void _expect_float_not_in_range(
6827 const char* const function, const char* const parameter,
6828 const char* const file, const int line,
6829 const double minimum, const double maximum, const double epsilon,
6830 const int count);
6831
6832void _expect_value(
6833 const char* const function, const char* const parameter,
6834 const char* const file, const int line, const uintmax_t value,
6835 const int count);
6836void _expect_int_value(const char *const function,
6837 const char *const parameter,
6838 const char *const file,
6839 const size_t line,
6840 const intmax_t value,
6841 const size_t count);
6842void _expect_uint_value(const char *const function,
6843 const char *const parameter,
6844 const char *const file,
6845 const size_t line,
6846 const uintmax_t value,
6847 const size_t count);
6848void _expect_int_not_value(const char *const function,
6849 const char *const parameter,
6850 const char *const file,
6851 const size_t line,
6852 const intmax_t value,
6853 const size_t count);
6854void _expect_uint_not_value(const char *const function,
6855 const char *const parameter,
6856 const char *const file,
6857 const size_t line,
6858 const uintmax_t value,
6859 const size_t count);
6860void _expect_not_value(
6861 const char* const function, const char* const parameter,
6862 const char* const file, const int line, const uintmax_t value,
6863 const int count);
6864
6865void _expect_float(
6866 const char* const function, const char* const parameter,
6867 const char* const file, const int line, const double value,
6868 const double epsilon, const int count);
6869void _expect_not_float(
6870 const char* const function, const char* const parameter,
6871 const char* const file, const int line, const double value,
6872 const double epsilon, const int count);
6873
6874void _expect_double(const char *const function,
6875 const char *const parameter,
6876 const char *const file,
6877 const int line,
6878 const double value,
6879 const double epsilon,
6880 const int count);
6881void _expect_not_double(const char *const function,
6882 const char *const parameter,
6883 const char *const file,
6884 const int line,
6885 const double value,
6886 const double epsilon,
6887 const int count);
6888
6889void _expect_string(
6890 const char* const function, const char* const parameter,
6891 const char* const file, const int line, const char* string,
6892 const int count);
6893void _expect_not_string(
6894 const char* const function, const char* const parameter,
6895 const char* const file, const int line, const char* string,
6896 const int count);
6897
6898void _expect_memory(
6899 const char* const function, const char* const parameter,
6900 const char* const file, const int line, const void* const memory,
6901 const size_t size, const int count);
6902void _expect_not_memory(
6903 const char* const function, const char* const parameter,
6904 const char* const file, const int line, const void* const memory,
6905 const size_t size, const int count);
6906
6907void _expect_any(
6908 const char* const function, const char* const parameter,
6909 const char* const file, const int line, const int count);
6910
6911void _check_expected(
6912 const char * const function_name, const char * const parameter_name,
6913 const char* file, const int line, const CMockaValueData value);
6914
6915void _will_return(const char *const function_name,
6916 const char *const file,
6917 const int line,
6918 const char *name,
6919 const CMockaValueData value,
6920 const int count);
6921void _will_set_parameter(const char *const function_name,
6922 const char *name,
6923 const char *const file,
6924 const int line,
6925 const char *type,
6926 const CMockaValueData value,
6927 const int count);
6928void _assert_true(const uintmax_t result,
6929 const char* const expression,
6930 const char * const file, const int line);
6931void _assert_false(const uintmax_t result,
6932 const char * const expression,
6933 const char * const file, const int line);
6934void _assert_return_code(const intmax_t result,
6935 const int32_t error,
6936 const char * const expression,
6937 const char * const file,
6938 const int line);
6939void _assert_float_equal(const float a, const float n,
6940 const float epsilon, const char* const file,
6941 const int line);
6942void _assert_float_not_equal(const float a, const float n,
6943 const float epsilon, const char* const file,
6944 const int line);
6945void _assert_double_equal(const double a, const double n,
6946 const double epsilon, const char* const file,
6947 const int line);
6948void _assert_double_not_equal(const double a, const double n,
6949 const double epsilon, const char* const file,
6950 const int line);
6951void _assert_int_equal(const intmax_t a,
6952 const intmax_t b,
6953 const char * const file,
6954 const int line);
6955void _assert_int_not_equal(const intmax_t a,
6956 const intmax_t b,
6957 const char * const file,
6958 const int line);
6959void _assert_uint_equal(const uintmax_t a,
6960 const uintmax_t b,
6961 const char * const file,
6962 const int line);
6963void _assert_uint_not_equal(const uintmax_t a,
6964 const uintmax_t b,
6965 const char * const file,
6966 const int line);
6967CMOCKA_NO_ACCESS_ATTRIBUTE
6968void _assert_ptr_equal_msg(const void *a,
6969 const void *b,
6970 const char *const file,
6971 const int line,
6972 const char *const msg);
6973CMOCKA_NO_ACCESS_ATTRIBUTE
6974void _assert_ptr_not_equal_msg(const void *a,
6975 const void *b,
6976 const char *const file,
6977 const int line,
6978 const char *const msg);
6979void _assert_string_equal(const char * const a, const char * const b,
6980 const char * const file, const int line);
6981void _assert_string_not_equal(const char * const a, const char * const b,
6982 const char *file, const int line);
6983void _assert_memory_equal(const void * const a, const void * const b,
6984 const size_t size, const char* const file,
6985 const int line);
6986void _assert_memory_not_equal(const void * const a, const void * const b,
6987 const size_t size, const char* const file,
6988 const int line);
6989void _assert_int_in_range(const intmax_t value,
6990 const intmax_t minimum,
6991 const intmax_t maximum,
6992 const char* const file,
6993 const int line);
6994void _assert_int_not_in_range(const intmax_t value,
6995 const intmax_t minimum,
6996 const intmax_t maximum,
6997 const char *const file,
6998 const int line);
6999void _assert_uint_in_range(const uintmax_t value,
7000 const uintmax_t minimum,
7001 const uintmax_t maximum,
7002 const char* const file,
7003 const int line);
7004void _assert_uint_not_in_range(const uintmax_t value,
7005 const uintmax_t minimum,
7006 const uintmax_t maximum,
7007 const char* const file,
7008 const int line);
7009void _assert_float_in_range(const double value,
7010 const double minimum,
7011 const double maximum,
7012 const double epsilon,
7013 const char* const file,
7014 const int line);
7015void _assert_float_not_in_range(const double value,
7016 const double minimum,
7017 const double maximum,
7018 const double epsilon,
7019 const char* const file,
7020 const int line);
7021void _assert_not_in_set(
7022 const uintmax_t value, const uintmax_t values[],
7023 const size_t number_of_values, const char* const file, const int line);
7024void _assert_int_in_set(const intmax_t value,
7025 const intmax_t values[],
7026 const size_t number_of_values,
7027 const char *const file,
7028 const int line);
7029void _assert_int_not_in_set(const intmax_t value,
7030 const intmax_t values[],
7031 const size_t number_of_values,
7032 const char *const file,
7033 const int line);
7034void _assert_uint_in_set(const uintmax_t value,
7035 const uintmax_t values[],
7036 const size_t number_of_values,
7037 const char *const file,
7038 const int line);
7039void _assert_uint_not_in_set(const uintmax_t value,
7040 const uintmax_t values[],
7041 const size_t number_of_values,
7042 const char *const file,
7043 const int line);
7044void _assert_float_in_set(const double value,
7045 const double values[],
7046 const size_t number_of_values,
7047 const double epsilon,
7048 const char *const file,
7049 const int line);
7050void _assert_float_not_in_set(const double value,
7051 const double values[],
7052 const size_t number_of_values,
7053 const double epsilon,
7054 const char *const file,
7055 const int line);
7056
7057void* _test_malloc(const size_t size, const char* file, const int line);
7058void* _test_realloc(void *ptr, const size_t size, const char* file, const int line);
7059void* _test_calloc(const size_t number_of_elements, const size_t size,
7060 const char* file, const int line);
7061void _test_free(void* const ptr, const char* file, const int line);
7062
7063CMOCKA_NORETURN void _fail(const char * const file, const int line);
7064
7065CMOCKA_NORETURN void _skip(const char * const file, const int line);
7066
7067CMOCKA_NORETURN void _stop(void);
7068
7069/* Test runner */
7070int _cmocka_run_group_tests(const char *group_name,
7071 const struct CMUnitTest * const tests,
7072 const size_t num_tests,
7073 CMFixtureFunction group_setup,
7074 CMFixtureFunction group_teardown);
7075
7077
7078#ifdef __cplusplus
7079} /* extern "C" */
7080#endif
7081
7082#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:4789
void cm_print_error(const char *const format,...)
void cmocka_set_callbacks(const struct CMCallbacks *f_callbacks)
Set callback functions for CMocka.
Definition cmocka.c:154
void cmocka_print_error(const char *const format,...) CMOCKA_PRINTF_ATTRIBUTE(1
Print error message using the cmocka output format.
cm_message_output
Output format options for test results.
Definition cmocka.h:6583
void cmocka_set_skip_filter(const char *pattern)
Set a pattern to skip tests matching the pattern.
Definition cmocka.c:4849
void cmocka_set_test_filter(const char *pattern)
Set a pattern to only run the test matching the pattern.
Definition cmocka.c:4832
@ CM_OUTPUT_TAP
Definition cmocka.h:6591
@ CM_OUTPUT_STDOUT
Definition cmocka.h:6587
@ CM_OUTPUT_SUBUNIT
Definition cmocka.h:6589
@ CM_OUTPUT_STANDARD
Definition cmocka.h:6585
@ CM_OUTPUT_XML
Definition cmocka.h:6593
void(* UnitTestFunction)(void **state)
Definition cmocka.h:6384
int(* CMFixtureFunction)(void **state)
Definition cmocka.h:6466
int cmocka_run_group_tests(const struct CMUnitTest group_tests[], CMFixtureFunction group_setup, CMFixtureFunction group_teardown)
Run tests specified by an array of CMUnitTest structures.
void fail(void)
Forces the test to fail immediately and quit.
void stop(void)
Forces the test to be stopped immediately.
UnitTestFunctionType
Definition cmocka.h:6423
void fail_msg(const char *msg,...)
Forces the test to fail immediately and quit, printing the reason.
int cmocka_run_group_tests_name(const char *group_name, const struct CMUnitTest group_tests[], CMFixtureFunction group_setup, CMFixtureFunction group_teardown)
Run tests specified by an array of CMUnitTest structures and specify a name.
void skip(void)
Forces the test to not be executed, but marked as skipped.
void(* CMUnitTestFunction)(void **state)
Definition cmocka.h:6459
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:3440
void expect_assert_failure(function fn_call)
Ensure that mock_assert() is called.
void will_return_int(#function, intmax_t value)
Store an integer value to be returned by mock() later.
void will_set_parameter_float_always(#function, #name, float value)
Store a named float value that will always be returned by mock_parameter_float().
uintmax_t mock_parameter(#name)
Retrieve a named value for the current function.
void will_return_float_maybe(#function, float value)
Store a float value that may always be returned by mock_float().
void will_set_parameter_int(#function, #name, intmax_t value)
Store a named integer value to be returned by mock_parameter() later.
intmax_t mock_int()
Retrieve an integer return value of the current function.
void will_return_float_always(#function, float value)
Store a float value that will always be returned by mock_float().
void will_set_parameter_int_count(#function, #name, intmax_t value, int count)
Store a named integer value to be returned a specified number of times by mock_parameter_int() later.
void will_return_double_count(#function, double value, int count)
Store a double precision floating point value to be returned a specified number of times by mock() la...
void will_set_parameter_double_count(#function, #name, double value, int count)
Store a named double value to be returned a specified number of times by mock_parameter_double() late...
void will_set_parameter_uint(#function, #name, uintmax_t value)
Store a named unsigned integer value to be returned by mock_parameter() later.
void will_set_parameter_float_maybe(#function, #name, float value)
Store a named float value that may always be returned by mock_parameter_float().
void * mock_parameter_ptr(#name)
Retrieve a named pointer for the current function.
void will_return_count(#function, uintmax_t value, int count)
void will_set_parameter(#function, #name, uintmax_t value)
Store a named value to be returned by mock_parameter() later.
void will_return_int_maybe(#function, intmax_t value)
Store an integer value that may always be returned by mock_int().
void will_set_parameter_ptr_type(#function, #name, void *value, #type)
Store a named pointer value to be returned by mock_parameter() later.
void will_set_parameter_ptr(#function, #name, void *value)
Store a named pointer value to be returned by mock_parameter() later.
void will_return(#function, uintmax_t value)
Store a value to be returned by mock() later.
void will_return_ptr_type(#function, void *value, type)
Store a pointer value to be returned by mock_ptr_type_checked() later.
void will_return_double_always(#function, double value)
Store a double value that will always be returned by mock_double().
void will_set_errno_always(#function, intmax_t value)
Store an integer value to set errno to by mock_errno() later, for a specified number of times.
type mock_parameter_ptr_type(#name, #type)
Retrieve a named pointer for the current function.
double mock_double(void)
Retrieve a double precision floating point return value of the current function.
void will_return_uint_maybe(#function, uintmax_t value)
Store an unsigned integer value that may always be returned by mock_uint().
void will_set_errno_count(#function, intmax_t value, size_t count)
Store an integer value to always set errno to by mock_errno().
void will_return_uint_always(#function, uintmax_t value)
Store an unsigned integer value that will always be returned by mock_uint().
void will_set_parameter_double_maybe(#function, #name, double value)
Store a named double value that may always be returned by mock_parameter_double().
void will_set_parameter_int_maybe(#function, #name, intmax_t value)
Store a named integer value that may always be returned by mock_parameter_int().
void will_set_errno_maybe(#function, intmax_t value)
Store an integer value to set errno to by mock_errno() later, for a specified number of times.
void will_return_uint_count(#function, uintmax_t value, int count)
Store an unsigned integer value to be returned a specified number of times by mock() later.
void will_return_double_maybe(#function, double value)
Store a double value that may always be returned by mock_double().
uintmax_t mock_uint(void)
Retrieve an unsigned integer return value of the current function.
void will_set_parameter_double(#function, #name, double value)
Store a named double precision floating point value to be returned by mock_parameter() later.
void will_set_parameter_ptr_always(#function, #name, void *value)
Store a named pointer value that will be always returned by mock_parameter_ptr().
void will_return_always(#function, uintmax_t value)
void will_return_ptr(#function, void *value)
Store a pointer value to be returned by mock_ptr_type() later.
void will_return_ptr_always(#function, void *value)
Store a value that will be always returned by mock_ptr_type().
void will_return_int_always(#function, intmax_t value)
Store an integer value that will always be returned by mock_int().
type mock_type(#type)
Retrieve a value of the current function and cast it to given type.
void will_set_parameter_float(#function, #name, float value)
Store a named float value to be returned by mock_parameter() later.
void will_set_parameter_double_always(#function, #name, double value)
Store a named double value that will always be returned by mock_parameter_double().
bool has_mock(void)
Check if data is available for the current mock function.
float mock_parameter_float(#name)
Retrieve a named float value for the current function.
void will_set_parameter_uint_maybe(#function, #name, uintmax_t value)
Store a named unsigned integer value that may always be returned by mock_parameter_uint().
void will_set_parameter_int_always(#function, #name, intmax_t value)
Store a named integer value that will always be returned by mock_parameter_int().
void will_return_maybe(#function, uintmax_t value)
void will_set_parameter_always(#function, #name, uintmax_t value)
void will_set_parameter_count(#function, #name, uintmax_t value, int count)
void will_return_int_count(#function, intmax_t value, int count)
Store an integer value to be returned a specified number of times by mock() later.
void will_set_parameter_float_count(#function, #name, float value, int count)
Store a named float value to be returned a specified number of times by mock_parameter_float() later.
void will_return_ptr_count(#function, void *value, int count)
Store a pointer value to be returned by mock_ptr_type() later.
void will_set_parameter_uint_always(#function, #name, uintmax_t value)
Store a named unsigned integer value that will always be returned by mock_parameter_uint().
void will_set_parameter_maybe(#function, #name, uintmax_t value)
uintmax_t mock_parameter_uint(#name)
Retrieve an unsigned integer return value of the current function.
void will_return_uint(#function, uintmax_t value)
Store a unsigned integer value to be returned by mock() later.
void will_return_float(#function, float value)
Store a float value to be returned by mock() later.
void will_set_errno(#function, intmax_t value)
Store an integer value to set errno to by mock_errno() later.
void will_return_float_count(#function, float value, int count)
Store a float value to be returned a specified number of times by mock() later.
type mock_ptr_type(#type)
Retrieve a typed return value of the current function.
void will_set_parameter_ptr_count(#function, #name, void *value, int count)
Store a named pointer value to be returned a specified number of times by mock_parameter_ptr() later.
float mock_float(void)
Retrieve a float return value of the current function.
uintmax_t mock(void)
Retrieve a return value of the current function.
void mock_errno(void)
set errno for the current function.
intmax_t mock_parameter_int(#name)
Retrieve a named value for the current function and cast it to given type.
void will_return_double(#function, double value)
Store a double precision floating point value to be returned by mock() later.
void will_set_parameter_ptr_maybe(#function, #name, void *value)
Store a named pointer value that may be always returned by mock_parameter_ptr().
void will_return_ptr_maybe(#function, void *value)
Store a value that may be always returned by mock_ptr_type().
void will_set_parameter_uint_count(#function, uintmax_t value, int count)
Store a named unsigned integer value to be returned a specified number of times by mock_parameter_uin...
double mock_parameter_double(#name)
Retrieve a named double precision floating point value for the current function.
type mock_ptr_type_checked(#type)
Retrieve a typed return value of the current function with type checking.
void expect_float_not_in_set(#function, #parameter, double value_array[], double epsilon)
Add an event to check if the float parameter value is not part of the provided array.
void expect_not_in_range_count(#function, #parameter, uintmax_t minimum, uintmax_t maximum, size_t count)
Add an event to repeatedly check a parameter is outside a numerical range. The check would succeed if...
void expect_float_not_in_range_count(#function, #parameter, double minimum, double maximum, double epsilon, size_t count)
Add an event to repeatedly check a parameter is outside a numerical range. The check would succeed if...
void expect_uint_not_in_range_count(#function, uintmax_t minimum, uintmax_t maximum, size_t count)
Add an event to repeatedly check an unsigned integer parameter is outside a numerical range....
void expect_float_not_in_set_count(#function, #parameter, double value_array[], double epsilon, size_t count)
Add an event to check if the float parameter value is not part of the provided integer array.
void expect_uint_not_in_range(#function, uintmax_t minimum, uintmax_t maximum)
Add an event to check an unsigned integer parameter is outside a numerical range. The check would suc...
void expect_any_count(#function, #parameter, size_t count)
Add an event to repeatedly check if a parameter (of any value) has been passed.
void expect_not_string(#function, #parameter, const char *string)
Add an event to check if the parameter value isn't equal to the provided string.
void check_expected_ptr(#parameter)
Determine whether a function parameter is correct.
void expect_in_set_count(#function, #parameter, uintmax_t value_array[], size_t count)
void expect_not_in_set_count(#function, #parameter, uintmax_t value_array[], size_t count)
void check_expected(#parameter)
void expect_not_string_count(#function, #parameter, const char *string, size_t count)
Add an event to check if the parameter value isn't equal to the provided string.
void expect_in_range_count(#function, #parameter, uintmax_t minimum, uintmax_t maximum, size_t count)
void expect_not_memory_count(#function, #parameter, void *memory, size_t size, size_t count)
Add an event to repeatedly check if the parameter doesn't match an area of memory.
void expect_int_in_set_count(#function, #parameter, intmax_t value_array[], size_t count)
Add an event to check if the parameter value is part of the provided integer array.
void expect_check_data(function, parameter, CheckParameterValueData check_function, CMockaValueData check_data)
Add a custom parameter checking function using CMockaValueData (new API).
void expect_in_range(#function, #parameter, uintmax_t minimum, uintmax_t maximum)
void expect_float_in_set_count(#function, #parameter, double value_array[], double epsilon, size_t count)
Add an event to check if the float parameter value is part of the provided integer array.
void expect_float(#function, #parameter, double value, double epsilon)
Add an event to check if a parameter is the given floating point value.
void expect_uint_in_range_count(#function, uintmax_t minimum, uintmax_t maximum, size_t count)
Add an event to repeatedly check an unsigned integer parameter is inside a numerical range....
void check_expected_float(#parameter)
Determine whether a function parameter is correct.
void expect_float_in_range(#function, #parameter, double minimum, double maximum, double epsilon)
Add an event to check a parameter is inside a numerical range. The check would succeed if minimum <= ...
void expect_double(#function, #parameter, double value, double epsilon)
Add an event to check if a parameter is the given double precision floating point value.
void expect_int_not_value_count(#function, intmax_t value, size_t count)
Add an event to repeatedly check if a parameter (int) isn't the given value.
void expect_string(#function, #parameter, const char *string)
Add an event to check if the parameter value is equal to the provided string.
void expect_int_value(#function, #parameter, intmax_t value)
Add an event to check if an integer parameter is the given value.
void expect_int_not_in_set(#function, #parameter, intmax_t value_array[])
Add an event to check if the integer parameter value is not part of the provided integer array.
void expect_any_always(#function, #parameter)
Add an event to always check if a parameter (of any value) has been passed.
void expect_uint_in_range(#function, uintmax_t minimum, uintmax_t maximum)
Add an event to check an unsigned integer parameter is inside a numerical range. The check would succ...
void expect_not_memory(#function, #parameter, void *memory, size_t size)
Add an event to check if the parameter doesn't match an area of memory.
void expect_memory_count(#function, #parameter, void *memory, size_t size, size_t count)
Add an event to repeatedly check if the parameter does match an area of memory.
void expect_not_in_range(#function, #parameter, uintmax_t minimum, uintmax_t maximum)
Add an event to check a parameter is outside a numerical range. The check would succeed if minimum > ...
void expect_float_in_range_count(#function, #parameter, double minimum, double maximum, double epsilon, size_t count)
Add an event to repeatedly check a parameter is inside a numerical range. The check would succeed if ...
void expect_int_value_count(#function, intmax_t value, size_t count)
Add an event to repeatedly check if an integer parameter is the given value.
int(* CheckParameterValue)(const uintmax_t value, const uintmax_t check_value_data)
Definition cmocka.h:6391
void expect_uint_value(#function, #parameter, uintmax_t value)
Add an event to check if an unsigned integer parameter is the given value.
void expect_uint_value_count(#function, uintmax_t value, size_t count)
Add an event to repeatedly check if an unsigned integer parameter is the given value.
void check_expected_int(#parameter)
Determine whether a function parameter is correct.
void expect_int_not_in_range_count(#function, intmax_t minimum, intmax_t maximum, size_t count)
Add an event to repeatedly check an integer parameter is outside a numerical range....
void check_expected_double(#parameter)
Determine whether a function parameter is correct.
int(* CheckIntParameterValue)(const intmax_t value, const intmax_t check_value_data)
Definition cmocka.h:6407
int(* CheckParameterValueData)(const CMockaValueData value, const CMockaValueData check_value_data)
Definition cmocka.h:6399
void expect_not_value(#function, #parameter, uintmax_t value)
void expect_memory(#function, #parameter, void *memory, size_t size)
Add an event to check if the parameter does match an area of memory.
void expect_int_in_range(#function, intmax_t minimum, intmax_t maximum)
Add an event to check an integer parameter is inside a numerical range. The check would succeed if mi...
void expect_not_float(#function, #parameter, double value, double epsilon)
Add an event to check if a parameter isn't the given floating point value.
void check_expected_uint(#parameter)
Determine whether a function parameter is correct.
void expect_uint_not_value_count(#function, uintmax_t value, size_t count)
Add an event to repeatedly check if a parameter (uint) isn't the given value.
void expect_uint_not_in_set_count(#function, uintmax_t value_array[], size_t count)
Add an event to check if the unsigned integer parameter value is not part of the provided unsigned in...
void expect_check_data_count(function, parameter, CheckParameterValueData check_function, CMockaValueData check_data, size_t count)
Add a custom parameter checking function using CMockaValueData with count (new API).
void expect_any(#function, #parameter)
Add an event to check if a parameter (of any value) has been passed.
void expect_check_count(function, parameter, CheckParameterValue check_function, const void *check_data, size_t count)
void expect_int_in_range_count(#function, intmax_t minimum, intmax_t maximum, size_t count)
Add an event to repeatedly check an integer parameter is inside a numerical range....
void expect_float_in_set(#function, #parameter, double value_array[], double epsilon)
Add an event to check if the float parameter value is part of the provided array.
void expect_not_in_set(#function, #parameter, uintmax_t value_array[])
void expect_float_not_in_range(#function, #parameter, double minimum, double maximum, double epsilon)
Add an event to check a parameter is outside a numerical range. The check would succeed if minimum > ...
void expect_float_count(#function, #parameter, double value, double epsilon, size_t count)
Add an event to repeatedly check if a parameter is the given floating point value.
int(* CheckUintParameterValue)(const uintmax_t value, const uintmax_t check_value_data)
Definition cmocka.h:6415
void check_expected_any(#parameter)
Check that any parameter value matches the next value in the queue.
void expect_value(#function, #parameter, uintmax_t value)
void expect_double_count(#function, double value, double epsilon, size_t count)
Add an event to repeatedly check if a parameter is the given double precision floating point value.
void expect_uint_in_set_count(#function, #parameter, uintmax_t value_array[], size_t count)
Add an event to check if the parameter value is part of the provided unsigned integer array.
void expect_check(function, parameter, CheckParameterValue check_function, const void *check_data)
void expect_string_count(#function, #parameter, const char *string, size_t count)
Add an event to check if the parameter value is equal to the provided string.
void expect_not_double_count(#function, double value, double epsilon, size_t count)
Add an event to repeatedly check if a parameter isn't the double precision floating point value.
void expect_not_float_count(#function, #parameter, double value, double epsilon, size_t count)
Add an event to repeatedly check if a parameter isn't the floating point value.
void expect_not_double(#function, #parameter, double value, double epsilon)
Add an event to check if a parameter isn't the given double precision floating point value.
void expect_uint_not_value(#function, #parameter, uintmax_t value)
Add an event to check if a parameter (uint) isn't the given value.
void expect_int_not_value(#function, #parameter, intmax_t value)
Add an event to check if a parameter (int) isn't the given value.
void expect_value_count(#function, #parameter, uintmax_t value, size_t count)
void expect_not_value_count(#function, #parameter, uintmax_t value, size_t count)
void expect_in_set(#function, #parameter, uintmax_t value_array[])
void expect_uint_not_in_set(#function, #parameter, uintmax_t value_array[])
Add an event to check if the unsigned integer parameter value is not part of the provided unsigned in...
void expect_int_not_in_range(#function, intmax_t minimum, intmax_t maximum)
Add an event to check an integer parameter is outside a numerical range. The check would succeed if m...
void expect_int_not_in_set_count(#function, intmax_t value_array[], size_t count)
Add an event to check if the integer parameter value is not part of the provided integer array.
Definition cmocka.h:6539
void(* vprint_message)(const char *const format, va_list args)
Definition cmocka.h:6547
void(* vprint_error)(const char *const format, va_list args)
Definition cmocka.h:6556
Definition cmocka.h:6471
Definition cmocka.h:6506
Definition cmocka.h:6494
Definition cmocka.h:6447
Definition cmocka.h:6484
Definition cmocka.h:6438
Definition cmocka.h:6338
double real_val
Definition cmocka.h:6346
float float_val
Definition cmocka.h:6344
intmax_t int_val
Definition cmocka.h:6340
uintmax_t uint_val
Definition cmocka.h:6342
const void * ptr
Definition cmocka.h:6348