cmocka: /usr/src/cmocka/cmocka-2.0.0-1.x86_64/src/cmocka-2.0.0/include/cmocka.h Source File

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
425 bool 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
479 float mock_float(void);
480#else
481#define mock_float() (_mock(__func__, __FILE__, __LINE__, NULL)).float_val
482#endif
483
484#ifdef DOXYGEN
493 double 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
547type mock_ptr_type_checked(#type);
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
687 float mock_parameter_float(#name);
688#else
689#define mock_parameter_float(name) \
690 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "float")).float_val
691#endif
692
693#ifdef DOXYGEN
711 double mock_parameter_double(#name);
712#else
713#define mock_parameter_double(name) \
714 (_mock_parameter(__func__, #name, __FILE__, __LINE__, "double")).real_val
715#endif
716
717#ifdef DOXYGEN
734 void *mock_parameter_ptr(#name);
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
775 void 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
825 void 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
860 void 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
905 void 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
941 void 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
986 void 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
1022 void 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
1067 void 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
1103 void 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
1148 void 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
1175 void 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
1198 void 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
1220 void 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
1242 void 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
1252 void 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
1272 void 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
1305 void 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
1334 void 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
1362 void 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
1390 void 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
1400 void 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
1436 void 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
1476 void 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
1503 void 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
1530 void 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
1558 void 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
1609 void 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
1653 void 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
1699 void 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
1744 void 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
1790 void 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
1822 void 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
1854 void will_set_parameter_uint_count(#function,
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
1889 void 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
1921 void 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
1938 void 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
1975 void 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
2001 void 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
2027 void 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
2053 void 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
2064 void 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
2096 void 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
2123 void 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
2150 void 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
2177 void 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
2188 void 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
2228 void 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
2274 void 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
2325 void 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
2364 void 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
2399 void 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
2430 void 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
2481 void 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
2516 void 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
2545 void 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
2603 void 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
2628 void expect_check_count(function,
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
2806 void 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
2887 void expect_check_data_count(function,
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
2912 void 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
2937 void 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
2968 void 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
3004 void 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
3035 void 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
3051 void 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
3066 void 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
3098 void 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
3123 void expect_int_not_in_set_count(#function,
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
3153 void 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
3178 void expect_uint_not_in_set_count(#function,
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
3210 void 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
3237 void 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
3267 void 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
3294 void 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
3312 void 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
3327 void 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
3361 void 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
3391 void expect_int_in_range_count(#function,
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
3425 void expect_uint_in_range(#function,
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
3456 void expect_uint_in_range_count(#function,
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
3490 void 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
3517 void 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
3542 void expect_int_not_in_range(#function,
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
3572 void expect_int_not_in_range_count(#function,
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
3606 void expect_uint_not_in_range(#function,
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
3637 void expect_uint_not_in_range_count(#function,
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
3673 void 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
3702 void 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
3734 void 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
3763 void 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
3781 void 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
3795 void 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
3825 void 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
3850 void expect_int_value_count(#function,
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
3879 void 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
3904 void expect_uint_value_count(#function,
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
3932 void 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
3957 void expect_int_not_value_count(#function,
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
3985 void 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
4010 void expect_uint_not_value_count(#function,
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
4028 void 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
4043 void 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
4078 void 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
4108 void 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
4135 void 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
4168 void 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
4198 void 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
4230 void 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
4264 void 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
4296 void expect_not_double_count(#function,
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
4327 void 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
4352 void 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
4374 void 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
4399 void 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
4422 void 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
4449 void 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
4473 void 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
4500 void 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
4520 void 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
4538 void 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
4561 void 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
4572 void 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
4615 void 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
4633 void 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
4651 void 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
4672 void 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
4698 void 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
4724 void 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
4772 void 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
4790 void 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
4809 void 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
4828 void 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
4846 void 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
4862 void assert_null(void *pointer);
4863#else
4864#define assert_null(c) assert_ptr_equal((c), NULL)
4865#endif
4866
4867#ifdef DOXYGEN
4880 void 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
4896 void 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
4914 void 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
4933 void 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
4952 void 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
4999 void 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
5018 void 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
5039 void 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
5058 void 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
5079 void 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
5101 void 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
5123 void 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
5145 void 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
5166 void 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
5183 void 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
5204 void 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
5226 void 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
5247 void 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
5270 void 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
5296 void 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
5325 void 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
5341 void 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
5360 void 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
5394 void 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
5421 void 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
5435 void 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
5459 void 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
5478 void 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
5503 void 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
5528 void 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
5553 void 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
5580 void 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
5607 void 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
5692 void function_called(void);
5693#else
5694#define function_called() _function_called(__func__, __FILE__, __LINE__)
5695#endif
5696
5697#ifdef DOXYGEN
5708 void 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
5723 void 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
5737 void expect_function_call_any(#function);
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
5751 void ignore_function_calls(#function);
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
5795 void fail(void);
5796#else
5797#define fail() _fail(__FILE__, __LINE__)
5798#endif
5799
5800#ifdef DOXYGEN
5804 void skip(void);
5805#else
5806#define skip() _skip(__FILE__, __LINE__)
5807#endif
5808
5809#ifdef DOXYGEN
5818 void stop(void);
5819#else
5820#define stop() _stop()
5821#endif
5822
5823#ifdef DOXYGEN
5838 void 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
6009 int 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
6077 int 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
6171 void *test_malloc(size_t size);
6172#else
6173#define test_malloc(size) _test_malloc(size, __FILE__, __LINE__)
6174#endif
6175
6176#ifdef DOXYGEN
6190 void *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
6206 void *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
6219 void 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
6310 void 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
6338 typedef union {
6340 intmax_t int_val;
6342 uintmax_t uint_val;
6344 float float_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);
6353} CMockaValueData;
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
6384 typedef void (*UnitTestFunction)(void **state);
6385
6391 typedef int (*CheckParameterValue)(const uintmax_t value,
6392 const uintmax_t check_value_data);
6393
6399 typedef int (*CheckParameterValueData)(const CMockaValueData value,
6400 const CMockaValueData check_value_data);
6401
6407 typedef int (*CheckIntParameterValue)(const intmax_t value,
6408 const intmax_t check_value_data);
6409
6415 typedef int (*CheckUintParameterValue)(const uintmax_t value,
6416 const uintmax_t check_value_data);
6417
6423 typedef enum UnitTestFunctionType {
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,
6429} UnitTestFunctionType;
6430
6438 typedef struct UnitTest {
6439 const char* name;
6440 UnitTestFunction function;
6441 UnitTestFunctionType function_type;
6442} UnitTest;
6443
6447 typedef struct GroupTest {
6448 UnitTestFunction setup;
6449 UnitTestFunction teardown;
6450 const UnitTest *tests;
6451 const size_t number_of_tests;
6452} GroupTest;
6453
6459 typedef void (*CMUnitTestFunction)(void **state);
6460
6466 typedef int (*CMFixtureFunction)(void **state);
6467
6471 struct CMUnitTest {
6472 const char *name;
6473 CMUnitTestFunction test_func;
6474 CMFixtureFunction setup_func;
6475 CMFixtureFunction teardown_func;
6476 void *initial_state;
6477};
6478
6484 typedef struct SourceLocation {
6485 const char* file;
6486 int line;
6487} SourceLocation;
6488
6494 typedef struct CheckParameterEvent {
6495 SourceLocation location;
6496 const char *parameter_name;
6497 CheckParameterValue check_value;
6498 uintmax_t check_value_data;
6499} CheckParameterEvent;
6500
6506 typedef struct CheckParameterEventData {
6507 SourceLocation location;
6508 const char *parameter_name;
6509 CheckParameterValueData check_value;
6510 CMockaValueData check_value_data;
6511} CheckParameterEventData;
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
6539struct CMCallbacks {
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
6583 enum cm_message_output {
6585 CM_OUTPUT_STANDARD = 0x00000001,
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
6600 void 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
6622 void 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". */
6695 CMockaValueData _mock(const char *const function,
6696 const char *const file,
6697 const int line,
6698 const char *name);
6699
6700 CMockaValueData _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_ */
test_realloc
void * test_realloc(void *ptr, size_t size)
Test function overriding realloc which detects buffer overruns and memory leaks.
test_free
void test_free(void *ptr)
Test function overriding free(3).
test_calloc
void * test_calloc(size_t nmemb, size_t size)
Test function overriding calloc.
test_malloc
void * test_malloc(size_t size)
Test function overriding malloc.
assert_ptr_equal
void assert_ptr_equal(void *a, void *b)
Assert that the two given pointers are equal.
assert_int_equal
void assert_int_equal(intmax_t a, intmax_t b)
Assert that the two given integers are equal.
assert_int_in_set
void assert_int_in_set(intmax_t value, intmax_t values[], size_t count)
Assert that the specified integer value is within a set.
assert_not_in_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.
assert_int_not_in_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.
assert_string_equal
void assert_string_equal(const char *a, const char *b)
Assert that the two given strings are equal.
assert_null
void assert_null(void *pointer)
Assert that the given pointer is NULL.
assert_not_in_range
void assert_not_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum)
assert_float_not_in_range
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.
assert_memory_not_equal
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.
assert_float_not_in_set
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.
assert_ptr_not_equal
void assert_ptr_not_equal(void *a, void *b)
Assert that the two given pointers are not equal.
assert_double_equal
void assert_double_equal(double a, double b, double epsilon)
Assert that the two given double are equal given an epsilon.
assert_ptr_not_equal_msg
void assert_ptr_not_equal_msg(void *a, void *b, const char *const msg)
Assert that the two given pointers are not equal.
assert_float_in_range
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...
assert_float_in_set
void assert_float_in_set(double value, double values[], size_t count, double epsilon)
Assert that the specified float value is within a set.
assert_in_range
void assert_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum)
assert_uint_equal
void assert_uint_equal(uintmax_t a, uintmax_t b)
Assert that the two given unsigned integers are equal.
assert_non_null
void assert_non_null(void *pointer)
Assert that the given pointer is non-NULL.
assert_null_msg
void assert_null_msg(void *pointer, const char *const message)
Assert that the given pointer is NULL.
assert_true
void assert_true(scalar expression)
Assert that the given expression is true.
assert_ptr_equal_msg
void assert_ptr_equal_msg(void *a, void *b, const char *const msg)
Assert that the two given pointers are equal.
assert_false
void assert_false(scalar expression)
Assert that the given expression is false.
assert_in_set
void assert_in_set(uintmax_t value, uintmax_t values[], size_t count)
assert_int_in_range
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 ...
assert_uint_not_in_range
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.
assert_int_not_equal
void assert_int_not_equal(intmax_t a, intmax_t b)
Assert that the two given integers are not equal.
assert_uint_not_equal
void assert_uint_not_equal(uintmax_t a, uintmax_t b)
Assert that the two given unsigned integers are not equal.
assert_memory_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.
assert_float_equal
void assert_float_equal(float a, float b, float epsilon)
Assert that the two given float are equal given an epsilon.
assert_double_not_equal
void assert_double_not_equal(double a, double b, double epsilon)
Assert that the two given double are not equal given an epsilon.
assert_string_not_equal
void assert_string_not_equal(const char *a, const char *b)
Assert that the two given strings are not equal.
assert_int_not_in_range
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.
assert_uint_not_in_set
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.
assert_uint_in_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.
assert_float_not_equal
void assert_float_not_equal(float a, float b, float epsilon)
Assert that the two given float are not equal given an epsilon.
assert_non_null_msg
void assert_non_null_msg(void *pointer, const char *const message)
Assert that the given pointer is non-NULL.
assert_uint_in_range
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 ...
assert_return_code
void assert_return_code(intmax_t rc, int32_t error)
Assert that the return_code is greater than or equal to 0.
ignore_function_calls
void ignore_function_calls(#function)
Ignores function_called() invocations from given mock function.
expect_function_call_any
void expect_function_call_any(#function)
Expects function_called() from given mock at least once.
expect_function_call
void expect_function_call(#function)
Store expected single call to a mock to be checked by function_called() later.
function_called
void function_called(void)
Check that current mocked function is being called in the expected order.
expect_function_calls
void expect_function_calls(#function, const int times)
Store expected call(s) to a mock to be checked by function_called() later.
cmocka_set_message_output
void cmocka_set_message_output(uint32_t output)
Function to set the output format for a test.
Definition cmocka.c:4789
cm_print_error
void cm_print_error(const char *const format,...)
cmocka_set_callbacks
void cmocka_set_callbacks(const struct CMCallbacks *f_callbacks)
Set callback functions for CMocka.
Definition cmocka.c:154
cmocka_print_error
void cmocka_print_error(const char *const format,...) CMOCKA_PRINTF_ATTRIBUTE(1
Print error message using the cmocka output format.
cm_message_output
cm_message_output
Output format options for test results.
Definition cmocka.h:6583
cmocka_set_skip_filter
void cmocka_set_skip_filter(const char *pattern)
Set a pattern to skip tests matching the pattern.
Definition cmocka.c:4849
cmocka_set_test_filter
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
@ CM_OUTPUT_TAP
Definition cmocka.h:6591
CM_OUTPUT_STDOUT
@ CM_OUTPUT_STDOUT
Definition cmocka.h:6587
CM_OUTPUT_SUBUNIT
@ CM_OUTPUT_SUBUNIT
Definition cmocka.h:6589
CM_OUTPUT_STANDARD
@ CM_OUTPUT_STANDARD
Definition cmocka.h:6585
CM_OUTPUT_XML
@ CM_OUTPUT_XML
Definition cmocka.h:6593
UnitTestFunction
void(* UnitTestFunction)(void **state)
Definition cmocka.h:6384
CMFixtureFunction
int(* CMFixtureFunction)(void **state)
Definition cmocka.h:6466
cmocka_run_group_tests
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.
fail
void fail(void)
Forces the test to fail immediately and quit.
stop
void stop(void)
Forces the test to be stopped immediately.
UnitTestFunctionType
UnitTestFunctionType
Definition cmocka.h:6423
fail_msg
void fail_msg(const char *msg,...)
Forces the test to fail immediately and quit, printing the reason.
cmocka_run_group_tests_name
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.
skip
void skip(void)
Forces the test to not be executed, but marked as skipped.
CMUnitTestFunction
void(* CMUnitTestFunction)(void **state)
Definition cmocka.h:6459
mock_assert
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
expect_assert_failure
void expect_assert_failure(function fn_call)
Ensure that mock_assert() is called.
will_return_int
void will_return_int(#function, intmax_t value)
Store an integer value to be returned by mock() later.
will_set_parameter_float_always
void will_set_parameter_float_always(#function, #name, float value)
Store a named float value that will always be returned by mock_parameter_float().
mock_parameter
uintmax_t mock_parameter(#name)
Retrieve a named value for the current function.
will_return_float_maybe
void will_return_float_maybe(#function, float value)
Store a float value that may always be returned by mock_float().
will_set_parameter_int
void will_set_parameter_int(#function, #name, intmax_t value)
Store a named integer value to be returned by mock_parameter() later.
mock_int
intmax_t mock_int()
Retrieve an integer return value of the current function.
will_return_float_always
void will_return_float_always(#function, float value)
Store a float value that will always be returned by mock_float().
will_set_parameter_int_count
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.
will_return_double_count
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...
will_set_parameter_double_count
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...
will_set_parameter_uint
void will_set_parameter_uint(#function, #name, uintmax_t value)
Store a named unsigned integer value to be returned by mock_parameter() later.
will_set_parameter_float_maybe
void will_set_parameter_float_maybe(#function, #name, float value)
Store a named float value that may always be returned by mock_parameter_float().
mock_parameter_ptr
void * mock_parameter_ptr(#name)
Retrieve a named pointer for the current function.
will_return_count
void will_return_count(#function, uintmax_t value, int count)
will_set_parameter
void will_set_parameter(#function, #name, uintmax_t value)
Store a named value to be returned by mock_parameter() later.
will_return_int_maybe
void will_return_int_maybe(#function, intmax_t value)
Store an integer value that may always be returned by mock_int().
will_set_parameter_ptr_type
void will_set_parameter_ptr_type(#function, #name, void *value, #type)
Store a named pointer value to be returned by mock_parameter() later.
will_set_parameter_ptr
void will_set_parameter_ptr(#function, #name, void *value)
Store a named pointer value to be returned by mock_parameter() later.
will_return
void will_return(#function, uintmax_t value)
Store a value to be returned by mock() later.
will_return_ptr_type
void will_return_ptr_type(#function, void *value, type)
Store a pointer value to be returned by mock_ptr_type_checked() later.
will_return_double_always
void will_return_double_always(#function, double value)
Store a double value that will always be returned by mock_double().
will_set_errno_always
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.
mock_parameter_ptr_type
type mock_parameter_ptr_type(#name, #type)
Retrieve a named pointer for the current function.
mock_double
double mock_double(void)
Retrieve a double precision floating point return value of the current function.
will_return_uint_maybe
void will_return_uint_maybe(#function, uintmax_t value)
Store an unsigned integer value that may always be returned by mock_uint().
will_set_errno_count
void will_set_errno_count(#function, intmax_t value, size_t count)
Store an integer value to always set errno to by mock_errno().
will_return_uint_always
void will_return_uint_always(#function, uintmax_t value)
Store an unsigned integer value that will always be returned by mock_uint().
will_set_parameter_double_maybe
void will_set_parameter_double_maybe(#function, #name, double value)
Store a named double value that may always be returned by mock_parameter_double().
will_set_parameter_int_maybe
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().
will_set_errno_maybe
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.
will_return_uint_count
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.
will_return_double_maybe
void will_return_double_maybe(#function, double value)
Store a double value that may always be returned by mock_double().
mock_uint
uintmax_t mock_uint(void)
Retrieve an unsigned integer return value of the current function.
will_set_parameter_double
void will_set_parameter_double(#function, #name, double value)
Store a named double precision floating point value to be returned by mock_parameter() later.
will_set_parameter_ptr_always
void will_set_parameter_ptr_always(#function, #name, void *value)
Store a named pointer value that will be always returned by mock_parameter_ptr().
will_return_always
void will_return_always(#function, uintmax_t value)
will_return_ptr
void will_return_ptr(#function, void *value)
Store a pointer value to be returned by mock_ptr_type() later.
will_return_ptr_always
void will_return_ptr_always(#function, void *value)
Store a value that will be always returned by mock_ptr_type().
will_return_int_always
void will_return_int_always(#function, intmax_t value)
Store an integer value that will always be returned by mock_int().
mock_type
type mock_type(#type)
Retrieve a value of the current function and cast it to given type.
will_set_parameter_float
void will_set_parameter_float(#function, #name, float value)
Store a named float value to be returned by mock_parameter() later.
will_set_parameter_double_always
void will_set_parameter_double_always(#function, #name, double value)
Store a named double value that will always be returned by mock_parameter_double().
has_mock
bool has_mock(void)
Check if data is available for the current mock function.
mock_parameter_float
float mock_parameter_float(#name)
Retrieve a named float value for the current function.
will_set_parameter_uint_maybe
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().
will_set_parameter_int_always
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().
will_return_maybe
void will_return_maybe(#function, uintmax_t value)
will_set_parameter_always
void will_set_parameter_always(#function, #name, uintmax_t value)
will_set_parameter_count
void will_set_parameter_count(#function, #name, uintmax_t value, int count)
will_return_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.
will_set_parameter_float_count
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.
will_return_ptr_count
void will_return_ptr_count(#function, void *value, int count)
Store a pointer value to be returned by mock_ptr_type() later.
will_set_parameter_uint_always
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().
will_set_parameter_maybe
void will_set_parameter_maybe(#function, #name, uintmax_t value)
mock_parameter_uint
uintmax_t mock_parameter_uint(#name)
Retrieve an unsigned integer return value of the current function.
will_return_uint
void will_return_uint(#function, uintmax_t value)
Store a unsigned integer value to be returned by mock() later.
will_return_float
void will_return_float(#function, float value)
Store a float value to be returned by mock() later.
will_set_errno
void will_set_errno(#function, intmax_t value)
Store an integer value to set errno to by mock_errno() later.
will_return_float_count
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.
mock_ptr_type
type mock_ptr_type(#type)
Retrieve a typed return value of the current function.
will_set_parameter_ptr_count
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.
mock_float
float mock_float(void)
Retrieve a float return value of the current function.
mock
uintmax_t mock(void)
Retrieve a return value of the current function.
mock_errno
void mock_errno(void)
set errno for the current function.
mock_parameter_int
intmax_t mock_parameter_int(#name)
Retrieve a named value for the current function and cast it to given type.
will_return_double
void will_return_double(#function, double value)
Store a double precision floating point value to be returned by mock() later.
will_set_parameter_ptr_maybe
void will_set_parameter_ptr_maybe(#function, #name, void *value)
Store a named pointer value that may be always returned by mock_parameter_ptr().
will_return_ptr_maybe
void will_return_ptr_maybe(#function, void *value)
Store a value that may be always returned by mock_ptr_type().
will_set_parameter_uint_count
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...
mock_parameter_double
double mock_parameter_double(#name)
Retrieve a named double precision floating point value for the current function.
mock_ptr_type_checked
type mock_ptr_type_checked(#type)
Retrieve a typed return value of the current function with type checking.
expect_float_not_in_set
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.
expect_not_in_range_count
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...
expect_float_not_in_range_count
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...
expect_uint_not_in_range_count
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....
expect_float_not_in_set_count
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.
expect_uint_not_in_range
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...
expect_any_count
void expect_any_count(#function, #parameter, size_t count)
Add an event to repeatedly check if a parameter (of any value) has been passed.
expect_not_string
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.
check_expected_ptr
void check_expected_ptr(#parameter)
Determine whether a function parameter is correct.
expect_in_set_count
void expect_in_set_count(#function, #parameter, uintmax_t value_array[], size_t count)
expect_not_in_set_count
void expect_not_in_set_count(#function, #parameter, uintmax_t value_array[], size_t count)
check_expected
void check_expected(#parameter)
expect_not_string_count
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.
expect_in_range_count
void expect_in_range_count(#function, #parameter, uintmax_t minimum, uintmax_t maximum, size_t count)
expect_not_memory_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.
expect_int_in_set_count
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.
expect_check_data
void expect_check_data(function, parameter, CheckParameterValueData check_function, CMockaValueData check_data)
Add a custom parameter checking function using CMockaValueData (new API).
expect_in_range
void expect_in_range(#function, #parameter, uintmax_t minimum, uintmax_t maximum)
expect_float_in_set_count
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.
expect_float
void expect_float(#function, #parameter, double value, double epsilon)
Add an event to check if a parameter is the given floating point value.
expect_uint_in_range_count
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....
check_expected_float
void check_expected_float(#parameter)
Determine whether a function parameter is correct.
expect_float_in_range
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 <= ...
expect_double
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.
expect_int_not_value_count
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.
expect_string
void expect_string(#function, #parameter, const char *string)
Add an event to check if the parameter value is equal to the provided string.
expect_int_value
void expect_int_value(#function, #parameter, intmax_t value)
Add an event to check if an integer parameter is the given value.
expect_int_not_in_set
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.
expect_any_always
void expect_any_always(#function, #parameter)
Add an event to always check if a parameter (of any value) has been passed.
expect_uint_in_range
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...
expect_not_memory
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.
expect_memory_count
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.
expect_not_in_range
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 > ...
expect_float_in_range_count
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 ...
expect_int_value_count
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.
CheckParameterValue
int(* CheckParameterValue)(const uintmax_t value, const uintmax_t check_value_data)
Definition cmocka.h:6391
expect_uint_value
void expect_uint_value(#function, #parameter, uintmax_t value)
Add an event to check if an unsigned integer parameter is the given value.
expect_uint_value_count
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.
check_expected_int
void check_expected_int(#parameter)
Determine whether a function parameter is correct.
expect_int_not_in_range_count
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....
check_expected_double
void check_expected_double(#parameter)
Determine whether a function parameter is correct.
CheckIntParameterValue
int(* CheckIntParameterValue)(const intmax_t value, const intmax_t check_value_data)
Definition cmocka.h:6407
CheckParameterValueData
int(* CheckParameterValueData)(const CMockaValueData value, const CMockaValueData check_value_data)
Definition cmocka.h:6399
expect_not_value
void expect_not_value(#function, #parameter, uintmax_t value)
expect_memory
void expect_memory(#function, #parameter, void *memory, size_t size)
Add an event to check if the parameter does match an area of memory.
expect_int_in_range
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...
expect_not_float
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.
check_expected_uint
void check_expected_uint(#parameter)
Determine whether a function parameter is correct.
expect_uint_not_value_count
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.
expect_uint_not_in_set_count
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...
expect_check_data_count
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).
expect_any
void expect_any(#function, #parameter)
Add an event to check if a parameter (of any value) has been passed.
expect_check_count
void expect_check_count(function, parameter, CheckParameterValue check_function, const void *check_data, size_t count)
expect_int_in_range_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....
expect_float_in_set
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.
expect_not_in_set
void expect_not_in_set(#function, #parameter, uintmax_t value_array[])
expect_float_not_in_range
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 > ...
expect_float_count
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.
CheckUintParameterValue
int(* CheckUintParameterValue)(const uintmax_t value, const uintmax_t check_value_data)
Definition cmocka.h:6415
check_expected_any
void check_expected_any(#parameter)
Check that any parameter value matches the next value in the queue.
expect_value
void expect_value(#function, #parameter, uintmax_t value)
expect_double_count
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.
expect_uint_in_set_count
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.
expect_check
void expect_check(function, parameter, CheckParameterValue check_function, const void *check_data)
expect_string_count
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.
expect_not_double_count
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.
expect_not_float_count
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.
expect_not_double
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.
expect_uint_not_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.
expect_int_not_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.
expect_value_count
void expect_value_count(#function, #parameter, uintmax_t value, size_t count)
expect_not_value_count
void expect_not_value_count(#function, #parameter, uintmax_t value, size_t count)
expect_in_set
void expect_in_set(#function, #parameter, uintmax_t value_array[])
expect_uint_not_in_set
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...
expect_int_not_in_range
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...
expect_int_not_in_set_count
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.
CMCallbacks
Definition cmocka.h:6539
CMCallbacks::vprint_message
void(* vprint_message)(const char *const format, va_list args)
Definition cmocka.h:6547
CMCallbacks::vprint_error
void(* vprint_error)(const char *const format, va_list args)
Definition cmocka.h:6556
CMUnitTest
Definition cmocka.h:6471
CheckParameterEventData
Definition cmocka.h:6506
CheckParameterEvent
Definition cmocka.h:6494
GroupTest
Definition cmocka.h:6447
SourceLocation
Definition cmocka.h:6484
UnitTest
Definition cmocka.h:6438
CMockaValueData
Definition cmocka.h:6338
CMockaValueData::real_val
double real_val
Definition cmocka.h:6346
CMockaValueData::float_val
float float_val
Definition cmocka.h:6344
CMockaValueData::int_val
intmax_t int_val
Definition cmocka.h:6340
CMockaValueData::uint_val
uintmax_t uint_val
Definition cmocka.h:6342
CMockaValueData::ptr
const void * ptr
Definition cmocka.h:6348