cmocka  0.4.1
cmocka.h
1 /*
2  * Copyright 2008 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef CMOCKA_H_
17 #define CMOCKA_H_
18 
19 #ifdef _WIN32
20 # ifdef _MSC_VER
21 
22 # ifndef inline
23 #define inline __inline
24 # endif /* inline */
25 
26 # if _MSC_VER < 1500
27 # ifdef __cplusplus
28 extern "C" {
29 # endif /* __cplusplus */
30 int __stdcall IsDebuggerPresent();
31 # ifdef __cplusplus
32 } /* extern "C" */
33 # endif /* __cplusplus */
34 # endif /* _MSC_VER < 1500 */
35 # endif /* _MSC_VER */
36 #endif /* _WIN32 */
37 
38 /*
39  * These headers or their equivalents should be included prior to including
40  * this header file.
41  *
42  * #include <stdarg.h>
43  * #include <stddef.h>
44  * #include <setjmp.h>
45  *
46  * This allows test applications to use custom definitions of C standard
47  * library functions and types.
48  */
49 
50 /* For those who are used to __func__ from gcc. */
51 #ifndef __func__
52 #define __func__ __FUNCTION__
53 #endif
54 
55 /* GCC have printf type attribute check. */
56 #ifdef __GNUC__
57 #define CMOCKA_PRINTF_ATTRIBUTE(a,b) \
58  __attribute__ ((__format__ (__printf__, a, b)))
59 #else
60 #define CMOCKA_PRINTF_ATTRIBUTE(a,b)
61 #endif /* __GNUC__ */
62 
71 /*
72  * Largest integral type. This type should be large enough to hold any
73  * pointer or integer supported by the compiler.
74  */
75 #ifndef LargestIntegralType
76 #define LargestIntegralType unsigned long long
77 #endif /* LargestIntegralType */
78 
79 /* Printf format used to display LargestIntegralType. */
80 #ifndef LargestIntegralTypePrintfFormat
81 #ifdef _WIN32
82 #define LargestIntegralTypePrintfFormat "0x%I64x"
83 #else
84 #define LargestIntegralTypePrintfFormat "%#llx"
85 #endif /* _WIN32 */
86 #endif /* LargestIntegralTypePrintfFormat */
87 
88 /* Perform an unsigned cast to LargestIntegralType. */
89 #define cast_to_largest_integral_type(value) \
90  ((LargestIntegralType)((size_t)(value)))
91 
92 /* Smallest integral type capable of holding a pointer. */
93 #if !defined(_UINTPTR_T) && !defined(_UINTPTR_T_DEFINED)
94 # if defined(_WIN32)
95  /* WIN32 is an ILP32 platform */
96  typedef unsigned int uintptr_t;
97 # elif defined(_WIN64)
98  typedef unsigned long int uintptr_t
99 # else /* _WIN32 */
100 
101 /* ILP32 and LP64 platforms */
102 # ifdef __WORDSIZE /* glibc */
103 # if __WORDSIZE == 64
104  typedef unsigned long int uintptr_t;
105 # else
106  typedef unsigned int uintptr_t;
107 # endif /* __WORDSIZE == 64 */
108 # else /* __WORDSIZE */
109 # if defined(_LP64) || defined(_I32LPx)
110  typedef unsigned long int uintptr_t;
111 # else
112  typedef unsigned int uintptr_t;
113 # endif
114 # endif /* __WORDSIZE */
115 # endif /* _WIN32 */
116 
117 # define _UINTPTR_T
118 # define _UINTPTR_T_DEFINED
119 #endif /* !defined(_UINTPTR_T) || !defined(_UINTPTR_T_DEFINED) */
120 
121 /* Perform an unsigned cast to uintptr_t. */
122 #define cast_to_pointer_integral_type(value) \
123  ((uintptr_t)(value))
124 
125 /* Perform a cast of a pointer to uintmax_t */
126 #define cast_ptr_to_largest_integral_type(value) \
127 cast_to_largest_integral_type(cast_to_pointer_integral_type(value))
128 
177 #ifdef DOXYGEN
178 
185 void *mock(void);
186 #else
187 #define mock() _mock(__func__, __FILE__, __LINE__)
188 #endif
189 
190 #ifdef DOXYGEN
191 
211 void *mock_type(#type);
212 #else
213 #define mock_type(type) ((type) mock())
214 #endif
215 
216 #ifdef DOXYGEN
217 
238 void *mock_ptr_type(#type);
239 #else
240 #define mock_ptr_type(type) ((type) (uintptr_t) mock())
241 #endif
242 
243 
244 #ifdef DOXYGEN
245 
269 void will_return(#function, void *value);
270 #else
271 #define will_return(function, value) \
272  _will_return(#function, __FILE__, __LINE__, \
273  cast_to_largest_integral_type(value), 1)
274 #endif
275 
276 #ifdef DOXYGEN
277 
290 void will_return_count(#function, void *value, int count);
291 #else
292 #define will_return_count(function, value, count) \
293  _will_return(#function, __FILE__, __LINE__, \
294  cast_to_largest_integral_type(value), count)
295 #endif
296 
297 #ifdef DOXYGEN
298 
313 void will_return_always(#function, void *value);
314 #else
315 #define will_return_always(function, value) \
316  will_return_count(function, (value), -1)
317 #endif
318 
365 /*
366  * Add a custom parameter checking function. If the event parameter is NULL
367  * the event structure is allocated internally by this function. If event
368  * parameter is provided it must be allocated on the heap and doesn't need to
369  * be deallocated by the caller.
370  */
371 #ifdef DOXYGEN
372 
388 void expect_check(#function, #parameter, #check_function, const void *check_data);
389 #else
390 #define expect_check(function, parameter, check_function, check_data) \
391  _expect_check(#function, #parameter, __FILE__, __LINE__, check_function, \
392  cast_to_largest_integral_type(check_data), NULL, 1)
393 #endif
394 
395 #ifdef DOXYGEN
396 
410 void expect_in_set(#function, #parameter, uintmax_t value_array[]);
411 #else
412 #define expect_in_set(function, parameter, value_array) \
413  expect_in_set_count(function, parameter, value_array, 1)
414 #endif
415 
416 #ifdef DOXYGEN
417 
435 void expect_in_set_count(#function, #parameter, uintmax_t value_array[], size_t count);
436 #else
437 #define expect_in_set_count(function, parameter, value_array, count) \
438  _expect_in_set(#function, #parameter, __FILE__, __LINE__, value_array, \
439  sizeof(value_array) / sizeof((value_array)[0]), count)
440 #endif
441 
442 #ifdef DOXYGEN
443 
457 void expect_not_in_set(#function, #parameter, uintmax_t value_array[]);
458 #else
459 #define expect_not_in_set(function, parameter, value_array) \
460  expect_not_in_set_count(function, parameter, value_array, 1)
461 #endif
462 
463 #ifdef DOXYGEN
464 
482 void expect_not_in_set_count(#function, #parameter, uintmax_t value_array[], size_t count);
483 #else
484 #define expect_not_in_set_count(function, parameter, value_array, count) \
485  _expect_not_in_set( \
486  #function, #parameter, __FILE__, __LINE__, value_array, \
487  sizeof(value_array) / sizeof((value_array)[0]), count)
488 #endif
489 
490 
491 #ifdef DOXYGEN
492 
508 void expect_in_range(#function, #parameter, uintmax_t minimum, uintmax_t maximum);
509 #else
510 #define expect_in_range(function, parameter, minimum, maximum) \
511  expect_in_range_count(function, parameter, minimum, maximum, 1)
512 #endif
513 
514 #ifdef DOXYGEN
515 
535 void expect_in_range_count(#function, #parameter, uintmax_t minimum, uintmax_t maximum, size_t count);
536 #else
537 #define expect_in_range_count(function, parameter, minimum, maximum, count) \
538  _expect_in_range(#function, #parameter, __FILE__, __LINE__, minimum, \
539  maximum, count)
540 #endif
541 
542 #ifdef DOXYGEN
543 
559 void expect_not_in_range(#function, #parameter, uintmax_t minimum, uintmax_t maximum);
560 #else
561 #define expect_not_in_range(function, parameter, minimum, maximum) \
562  expect_not_in_range_count(function, parameter, minimum, maximum, 1)
563 #endif
564 
565 #ifdef DOXYGEN
566 
586 void expect_not_in_range_count(#function, #parameter, uintmax_t minimum, uintmax_t maximum, size_t count);
587 #else
588 #define expect_not_in_range_count(function, parameter, minimum, maximum, \
589  count) \
590  _expect_not_in_range(#function, #parameter, __FILE__, __LINE__, \
591  minimum, maximum, count)
592 #endif
593 
594 #ifdef DOXYGEN
595 
608 void expect_value(#function, #parameter, uintmax_t value);
609 #else
610 #define expect_value(function, parameter, value) \
611  expect_value_count(function, parameter, value, 1)
612 #endif
613 
614 #ifdef DOXYGEN
615 
632 void expect_value_count(#function, #parameter, uintmax_t value, size_t count);
633 #else
634 #define expect_value_count(function, parameter, value, count) \
635  _expect_value(#function, #parameter, __FILE__, __LINE__, \
636  cast_to_largest_integral_type(value), count)
637 #endif
638 
639 #ifdef DOXYGEN
640 
653 void expect_not_value(#function, #parameter, uintmax_t value);
654 #else
655 #define expect_not_value(function, parameter, value) \
656  expect_not_value_count(function, parameter, value, 1)
657 #endif
658 
659 #ifdef DOXYGEN
660 
677 void expect_not_value_count(#function, #parameter, uintmax_t value, size_t count);
678 #else
679 #define expect_not_value_count(function, parameter, value, count) \
680  _expect_not_value(#function, #parameter, __FILE__, __LINE__, \
681  cast_to_largest_integral_type(value), count)
682 #endif
683 
684 #ifdef DOXYGEN
685 
699 void expect_string(#function, #parameter, const char *string);
700 #else
701 #define expect_string(function, parameter, string) \
702  expect_string_count(function, parameter, string, 1)
703 #endif
704 
705 #ifdef DOXYGEN
706 
724 void expect_string_count(#function, #parameter, const char *string, size_t count);
725 #else
726 #define expect_string_count(function, parameter, string, count) \
727  _expect_string(#function, #parameter, __FILE__, __LINE__, \
728  (const char*)(string), count)
729 #endif
730 
731 #ifdef DOXYGEN
732 
746 void expect_not_string(#function, #parameter, const char *string);
747 #else
748 #define expect_not_string(function, parameter, string) \
749  expect_not_string_count(function, parameter, string, 1)
750 #endif
751 
752 #ifdef DOXYGEN
753 
771 void expect_not_string_count(#function, #parameter, const char *string, size_t count);
772 #else
773 #define expect_not_string_count(function, parameter, string, count) \
774  _expect_not_string(#function, #parameter, __FILE__, __LINE__, \
775  (const char*)(string), count)
776 #endif
777 
778 #ifdef DOXYGEN
779 
794 void expect_memory(#function, #parameter, void *memory, size_t size);
795 #else
796 #define expect_memory(function, parameter, memory, size) \
797  expect_memory_count(function, parameter, memory, size, 1)
798 #endif
799 
800 #ifdef DOXYGEN
801 
821 void expect_memory_count(#function, #parameter, void *memory, size_t size, size_t count);
822 #else
823 #define expect_memory_count(function, parameter, memory, size, count) \
824  _expect_memory(#function, #parameter, __FILE__, __LINE__, \
825  (const void*)(memory), size, count)
826 #endif
827 
828 #ifdef DOXYGEN
829 
845 void expect_not_memory(#function, #parameter, void *memory, size_t size);
846 #else
847 #define expect_not_memory(function, parameter, memory, size) \
848  expect_not_memory_count(function, parameter, memory, size, 1)
849 #endif
850 
851 #ifdef DOXYGEN
852 
872 void expect_not_memory_count(#function, #parameter, void *memory, size_t size, size_t count);
873 #else
874 #define expect_not_memory_count(function, parameter, memory, size, count) \
875  _expect_not_memory(#function, #parameter, __FILE__, __LINE__, \
876  (const void*)(memory), size, count)
877 #endif
878 
879 
880 #ifdef DOXYGEN
881 
892 void expect_any(#function, #parameter);
893 #else
894 #define expect_any(function, parameter) \
895  expect_any_count(function, parameter, 1)
896 #endif
897 
898 #ifdef DOXYGEN
899 
915 void expect_any_count(#function, #parameter, size_t count);
916 #else
917 #define expect_any_count(function, parameter, count) \
918  _expect_any(#function, #parameter, __FILE__, __LINE__, count)
919 #endif
920 
921 #ifdef DOXYGEN
922 
932 void check_expected(#parameter);
933 #else
934 #define check_expected(parameter) \
935  _check_expected(__func__, #parameter, __FILE__, __LINE__, \
936  cast_to_largest_integral_type(parameter))
937 #endif
938 
960 #ifdef DOXYGEN
961 
973 void assert_true(scalar expression);
974 #else
975 #define assert_true(c) _assert_true(cast_to_largest_integral_type(c), #c, \
976  __FILE__, __LINE__)
977 #endif
978 
979 #ifdef DOXYGEN
980 
991 void assert_false(scalar expression);
992 #else
993 #define assert_false(c) _assert_true(!(cast_to_largest_integral_type(c)), #c, \
994  __FILE__, __LINE__)
995 #endif
996 
997 #ifdef DOXYGEN
998 
1010 void assert_return_code(int rc, int error);
1011 #else
1012 #define assert_return_code(rc, error) \
1013  _assert_return_code(cast_to_largest_integral_type(rc), \
1014  sizeof(rc), \
1015  cast_to_largest_integral_type(error), \
1016  #rc, __FILE__, __LINE__)
1017 #endif
1018 
1019 #ifdef DOXYGEN
1020 
1030 void assert_non_null(void *pointer);
1031 #else
1032 #define assert_non_null(c) _assert_true(cast_ptr_to_largest_integral_type(c), #c, \
1033  __FILE__, __LINE__)
1034 #endif
1035 
1036 #ifdef DOXYGEN
1037 
1047 void assert_null(void *pointer);
1048 #else
1049 #define assert_null(c) _assert_true(!(cast_ptr_to_largest_integral_type(c)), #c, \
1050 __FILE__, __LINE__)
1051 #endif
1052 
1053 #ifdef DOXYGEN
1054 
1064 void assert_int_equal(int a, int b);
1065 #else
1066 #define assert_int_equal(a, b) \
1067  _assert_int_equal(cast_to_largest_integral_type(a), \
1068  cast_to_largest_integral_type(b), \
1069  __FILE__, __LINE__)
1070 #endif
1071 
1072 #ifdef DOXYGEN
1073 
1085 void assert_int_not_equal(int a, int b);
1086 #else
1087 #define assert_int_not_equal(a, b) \
1088  _assert_int_not_equal(cast_to_largest_integral_type(a), \
1089  cast_to_largest_integral_type(b), \
1090  __FILE__, __LINE__)
1091 #endif
1092 
1093 #ifdef DOXYGEN
1094 
1104 void assert_string_equal(const char *a, const char *b);
1105 #else
1106 #define assert_string_equal(a, b) \
1107  _assert_string_equal((const char*)(a), (const char*)(b), __FILE__, \
1108  __LINE__)
1109 #endif
1110 
1111 #ifdef DOXYGEN
1112 
1122 void assert_string_not_equal(const char *a, const char *b);
1123 #else
1124 #define assert_string_not_equal(a, b) \
1125  _assert_string_not_equal((const char*)(a), (const char*)(b), __FILE__, \
1126  __LINE__)
1127 #endif
1128 
1129 #ifdef DOXYGEN
1130 
1144 void assert_memory_equal(const void *a, const void *b, size_t size);
1145 #else
1146 #define assert_memory_equal(a, b, size) \
1147  _assert_memory_equal((const void*)(a), (const void*)(b), size, __FILE__, \
1148  __LINE__)
1149 #endif
1150 
1151 #ifdef DOXYGEN
1152 
1166 void assert_memory_not_equal(const void *a, const void *b, size_t size);
1167 #else
1168 #define assert_memory_not_equal(a, b, size) \
1169  _assert_memory_not_equal((const void*)(a), (const void*)(b), size, \
1170  __FILE__, __LINE__)
1171 #endif
1172 
1173 #ifdef DOXYGEN
1174 
1187 void assert_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum);
1188 #else
1189 #define assert_in_range(value, minimum, maximum) \
1190  _assert_in_range( \
1191  cast_to_largest_integral_type(value), \
1192  cast_to_largest_integral_type(minimum), \
1193  cast_to_largest_integral_type(maximum), __FILE__, __LINE__)
1194 #endif
1195 
1196 #ifdef DOXYGEN
1197 
1210 void assert_not_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum);
1211 #else
1212 #define assert_not_in_range(value, minimum, maximum) \
1213  _assert_not_in_range( \
1214  cast_to_largest_integral_type(value), \
1215  cast_to_largest_integral_type(minimum), \
1216  cast_to_largest_integral_type(maximum), __FILE__, __LINE__)
1217 #endif
1218 
1219 #ifdef DOXYGEN
1220 
1232 void assert_in_set(uintmax_t value, uintmax_t values[], size_t count);
1233 #else
1234 #define assert_in_set(value, values, number_of_values) \
1235  _assert_in_set(value, values, number_of_values, __FILE__, __LINE__)
1236 #endif
1237 
1238 #ifdef DOXYGEN
1239 
1251 void assert_not_in_set(uintmax_t value, uintmax_t values[], size_t count);
1252 #else
1253 #define assert_not_in_set(value, values, number_of_values) \
1254  _assert_not_in_set(value, values, number_of_values, __FILE__, __LINE__)
1255 #endif
1256 
1285 #ifdef DOXYGEN
1286 
1289 void fail(void);
1290 #else
1291 #define fail() _fail(__FILE__, __LINE__)
1292 #endif
1293 
1294 #ifdef DOXYGEN
1295 
1309 void fail_msg(const char *msg, ...);
1310 #else
1311 #define fail_msg(msg, ...) do { \
1312  print_error("ERROR: " msg "\n", ##__VA_ARGS__); \
1313  fail(); \
1314 } while (0)
1315 #endif
1316 
1317 #ifdef DOXYGEN
1318 
1335 int run_test(#function);
1336 #else
1337 #define run_test(f) _run_test(#f, f, NULL, UNIT_TEST_FUNCTION_TYPE_TEST, NULL)
1338 #endif
1339 
1340 static inline void _unit_test_dummy(void **state) {
1341  (void)state;
1342 }
1343 
1345 #define unit_test(f) { #f, f, UNIT_TEST_FUNCTION_TYPE_TEST }
1346 
1347 #define _unit_test_setup(test, setup) \
1348  { #test "_" #setup, setup, UNIT_TEST_FUNCTION_TYPE_SETUP }
1349 
1351 #define unit_test_setup(test, setup) \
1352  _unit_test_setup(test, setup), \
1353  unit_test(test), \
1354  _unit_test_teardown(test, _unit_test_dummy)
1355 
1356 #define _unit_test_teardown(test, teardown) \
1357  { #test "_" #teardown, teardown, UNIT_TEST_FUNCTION_TYPE_TEARDOWN }
1358 
1360 #define unit_test_teardown(test, teardown) \
1361  _unit_test_setup(test, _unit_test_dummy), \
1362  unit_test(test), \
1363  _unit_test_teardown(test, teardown)
1364 
1366 #define group_test_setup(setup) \
1367  { "group_" #setup, setup, UNIT_TEST_FUNCTION_TYPE_GROUP_SETUP }
1368 
1370 #define group_test_teardown(teardown) \
1371  { "group_" #teardown, teardown, UNIT_TEST_FUNCTION_TYPE_GROUP_TEARDOWN }
1372 
1377 #define unit_test_setup_teardown(test, setup, teardown) \
1378  _unit_test_setup(test, setup), \
1379  unit_test(test), \
1380  _unit_test_teardown(test, teardown)
1381 
1382 #ifdef DOXYGEN
1383 
1428 int run_tests(const UnitTest tests[]);
1429 #else
1430 #define run_tests(tests) _run_tests(tests, sizeof(tests) / sizeof(tests)[0])
1431 #endif
1432 
1433 #define run_group_tests(tests) _run_group_tests(tests, sizeof(tests) / sizeof(tests)[0])
1434 
1460 #ifdef DOXYGEN
1461 
1483 void *test_malloc(size_t size);
1484 #else
1485 #define test_malloc(size) _test_malloc(size, __FILE__, __LINE__)
1486 #endif
1487 
1488 #ifdef DOXYGEN
1489 
1502 void *test_calloc(size_t nmemb, size_t size);
1503 #else
1504 #define test_calloc(num, size) _test_calloc(num, size, __FILE__, __LINE__)
1505 #endif
1506 
1507 #ifdef DOXYGEN
1508 
1515 void test_free(void *ptr);
1516 #else
1517 #define test_free(ptr) _test_free(ptr, __FILE__, __LINE__)
1518 #endif
1519 
1520 /* Redirect malloc, calloc and free to the unit test allocators. */
1521 #ifdef UNIT_TESTING
1522 #define malloc test_malloc
1523 #define calloc test_calloc
1524 #define free test_free
1525 #endif /* UNIT_TESTING */
1526 
1580 void mock_assert(const int result, const char* const expression,
1581  const char * const file, const int line);
1582 
1583 #ifdef DOXYGEN
1584 
1606 void expect_assert_failure(function fn_call);
1607 #else
1608 #define expect_assert_failure(function_call) \
1609  { \
1610  const int result = setjmp(global_expect_assert_env); \
1611  global_expecting_assert = 1; \
1612  if (result) { \
1613  print_message("Expected assertion %s occurred\n", \
1614  global_last_failed_assert); \
1615  global_expecting_assert = 0; \
1616  } else { \
1617  function_call ; \
1618  global_expecting_assert = 0; \
1619  print_error("Expected assert in %s\n", #function_call); \
1620  _fail(__FILE__, __LINE__); \
1621  } \
1622  }
1623 #endif
1624 
1627 /* Function prototype for setup, test and teardown functions. */
1628 typedef void (*UnitTestFunction)(void **state);
1629 
1630 /* Function that determines whether a function parameter value is correct. */
1631 typedef int (*CheckParameterValue)(const LargestIntegralType value,
1632  const LargestIntegralType check_value_data);
1633 
1634 /* Type of the unit test function. */
1635 typedef enum UnitTestFunctionType {
1636  UNIT_TEST_FUNCTION_TYPE_TEST = 0,
1637  UNIT_TEST_FUNCTION_TYPE_SETUP,
1638  UNIT_TEST_FUNCTION_TYPE_TEARDOWN,
1639  UNIT_TEST_FUNCTION_TYPE_GROUP_SETUP,
1640  UNIT_TEST_FUNCTION_TYPE_GROUP_TEARDOWN,
1641 } UnitTestFunctionType;
1642 
1643 /*
1644  * Stores a unit test function with its name and type.
1645  * NOTE: Every setup function must be paired with a teardown function. It's
1646  * possible to specify NULL function pointers.
1647  */
1648 typedef struct UnitTest {
1649  const char* name;
1650  UnitTestFunction function;
1651  UnitTestFunctionType function_type;
1652 } UnitTest;
1653 
1654 typedef struct GroupTest {
1655  UnitTestFunction setup;
1656  UnitTestFunction teardown;
1657  const UnitTest *tests;
1658  const size_t number_of_tests;
1659 } GroupTest;
1660 
1661 /* Location within some source code. */
1662 typedef struct SourceLocation {
1663  const char* file;
1664  int line;
1665 } SourceLocation;
1666 
1667 /* Event that's called to check a parameter value. */
1668 typedef struct CheckParameterEvent {
1669  SourceLocation location;
1670  const char *parameter_name;
1671  CheckParameterValue check_value;
1672  LargestIntegralType check_value_data;
1673 } CheckParameterEvent;
1674 
1675 /* Used by expect_assert_failure() and mock_assert(). */
1676 extern int global_expecting_assert;
1677 extern jmp_buf global_expect_assert_env;
1678 extern const char * global_last_failed_assert;
1679 
1680 /* Retrieves a value for the given function, as set by "will_return". */
1681 LargestIntegralType _mock(const char * const function, const char* const file,
1682  const int line);
1683 
1684 void _expect_check(
1685  const char* const function, const char* const parameter,
1686  const char* const file, const int line,
1687  const CheckParameterValue check_function,
1688  const LargestIntegralType check_data, CheckParameterEvent * const event,
1689  const int count);
1690 
1691 void _expect_in_set(
1692  const char* const function, const char* const parameter,
1693  const char* const file, const int line, const LargestIntegralType values[],
1694  const size_t number_of_values, const int count);
1695 void _expect_not_in_set(
1696  const char* const function, const char* const parameter,
1697  const char* const file, const int line, const LargestIntegralType values[],
1698  const size_t number_of_values, const int count);
1699 
1700 void _expect_in_range(
1701  const char* const function, const char* const parameter,
1702  const char* const file, const int line,
1703  const LargestIntegralType minimum,
1704  const LargestIntegralType maximum, const int count);
1705 void _expect_not_in_range(
1706  const char* const function, const char* const parameter,
1707  const char* const file, const int line,
1708  const LargestIntegralType minimum,
1709  const LargestIntegralType maximum, const int count);
1710 
1711 void _expect_value(
1712  const char* const function, const char* const parameter,
1713  const char* const file, const int line, const LargestIntegralType value,
1714  const int count);
1715 void _expect_not_value(
1716  const char* const function, const char* const parameter,
1717  const char* const file, const int line, const LargestIntegralType value,
1718  const int count);
1719 
1720 void _expect_string(
1721  const char* const function, const char* const parameter,
1722  const char* const file, const int line, const char* string,
1723  const int count);
1724 void _expect_not_string(
1725  const char* const function, const char* const parameter,
1726  const char* const file, const int line, const char* string,
1727  const int count);
1728 
1729 void _expect_memory(
1730  const char* const function, const char* const parameter,
1731  const char* const file, const int line, const void* const memory,
1732  const size_t size, const int count);
1733 void _expect_not_memory(
1734  const char* const function, const char* const parameter,
1735  const char* const file, const int line, const void* const memory,
1736  const size_t size, const int count);
1737 
1738 void _expect_any(
1739  const char* const function, const char* const parameter,
1740  const char* const file, const int line, const int count);
1741 
1742 void _check_expected(
1743  const char * const function_name, const char * const parameter_name,
1744  const char* file, const int line, const LargestIntegralType value);
1745 
1746 void _will_return(const char * const function_name, const char * const file,
1747  const int line, const LargestIntegralType value,
1748  const int count);
1749 void _assert_true(const LargestIntegralType result,
1750  const char* const expression,
1751  const char * const file, const int line);
1752 void _assert_return_code(const LargestIntegralType result,
1753  size_t rlen,
1754  const LargestIntegralType error,
1755  const char * const expression,
1756  const char * const file,
1757  const int line);
1758 void _assert_int_equal(
1759  const LargestIntegralType a, const LargestIntegralType b,
1760  const char * const file, const int line);
1761 void _assert_int_not_equal(
1762  const LargestIntegralType a, const LargestIntegralType b,
1763  const char * const file, const int line);
1764 void _assert_string_equal(const char * const a, const char * const b,
1765  const char * const file, const int line);
1766 void _assert_string_not_equal(const char * const a, const char * const b,
1767  const char *file, const int line);
1768 void _assert_memory_equal(const void * const a, const void * const b,
1769  const size_t size, const char* const file,
1770  const int line);
1771 void _assert_memory_not_equal(const void * const a, const void * const b,
1772  const size_t size, const char* const file,
1773  const int line);
1774 void _assert_in_range(
1775  const LargestIntegralType value, const LargestIntegralType minimum,
1776  const LargestIntegralType maximum, const char* const file, const int line);
1777 void _assert_not_in_range(
1778  const LargestIntegralType value, const LargestIntegralType minimum,
1779  const LargestIntegralType maximum, const char* const file, const int line);
1780 void _assert_in_set(
1781  const LargestIntegralType value, const LargestIntegralType values[],
1782  const size_t number_of_values, const char* const file, const int line);
1783 void _assert_not_in_set(
1784  const LargestIntegralType value, const LargestIntegralType values[],
1785  const size_t number_of_values, const char* const file, const int line);
1786 
1787 void* _test_malloc(const size_t size, const char* file, const int line);
1788 void* _test_calloc(const size_t number_of_elements, const size_t size,
1789  const char* file, const int line);
1790 void _test_free(void* const ptr, const char* file, const int line);
1791 
1792 void _fail(const char * const file, const int line);
1793 int _run_test(
1794  const char * const function_name, const UnitTestFunction Function,
1795  void ** const volatile state, const UnitTestFunctionType function_type,
1796  const void* const heap_check_point);
1797 int _run_tests(const UnitTest * const tests, const size_t number_of_tests);
1798 int _run_group_tests(const UnitTest * const tests,
1799  const size_t number_of_tests);
1800 
1801 /* Standard output and error print methods. */
1802 void print_message(const char* const format, ...) CMOCKA_PRINTF_ATTRIBUTE(1, 2);
1803 void print_error(const char* const format, ...) CMOCKA_PRINTF_ATTRIBUTE(1, 2);
1804 void vprint_message(const char* const format, va_list args) CMOCKA_PRINTF_ATTRIBUTE(1, 0);
1805 void vprint_error(const char* const format, va_list args) CMOCKA_PRINTF_ATTRIBUTE(1, 0);
1806 
1809 #endif /* CMOCKA_H_ */