Added
Link Here
|
1 |
Patch-Source: https://gitlab.com/cmocka/cmocka/-/commit/0e70150002ab7bcb626109b287f23c62ecf97565 |
2 |
-- |
3 |
From 0e70150002ab7bcb626109b287f23c62ecf97565 Mon Sep 17 00:00:00 2001 |
4 |
From: Andreas Schneider <asn@cryptomilk.org> |
5 |
Date: Mon, 5 Oct 2020 13:28:11 +0200 |
6 |
Subject: [PATCH] cmocka: Replace LargestIntegralType with uintmax_t |
7 |
|
8 |
This requires #include <stdint.h> |
9 |
|
10 |
Fixes #38 |
11 |
Fixes #49 |
12 |
--- |
13 |
example/allocate_module_test.c | 1 + |
14 |
example/assert_macro_test.c | 1 + |
15 |
example/assert_module_test.c | 1 + |
16 |
example/calculator_test.c | 1 + |
17 |
example/mock/chef_wrap/chef.c | 1 + |
18 |
example/mock/chef_wrap/waiter_test_wrap.c | 1 + |
19 |
include/cmocka.h | 162 ++++++++-------------- |
20 |
src/cmocka.c | 148 ++++++++++---------- |
21 |
tests/test_alloc.c | 1 + |
22 |
tests/test_assert_macros.c | 1 + |
23 |
tests/test_assert_macros_fail.c | 1 + |
24 |
tests/test_basics.c | 1 + |
25 |
tests/test_cmockery.c | 1 + |
26 |
tests/test_double_macros.c | 1 + |
27 |
tests/test_exception_handler.c | 1 + |
28 |
tests/test_fixtures.c | 1 + |
29 |
tests/test_float_macros.c | 1 + |
30 |
tests/test_group_fixtures.c | 1 + |
31 |
tests/test_group_setup_assert.c | 1 + |
32 |
tests/test_group_setup_fail.c | 1 + |
33 |
tests/test_groups.c | 1 + |
34 |
tests/test_ordering.c | 1 + |
35 |
tests/test_ordering_fail.c | 1 + |
36 |
tests/test_returns.c | 1 + |
37 |
tests/test_returns_fail.c | 1 + |
38 |
tests/test_setup_fail.c | 1 + |
39 |
tests/test_skip.c | 1 + |
40 |
tests/test_skip_filter.c | 1 + |
41 |
tests/test_strmatch.c | 1 + |
42 |
tests/test_wildcard.c | 1 + |
43 |
30 files changed, 156 insertions(+), 182 deletions(-) |
44 |
|
45 |
diff --git a/example/allocate_module_test.c b/example/allocate_module_test.c |
46 |
index 562aea2..eb3602f 100644 |
47 |
--- example/allocate_module_test.c |
48 |
+++ example/allocate_module_test.c |
49 |
@@ -16,6 +16,7 @@ |
50 |
#include <stdarg.h> |
51 |
#include <stddef.h> |
52 |
#include <setjmp.h> |
53 |
+#include <stdint.h> |
54 |
#include <cmocka.h> |
55 |
|
56 |
extern void leak_memory(void); |
57 |
diff --git a/example/assert_macro_test.c b/example/assert_macro_test.c |
58 |
index 2cd355c..093a884 100644 |
59 |
--- example/assert_macro_test.c |
60 |
+++ example/assert_macro_test.c |
61 |
@@ -16,6 +16,7 @@ |
62 |
#include <stdarg.h> |
63 |
#include <stddef.h> |
64 |
#include <setjmp.h> |
65 |
+#include <stdint.h> |
66 |
#include <cmocka.h> |
67 |
|
68 |
#include "assert_macro.h" |
69 |
diff --git a/example/assert_module_test.c b/example/assert_module_test.c |
70 |
index f387754..41b5a75 100644 |
71 |
--- example/assert_module_test.c |
72 |
+++ example/assert_module_test.c |
73 |
@@ -16,6 +16,7 @@ |
74 |
#include <stdarg.h> |
75 |
#include <stddef.h> |
76 |
#include <setjmp.h> |
77 |
+#include <stdint.h> |
78 |
#include <cmocka.h> |
79 |
|
80 |
#include "assert_module.h" |
81 |
diff --git a/example/calculator_test.c b/example/calculator_test.c |
82 |
index ab8cad8..a3d862a 100644 |
83 |
--- example/calculator_test.c |
84 |
+++ example/calculator_test.c |
85 |
@@ -16,6 +16,7 @@ |
86 |
#include <stdarg.h> |
87 |
#include <stddef.h> |
88 |
#include <setjmp.h> |
89 |
+#include <stdint.h> |
90 |
#include "cmocka.h" |
91 |
#include <stdio.h> |
92 |
|
93 |
diff --git a/example/mock/chef_wrap/chef.c b/example/mock/chef_wrap/chef.c |
94 |
index 1429cde..1c74125 100644 |
95 |
--- example/mock/chef_wrap/chef.c |
96 |
+++ example/mock/chef_wrap/chef.c |
97 |
@@ -18,6 +18,7 @@ |
98 |
#include <stdarg.h> |
99 |
#include <stddef.h> |
100 |
#include <setjmp.h> |
101 |
+#include <stdint.h> |
102 |
#include <cmocka.h> |
103 |
#include <stdio.h> |
104 |
#include <errno.h> |
105 |
diff --git a/example/mock/chef_wrap/waiter_test_wrap.c b/example/mock/chef_wrap/waiter_test_wrap.c |
106 |
index 4146818..04fe721 100644 |
107 |
--- example/mock/chef_wrap/waiter_test_wrap.c |
108 |
+++ example/mock/chef_wrap/waiter_test_wrap.c |
109 |
@@ -24,6 +24,7 @@ |
110 |
#include <stdarg.h> |
111 |
#include <stddef.h> |
112 |
#include <setjmp.h> |
113 |
+#include <stdint.h> |
114 |
#include <cmocka.h> |
115 |
|
116 |
#include "waiter_test_wrap.h" |
117 |
diff --git a/include/cmocka.h b/include/cmocka.h |
118 |
index a21d965..6f56520 100644 |
119 |
--- include/cmocka.h |
120 |
+++ include/cmocka.h |
121 |
@@ -57,32 +57,13 @@ int __stdcall IsDebuggerPresent(); |
122 |
* @{ |
123 |
*/ |
124 |
|
125 |
-/* If __WORDSIZE is not set, try to figure it out and default to 32 bit. */ |
126 |
-#ifndef __WORDSIZE |
127 |
-# if (defined(__x86_64__) && !defined(__ILP32__)) || defined(__sparc_v9__) || defined(__sparcv9) |
128 |
-# define __WORDSIZE 64 |
129 |
-# else |
130 |
-# define __WORDSIZE 32 |
131 |
-# endif |
132 |
-#endif |
133 |
+/* XXX: stdint.h is a new requirement to include, but things haven't adapted |
134 |
+ to it yet, so include it here too. |
135 |
+ since it's a requirement to use the header at all, there's no harm in |
136 |
+ including it? */ |
137 |
+#include <stdint.h> |
138 |
|
139 |
-#ifdef DOXYGEN |
140 |
-/** |
141 |
- * Largest integral type. This type should be large enough to hold any |
142 |
- * pointer or integer supported by the compiler. |
143 |
- */ |
144 |
-typedef uintmax_t LargestIntegralType; |
145 |
-#else /* DOXGEN */ |
146 |
-#ifndef LargestIntegralType |
147 |
-# if __WORDSIZE == 64 && !defined(_WIN64) |
148 |
-# define LargestIntegralType unsigned long int |
149 |
-# else |
150 |
-# define LargestIntegralType unsigned long long int |
151 |
-# endif |
152 |
-#endif /* LargestIntegralType */ |
153 |
-#endif /* DOXYGEN */ |
154 |
- |
155 |
-/* Printf format used to display LargestIntegralType as a hexidecimal. */ |
156 |
+/* Printf format used to display uintmax_t as a hexidecimal. */ |
157 |
#ifndef LargestIntegralTypePrintfFormat |
158 |
# ifdef _WIN32 |
159 |
# define LargestIntegralTypePrintfFormat "0x%I64x" |
160 |
@@ -95,7 +76,7 @@ typedef uintmax_t LargestIntegralType; |
161 |
# endif /* _WIN32 */ |
162 |
#endif /* LargestIntegralTypePrintfFormat */ |
163 |
|
164 |
-/* Printf format used to display LargestIntegralType as a decimal. */ |
165 |
+/* Printf format used to display uintmax_t as a decimal. */ |
166 |
#ifndef LargestIntegralTypePrintfFormatDecimal |
167 |
# ifdef _WIN32 |
168 |
# define LargestIntegralTypePrintfFormatDecimal "%I64u" |
169 |
@@ -116,44 +97,15 @@ typedef uintmax_t LargestIntegralType; |
170 |
# define DoublePrintfFormat "%f" |
171 |
#endif /* DoublePrintfFormat */ |
172 |
|
173 |
-/* Perform an unsigned cast to LargestIntegralType. */ |
174 |
+/* Perform an unsigned cast to uintmax_t. */ |
175 |
#define cast_to_largest_integral_type(value) \ |
176 |
- ((LargestIntegralType)(value)) |
177 |
- |
178 |
-/* Smallest integral type capable of holding a pointer. */ |
179 |
-#if !defined(_UINTPTR_T) && !defined(_UINTPTR_T_DEFINED) && !defined(HAVE_UINTPTR_T) |
180 |
-# if defined(_WIN32) |
181 |
- /* WIN32 is an ILP32 platform */ |
182 |
- typedef unsigned int uintptr_t; |
183 |
-# elif defined(_WIN64) |
184 |
- typedef unsigned long int uintptr_t; |
185 |
-# else /* _WIN32 */ |
186 |
- |
187 |
-/* ILP32 and LP64 platforms */ |
188 |
-# ifdef __WORDSIZE /* glibc */ |
189 |
-# if __WORDSIZE == 64 |
190 |
- typedef unsigned long int uintptr_t; |
191 |
-# else |
192 |
- typedef unsigned int uintptr_t; |
193 |
-# endif /* __WORDSIZE == 64 */ |
194 |
-# else /* __WORDSIZE */ |
195 |
-# if defined(_LP64) || defined(_I32LPx) |
196 |
- typedef unsigned long int uintptr_t; |
197 |
-# else |
198 |
- typedef unsigned int uintptr_t; |
199 |
-# endif |
200 |
-# endif /* __WORDSIZE */ |
201 |
-# endif /* _WIN32 */ |
202 |
- |
203 |
-# define _UINTPTR_T |
204 |
-# define _UINTPTR_T_DEFINED |
205 |
-#endif /* !defined(_UINTPTR_T) || !defined(_UINTPTR_T_DEFINED) */ |
206 |
+ ((uintmax_t)(value)) |
207 |
|
208 |
/* Perform an unsigned cast to uintptr_t. */ |
209 |
#define cast_to_pointer_integral_type(value) \ |
210 |
- ((uintptr_t)((size_t)(value))) |
211 |
+ ((uintptr_t)(value)) |
212 |
|
213 |
-/* Perform a cast of a pointer to LargestIntegralType */ |
214 |
+/* Perform a cast of a pointer to uintmax_t */ |
215 |
#define cast_ptr_to_largest_integral_type(value) \ |
216 |
cast_to_largest_integral_type(cast_to_pointer_integral_type(value)) |
217 |
|
218 |
@@ -240,7 +192,7 @@ cast_to_largest_integral_type(cast_to_pointer_integral_type(value)) |
219 |
* |
220 |
* @see will_return() |
221 |
*/ |
222 |
-LargestIntegralType mock(void); |
223 |
+uintmax_t mock(void); |
224 |
#else |
225 |
#define mock() _mock(__func__, __FILE__, __LINE__) |
226 |
#endif |
227 |
@@ -324,7 +276,7 @@ type mock_ptr_type(#type); |
228 |
* @see mock() |
229 |
* @see will_return_count() |
230 |
*/ |
231 |
-void will_return(#function, LargestIntegralType value); |
232 |
+void will_return(#function, uintmax_t value); |
233 |
#else |
234 |
#define will_return(function, value) \ |
235 |
_will_return(#function, __FILE__, __LINE__, \ |
236 |
@@ -347,7 +299,7 @@ void will_return(#function, LargestIntegralType value); |
237 |
* |
238 |
* @see mock() |
239 |
*/ |
240 |
-void will_return_count(#function, LargestIntegralType value, int count); |
241 |
+void will_return_count(#function, uintmax_t value, int count); |
242 |
#else |
243 |
#define will_return_count(function, value, count) \ |
244 |
_will_return(#function, __FILE__, __LINE__, \ |
245 |
@@ -370,7 +322,7 @@ void will_return_count(#function, LargestIntegralType value, int count); |
246 |
* @see will_return_count() |
247 |
* @see mock() |
248 |
*/ |
249 |
-void will_return_always(#function, LargestIntegralType value); |
250 |
+void will_return_always(#function, uintmax_t value); |
251 |
#else |
252 |
#define will_return_always(function, value) \ |
253 |
will_return_count(function, (value), WILL_RETURN_ALWAYS) |
254 |
@@ -398,7 +350,7 @@ void will_return_always(#function, LargestIntegralType value); |
255 |
* @see will_return_count() |
256 |
* @see mock() |
257 |
*/ |
258 |
-void will_return_maybe(#function, LargestIntegralType value); |
259 |
+void will_return_maybe(#function, uintmax_t value); |
260 |
#else |
261 |
#define will_return_maybe(function, value) \ |
262 |
will_return_count(function, (value), WILL_RETURN_ONCE) |
263 |
@@ -494,7 +446,7 @@ void expect_check(#function, #parameter, #check_function, const void *check_data |
264 |
* |
265 |
* @see check_expected(). |
266 |
*/ |
267 |
-void expect_in_set(#function, #parameter, LargestIntegralType value_array[]); |
268 |
+void expect_in_set(#function, #parameter, uintmax_t value_array[]); |
269 |
#else |
270 |
#define expect_in_set(function, parameter, value_array) \ |
271 |
expect_in_set_count(function, parameter, value_array, 1) |
272 |
@@ -519,7 +471,7 @@ void expect_in_set(#function, #parameter, LargestIntegralType value_array[]); |
273 |
* |
274 |
* @see check_expected(). |
275 |
*/ |
276 |
-void expect_in_set_count(#function, #parameter, LargestIntegralType value_array[], size_t count); |
277 |
+void expect_in_set_count(#function, #parameter, uintmax_t value_array[], size_t count); |
278 |
#else |
279 |
#define expect_in_set_count(function, parameter, value_array, count) \ |
280 |
_expect_in_set(#function, #parameter, __FILE__, __LINE__, value_array, \ |
281 |
@@ -541,7 +493,7 @@ void expect_in_set_count(#function, #parameter, LargestIntegralType value_array[ |
282 |
* |
283 |
* @see check_expected(). |
284 |
*/ |
285 |
-void expect_not_in_set(#function, #parameter, LargestIntegralType value_array[]); |
286 |
+void expect_not_in_set(#function, #parameter, uintmax_t value_array[]); |
287 |
#else |
288 |
#define expect_not_in_set(function, parameter, value_array) \ |
289 |
expect_not_in_set_count(function, parameter, value_array, 1) |
290 |
@@ -566,7 +518,7 @@ void expect_not_in_set(#function, #parameter, LargestIntegralType value_array[]) |
291 |
* |
292 |
* @see check_expected(). |
293 |
*/ |
294 |
-void expect_not_in_set_count(#function, #parameter, LargestIntegralType value_array[], size_t count); |
295 |
+void expect_not_in_set_count(#function, #parameter, uintmax_t value_array[], size_t count); |
296 |
#else |
297 |
#define expect_not_in_set_count(function, parameter, value_array, count) \ |
298 |
_expect_not_in_set( \ |
299 |
@@ -592,7 +544,7 @@ void expect_not_in_set_count(#function, #parameter, LargestIntegralType value_ar |
300 |
* |
301 |
* @see check_expected(). |
302 |
*/ |
303 |
-void expect_in_range(#function, #parameter, LargestIntegralType minimum, LargestIntegralType maximum); |
304 |
+void expect_in_range(#function, #parameter, uintmax_t minimum, uintmax_t maximum); |
305 |
#else |
306 |
#define expect_in_range(function, parameter, minimum, maximum) \ |
307 |
expect_in_range_count(function, parameter, minimum, maximum, 1) |
308 |
@@ -619,7 +571,7 @@ void expect_in_range(#function, #parameter, LargestIntegralType minimum, Largest |
309 |
* |
310 |
* @see check_expected(). |
311 |
*/ |
312 |
-void expect_in_range_count(#function, #parameter, LargestIntegralType minimum, LargestIntegralType maximum, size_t count); |
313 |
+void expect_in_range_count(#function, #parameter, uintmax_t minimum, uintmax_t maximum, size_t count); |
314 |
#else |
315 |
#define expect_in_range_count(function, parameter, minimum, maximum, count) \ |
316 |
_expect_in_range(#function, #parameter, __FILE__, __LINE__, minimum, \ |
317 |
@@ -643,7 +595,7 @@ void expect_in_range_count(#function, #parameter, LargestIntegralType minimum, L |
318 |
* |
319 |
* @see check_expected(). |
320 |
*/ |
321 |
-void expect_not_in_range(#function, #parameter, LargestIntegralType minimum, LargestIntegralType maximum); |
322 |
+void expect_not_in_range(#function, #parameter, uintmax_t minimum, uintmax_t maximum); |
323 |
#else |
324 |
#define expect_not_in_range(function, parameter, minimum, maximum) \ |
325 |
expect_not_in_range_count(function, parameter, minimum, maximum, 1) |
326 |
@@ -670,7 +622,7 @@ void expect_not_in_range(#function, #parameter, LargestIntegralType minimum, Lar |
327 |
* |
328 |
* @see check_expected(). |
329 |
*/ |
330 |
-void expect_not_in_range_count(#function, #parameter, LargestIntegralType minimum, LargestIntegralType maximum, size_t count); |
331 |
+void expect_not_in_range_count(#function, #parameter, uintmax_t minimum, uintmax_t maximum, size_t count); |
332 |
#else |
333 |
#define expect_not_in_range_count(function, parameter, minimum, maximum, \ |
334 |
count) \ |
335 |
@@ -695,7 +647,7 @@ void expect_not_in_range_count(#function, #parameter, LargestIntegralType minimu |
336 |
* @see expect_memory() |
337 |
* @see expect_any() |
338 |
*/ |
339 |
-void expect_value(#function, #parameter, LargestIntegralType value); |
340 |
+void expect_value(#function, #parameter, uintmax_t value); |
341 |
#else |
342 |
#define expect_value(function, parameter, value) \ |
343 |
expect_value_count(function, parameter, value, 1) |
344 |
@@ -722,7 +674,7 @@ void expect_value(#function, #parameter, LargestIntegralType value); |
345 |
* @see expect_not_string() |
346 |
* @see expect_not_memory() |
347 |
*/ |
348 |
-void expect_value_count(#function, #parameter, LargestIntegralType value, size_t count); |
349 |
+void expect_value_count(#function, #parameter, uintmax_t value, size_t count); |
350 |
#else |
351 |
#define expect_value_count(function, parameter, value, count) \ |
352 |
_expect_value(#function, #parameter, __FILE__, __LINE__, \ |
353 |
@@ -743,7 +695,7 @@ void expect_value_count(#function, #parameter, LargestIntegralType value, size_t |
354 |
* |
355 |
* @see check_expected(). |
356 |
*/ |
357 |
-void expect_not_value(#function, #parameter, LargestIntegralType value); |
358 |
+void expect_not_value(#function, #parameter, uintmax_t value); |
359 |
#else |
360 |
#define expect_not_value(function, parameter, value) \ |
361 |
expect_not_value_count(function, parameter, value, 1) |
362 |
@@ -767,7 +719,7 @@ void expect_not_value(#function, #parameter, LargestIntegralType value); |
363 |
* |
364 |
* @see check_expected(). |
365 |
*/ |
366 |
-void expect_not_value_count(#function, #parameter, LargestIntegralType value, size_t count); |
367 |
+void expect_not_value_count(#function, #parameter, uintmax_t value, size_t count); |
368 |
#else |
369 |
#define expect_not_value_count(function, parameter, value, count) \ |
370 |
_expect_not_value(#function, #parameter, __FILE__, __LINE__, \ |
371 |
@@ -1438,7 +1390,7 @@ void assert_memory_not_equal(const void *a, const void *b, size_t size); |
372 |
* |
373 |
* @param[in] maximum The maximum value allowed. |
374 |
*/ |
375 |
-void assert_in_range(LargestIntegralType value, LargestIntegralType minimum, LargestIntegralType maximum); |
376 |
+void assert_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum); |
377 |
#else |
378 |
#define assert_in_range(value, minimum, maximum) \ |
379 |
_assert_in_range( \ |
380 |
@@ -1461,7 +1413,7 @@ void assert_in_range(LargestIntegralType value, LargestIntegralType minimum, Lar |
381 |
* |
382 |
* @param[in] maximum The maximum value to compare. |
383 |
*/ |
384 |
-void assert_not_in_range(LargestIntegralType value, LargestIntegralType minimum, LargestIntegralType maximum); |
385 |
+void assert_not_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum); |
386 |
#else |
387 |
#define assert_not_in_range(value, minimum, maximum) \ |
388 |
_assert_not_in_range( \ |
389 |
@@ -1483,7 +1435,7 @@ void assert_not_in_range(LargestIntegralType value, LargestIntegralType minimum, |
390 |
* |
391 |
* @param[in] count The size of the values array. |
392 |
*/ |
393 |
-void assert_in_set(LargestIntegralType value, LargestIntegralType values[], size_t count); |
394 |
+void assert_in_set(uintmax_t value, uintmax_t values[], size_t count); |
395 |
#else |
396 |
#define assert_in_set(value, values, number_of_values) \ |
397 |
_assert_in_set(value, values, number_of_values, __FILE__, __LINE__) |
398 |
@@ -1502,7 +1454,7 @@ void assert_in_set(LargestIntegralType value, LargestIntegralType values[], size |
399 |
* |
400 |
* @param[in] count The size of the values array. |
401 |
*/ |
402 |
-void assert_not_in_set(LargestIntegralType value, LargestIntegralType values[], size_t count); |
403 |
+void assert_not_in_set(uintmax_t value, uintmax_t values[], size_t count); |
404 |
#else |
405 |
#define assert_not_in_set(value, values, number_of_values) \ |
406 |
_assert_not_in_set(value, values, number_of_values, __FILE__, __LINE__) |
407 |
@@ -2181,8 +2133,8 @@ void expect_assert_failure(function fn_call); |
408 |
typedef void (*UnitTestFunction)(void **state); |
409 |
|
410 |
/* Function that determines whether a function parameter value is correct. */ |
411 |
-typedef int (*CheckParameterValue)(const LargestIntegralType value, |
412 |
- const LargestIntegralType check_value_data); |
413 |
+typedef int (*CheckParameterValue)(const uintmax_t value, |
414 |
+ const uintmax_t check_value_data); |
415 |
|
416 |
/* Type of the unit test function. */ |
417 |
typedef enum UnitTestFunctionType { |
418 |
@@ -2236,7 +2188,7 @@ typedef struct CheckParameterEvent { |
419 |
SourceLocation location; |
420 |
const char *parameter_name; |
421 |
CheckParameterValue check_value; |
422 |
- LargestIntegralType check_value_data; |
423 |
+ uintmax_t check_value_data; |
424 |
} CheckParameterEvent; |
425 |
|
426 |
/* Used by expect_assert_failure() and mock_assert(). */ |
427 |
@@ -2245,7 +2197,7 @@ extern jmp_buf global_expect_assert_env; |
428 |
extern const char * global_last_failed_assert; |
429 |
|
430 |
/* Retrieves a value for the given function, as set by "will_return". */ |
431 |
-LargestIntegralType _mock(const char * const function, const char* const file, |
432 |
+uintmax_t _mock(const char * const function, const char* const file, |
433 |
const int line); |
434 |
|
435 |
void _expect_function_call( |
436 |
@@ -2261,36 +2213,36 @@ void _expect_check( |
437 |
const char* const function, const char* const parameter, |
438 |
const char* const file, const int line, |
439 |
const CheckParameterValue check_function, |
440 |
- const LargestIntegralType check_data, CheckParameterEvent * const event, |
441 |
+ const uintmax_t check_data, CheckParameterEvent * const event, |
442 |
const int count); |
443 |
|
444 |
void _expect_in_set( |
445 |
const char* const function, const char* const parameter, |
446 |
- const char* const file, const int line, const LargestIntegralType values[], |
447 |
+ const char* const file, const int line, const uintmax_t values[], |
448 |
const size_t number_of_values, const int count); |
449 |
void _expect_not_in_set( |
450 |
const char* const function, const char* const parameter, |
451 |
- const char* const file, const int line, const LargestIntegralType values[], |
452 |
+ const char* const file, const int line, const uintmax_t values[], |
453 |
const size_t number_of_values, const int count); |
454 |
|
455 |
void _expect_in_range( |
456 |
const char* const function, const char* const parameter, |
457 |
const char* const file, const int line, |
458 |
- const LargestIntegralType minimum, |
459 |
- const LargestIntegralType maximum, const int count); |
460 |
+ const uintmax_t minimum, |
461 |
+ const uintmax_t maximum, const int count); |
462 |
void _expect_not_in_range( |
463 |
const char* const function, const char* const parameter, |
464 |
const char* const file, const int line, |
465 |
- const LargestIntegralType minimum, |
466 |
- const LargestIntegralType maximum, const int count); |
467 |
+ const uintmax_t minimum, |
468 |
+ const uintmax_t maximum, const int count); |
469 |
|
470 |
void _expect_value( |
471 |
const char* const function, const char* const parameter, |
472 |
- const char* const file, const int line, const LargestIntegralType value, |
473 |
+ const char* const file, const int line, const uintmax_t value, |
474 |
const int count); |
475 |
void _expect_not_value( |
476 |
const char* const function, const char* const parameter, |
477 |
- const char* const file, const int line, const LargestIntegralType value, |
478 |
+ const char* const file, const int line, const uintmax_t value, |
479 |
const int count); |
480 |
|
481 |
void _expect_string( |
482 |
@@ -2317,17 +2269,17 @@ void _expect_any( |
483 |
|
484 |
void _check_expected( |
485 |
const char * const function_name, const char * const parameter_name, |
486 |
- const char* file, const int line, const LargestIntegralType value); |
487 |
+ const char* file, const int line, const uintmax_t value); |
488 |
|
489 |
void _will_return(const char * const function_name, const char * const file, |
490 |
- const int line, const LargestIntegralType value, |
491 |
+ const int line, const uintmax_t value, |
492 |
const int count); |
493 |
-void _assert_true(const LargestIntegralType result, |
494 |
+void _assert_true(const uintmax_t result, |
495 |
const char* const expression, |
496 |
const char * const file, const int line); |
497 |
-void _assert_return_code(const LargestIntegralType result, |
498 |
+void _assert_return_code(const uintmax_t result, |
499 |
size_t rlen, |
500 |
- const LargestIntegralType error, |
501 |
+ const uintmax_t error, |
502 |
const char * const expression, |
503 |
const char * const file, |
504 |
const int line); |
505 |
@@ -2344,10 +2296,10 @@ void _assert_double_not_equal(const double a, const double n, |
506 |
const double epsilon, const char* const file, |
507 |
const int line); |
508 |
void _assert_int_equal( |
509 |
- const LargestIntegralType a, const LargestIntegralType b, |
510 |
+ const uintmax_t a, const uintmax_t b, |
511 |
const char * const file, const int line); |
512 |
void _assert_int_not_equal( |
513 |
- const LargestIntegralType a, const LargestIntegralType b, |
514 |
+ const uintmax_t a, const uintmax_t b, |
515 |
const char * const file, const int line); |
516 |
void _assert_string_equal(const char * const a, const char * const b, |
517 |
const char * const file, const int line); |
518 |
@@ -2360,16 +2312,16 @@ void _assert_memory_not_equal(const void * const a, const void * const b, |
519 |
const size_t size, const char* const file, |
520 |
const int line); |
521 |
void _assert_in_range( |
522 |
- const LargestIntegralType value, const LargestIntegralType minimum, |
523 |
- const LargestIntegralType maximum, const char* const file, const int line); |
524 |
+ const uintmax_t value, const uintmax_t minimum, |
525 |
+ const uintmax_t maximum, const char* const file, const int line); |
526 |
void _assert_not_in_range( |
527 |
- const LargestIntegralType value, const LargestIntegralType minimum, |
528 |
- const LargestIntegralType maximum, const char* const file, const int line); |
529 |
+ const uintmax_t value, const uintmax_t minimum, |
530 |
+ const uintmax_t maximum, const char* const file, const int line); |
531 |
void _assert_in_set( |
532 |
- const LargestIntegralType value, const LargestIntegralType values[], |
533 |
+ const uintmax_t value, const uintmax_t values[], |
534 |
const size_t number_of_values, const char* const file, const int line); |
535 |
void _assert_not_in_set( |
536 |
- const LargestIntegralType value, const LargestIntegralType values[], |
537 |
+ const uintmax_t value, const uintmax_t values[], |
538 |
const size_t number_of_values, const char* const file, const int line); |
539 |
|
540 |
void* _test_malloc(const size_t size, const char* file, const int line); |
541 |
diff --git a/src/cmocka.c b/src/cmocka.c |
542 |
index 52897e1..62d4284 100644 |
543 |
--- src/cmocka.c |
544 |
+++ src/cmocka.c |
545 |
@@ -1,6 +1,6 @@ |
546 |
/* |
547 |
* Copyright 2008 Google Inc. |
548 |
- * Copyright 2014-2018 Andreas Schneider <asn@cryptomilk.org> |
549 |
+ * Copyright 2014-2020 Andreas Schneider <asn@cryptomilk.org> |
550 |
* Copyright 2015 Jakub Hrozek <jakub.hrozek@posteo.se> |
551 |
* |
552 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
553 |
@@ -111,14 +111,14 @@ |
554 |
|
555 |
|
556 |
/* |
557 |
- * Declare and initialize a LargestIntegralType variable name |
558 |
+ * Declare and initialize a uintmax_t variable name |
559 |
* with value the conversion of ptr. |
560 |
*/ |
561 |
#define declare_initialize_value_pointer_pointer(name, ptr) \ |
562 |
- LargestIntegralType name ; \ |
563 |
- name = (LargestIntegralType) (uintptr_t) ptr |
564 |
+ uintmax_t name ; \ |
565 |
+ name = (uintmax_t)((uintptr_t)(ptr)) |
566 |
|
567 |
-/* Cast a LargestIntegralType to pointer_type. */ |
568 |
+/* Cast a uintmax_t to pointer_type. */ |
569 |
#define cast_largest_integral_type_to_pointer( \ |
570 |
pointer_type, largest_integral_type) \ |
571 |
((pointer_type)(uintptr_t)(largest_integral_type)) |
572 |
@@ -158,7 +158,7 @@ typedef int (*EqualityFunction)(const void *left, const void *right); |
573 |
/* Value of a symbol and the place it was declared. */ |
574 |
typedef struct SymbolValue { |
575 |
SourceLocation location; |
576 |
- LargestIntegralType value; |
577 |
+ uintmax_t value; |
578 |
} SymbolValue; |
579 |
|
580 |
/* |
581 |
@@ -183,14 +183,14 @@ typedef void (*CleanupListValue)(const void *value, void *cleanup_value_data); |
582 |
/* Structure used to check the range of integer types.a */ |
583 |
typedef struct CheckIntegerRange { |
584 |
CheckParameterEvent event; |
585 |
- LargestIntegralType minimum; |
586 |
- LargestIntegralType maximum; |
587 |
+ uintmax_t minimum; |
588 |
+ uintmax_t maximum; |
589 |
} CheckIntegerRange; |
590 |
|
591 |
/* Structure used to check whether an integer value is in a set. */ |
592 |
typedef struct CheckIntegerSet { |
593 |
CheckParameterEvent event; |
594 |
- const LargestIntegralType *set; |
595 |
+ const uintmax_t *set; |
596 |
size_t size_of_set; |
597 |
} CheckIntegerSet; |
598 |
|
599 |
@@ -702,7 +702,7 @@ static void free_value(const void *value, void *cleanup_value_data) { |
600 |
static void free_symbol_map_value(const void *value, |
601 |
void *cleanup_value_data) { |
602 |
SymbolMapValue * const map_value = (SymbolMapValue*)value; |
603 |
- const LargestIntegralType children = cast_ptr_to_largest_integral_type(cleanup_value_data); |
604 |
+ const uintmax_t children = cast_ptr_to_largest_integral_type(cleanup_value_data); |
605 |
assert_non_null(value); |
606 |
if (children == 0) { |
607 |
list_free(&map_value->symbol_values_list_head, |
608 |
@@ -947,14 +947,14 @@ static size_t check_for_leftover_values( |
609 |
|
610 |
|
611 |
/* Get the next return value for the specified mock function. */ |
612 |
-LargestIntegralType _mock(const char * const function, const char* const file, |
613 |
+uintmax_t _mock(const char * const function, const char* const file, |
614 |
const int line) { |
615 |
void *result; |
616 |
const int rc = get_symbol_value(&global_function_result_map_head, |
617 |
&function, 1, &result); |
618 |
if (rc) { |
619 |
SymbolValue * const symbol = (SymbolValue*)result; |
620 |
- const LargestIntegralType value = symbol->value; |
621 |
+ const uintmax_t value = symbol->value; |
622 |
global_last_mock_value_location = symbol->location; |
623 |
if (rc == 1) { |
624 |
free(symbol); |
625 |
@@ -1055,7 +1055,7 @@ void _function_called(const char *const function, |
626 |
|
627 |
/* Add a return value for the specified mock function name. */ |
628 |
void _will_return(const char * const function_name, const char * const file, |
629 |
- const int line, const LargestIntegralType value, |
630 |
+ const int line, const uintmax_t value, |
631 |
const int count) { |
632 |
SymbolValue * const return_value = |
633 |
(SymbolValue*)malloc(sizeof(*return_value)); |
634 |
@@ -1077,7 +1077,7 @@ void _expect_check( |
635 |
const char* const function, const char* const parameter, |
636 |
const char* const file, const int line, |
637 |
const CheckParameterValue check_function, |
638 |
- const LargestIntegralType check_data, |
639 |
+ const uintmax_t check_data, |
640 |
CheckParameterEvent * const event, const int count) { |
641 |
CheckParameterEvent * const check = |
642 |
event ? event : (CheckParameterEvent*)malloc(sizeof(*check)); |
643 |
@@ -1241,8 +1241,8 @@ static int double_values_not_equal_display_error(const double left, |
644 |
|
645 |
/* Returns 1 if the specified values are equal. If the values are not equal |
646 |
* an error is displayed and 0 is returned. */ |
647 |
-static int values_equal_display_error(const LargestIntegralType left, |
648 |
- const LargestIntegralType right) { |
649 |
+static int values_equal_display_error(const uintmax_t left, |
650 |
+ const uintmax_t right) { |
651 |
const int equal = left == right; |
652 |
if (!equal) { |
653 |
cm_print_error(LargestIntegralTypePrintfFormat " != " |
654 |
@@ -1254,8 +1254,8 @@ static int values_equal_display_error(const LargestIntegralType left, |
655 |
/* |
656 |
* Returns 1 if the specified values are not equal. If the values are equal |
657 |
* an error is displayed and 0 is returned. */ |
658 |
-static int values_not_equal_display_error(const LargestIntegralType left, |
659 |
- const LargestIntegralType right) { |
660 |
+static int values_not_equal_display_error(const uintmax_t left, |
661 |
+ const uintmax_t right) { |
662 |
const int not_equal = left != right; |
663 |
if (!not_equal) { |
664 |
cm_print_error(LargestIntegralTypePrintfFormat " == " |
665 |
@@ -1273,12 +1273,12 @@ static int values_not_equal_display_error(const LargestIntegralType left, |
666 |
* displayed. |
667 |
*/ |
668 |
static int value_in_set_display_error( |
669 |
- const LargestIntegralType value, |
670 |
+ const uintmax_t value, |
671 |
const CheckIntegerSet * const check_integer_set, const int invert) { |
672 |
int succeeded = invert; |
673 |
assert_non_null(check_integer_set); |
674 |
{ |
675 |
- const LargestIntegralType * const set = check_integer_set->set; |
676 |
+ const uintmax_t * const set = check_integer_set->set; |
677 |
const size_t size_of_set = check_integer_set->size_of_set; |
678 |
size_t i; |
679 |
for (i = 0; i < size_of_set; i++) { |
680 |
@@ -1310,8 +1310,8 @@ static int value_in_set_display_error( |
681 |
* specified range an error is displayed and 0 is returned. |
682 |
*/ |
683 |
static int integer_in_range_display_error( |
684 |
- const LargestIntegralType value, const LargestIntegralType range_min, |
685 |
- const LargestIntegralType range_max) { |
686 |
+ const uintmax_t value, const uintmax_t range_min, |
687 |
+ const uintmax_t range_max) { |
688 |
if (value >= range_min && value <= range_max) { |
689 |
return 1; |
690 |
} |
691 |
@@ -1330,8 +1330,8 @@ static int integer_in_range_display_error( |
692 |
* specified range an error is displayed and zero is returned. |
693 |
*/ |
694 |
static int integer_not_in_range_display_error( |
695 |
- const LargestIntegralType value, const LargestIntegralType range_min, |
696 |
- const LargestIntegralType range_max) { |
697 |
+ const uintmax_t value, const uintmax_t range_min, |
698 |
+ const uintmax_t range_max) { |
699 |
if (value < range_min || value > range_max) { |
700 |
return 1; |
701 |
} |
702 |
@@ -1431,8 +1431,8 @@ static int memory_not_equal_display_error( |
703 |
|
704 |
|
705 |
/* CheckParameterValue callback to check whether a value is within a set. */ |
706 |
-static int check_in_set(const LargestIntegralType value, |
707 |
- const LargestIntegralType check_value_data) { |
708 |
+static int check_in_set(const uintmax_t value, |
709 |
+ const uintmax_t check_value_data) { |
710 |
return value_in_set_display_error(value, |
711 |
cast_largest_integral_type_to_pointer(CheckIntegerSet*, |
712 |
check_value_data), 0); |
713 |
@@ -1440,8 +1440,8 @@ static int check_in_set(const LargestIntegralType value, |
714 |
|
715 |
|
716 |
/* CheckParameterValue callback to check whether a value isn't within a set. */ |
717 |
-static int check_not_in_set(const LargestIntegralType value, |
718 |
- const LargestIntegralType check_value_data) { |
719 |
+static int check_not_in_set(const uintmax_t value, |
720 |
+ const uintmax_t check_value_data) { |
721 |
return value_in_set_display_error(value, |
722 |
cast_largest_integral_type_to_pointer(CheckIntegerSet*, |
723 |
check_value_data), 1); |
724 |
@@ -1453,12 +1453,12 @@ static int check_not_in_set(const LargestIntegralType value, |
725 |
static void expect_set( |
726 |
const char* const function, const char* const parameter, |
727 |
const char* const file, const int line, |
728 |
- const LargestIntegralType values[], const size_t number_of_values, |
729 |
+ const uintmax_t values[], const size_t number_of_values, |
730 |
const CheckParameterValue check_function, const int count) { |
731 |
CheckIntegerSet * const check_integer_set = |
732 |
(CheckIntegerSet*)malloc(sizeof(*check_integer_set) + |
733 |
(sizeof(values[0]) * number_of_values)); |
734 |
- LargestIntegralType * const set = (LargestIntegralType*)( |
735 |
+ uintmax_t * const set = (uintmax_t*)( |
736 |
check_integer_set + 1); |
737 |
declare_initialize_value_pointer_pointer(check_data, check_integer_set); |
738 |
assert_non_null(values); |
739 |
@@ -1476,7 +1476,7 @@ static void expect_set( |
740 |
void _expect_in_set( |
741 |
const char* const function, const char* const parameter, |
742 |
const char* const file, const int line, |
743 |
- const LargestIntegralType values[], const size_t number_of_values, |
744 |
+ const uintmax_t values[], const size_t number_of_values, |
745 |
const int count) { |
746 |
expect_set(function, parameter, file, line, values, number_of_values, |
747 |
check_in_set, count); |
748 |
@@ -1487,7 +1487,7 @@ void _expect_in_set( |
749 |
void _expect_not_in_set( |
750 |
const char* const function, const char* const parameter, |
751 |
const char* const file, const int line, |
752 |
- const LargestIntegralType values[], const size_t number_of_values, |
753 |
+ const uintmax_t values[], const size_t number_of_values, |
754 |
const int count) { |
755 |
expect_set(function, parameter, file, line, values, number_of_values, |
756 |
check_not_in_set, count); |
757 |
@@ -1495,8 +1495,8 @@ void _expect_not_in_set( |
758 |
|
759 |
|
760 |
/* CheckParameterValue callback to check whether a value is within a range. */ |
761 |
-static int check_in_range(const LargestIntegralType value, |
762 |
- const LargestIntegralType check_value_data) { |
763 |
+static int check_in_range(const uintmax_t value, |
764 |
+ const uintmax_t check_value_data) { |
765 |
CheckIntegerRange * const check_integer_range = |
766 |
cast_largest_integral_type_to_pointer(CheckIntegerRange*, |
767 |
check_value_data); |
768 |
@@ -1507,8 +1507,8 @@ static int check_in_range(const LargestIntegralType value, |
769 |
|
770 |
|
771 |
/* CheckParameterValue callback to check whether a value is not within a range. */ |
772 |
-static int check_not_in_range(const LargestIntegralType value, |
773 |
- const LargestIntegralType check_value_data) { |
774 |
+static int check_not_in_range(const uintmax_t value, |
775 |
+ const uintmax_t check_value_data) { |
776 |
CheckIntegerRange * const check_integer_range = |
777 |
cast_largest_integral_type_to_pointer(CheckIntegerRange*, |
778 |
check_value_data); |
779 |
@@ -1523,7 +1523,7 @@ static int check_not_in_range(const LargestIntegralType value, |
780 |
static void expect_range( |
781 |
const char* const function, const char* const parameter, |
782 |
const char* const file, const int line, |
783 |
- const LargestIntegralType minimum, const LargestIntegralType maximum, |
784 |
+ const uintmax_t minimum, const uintmax_t maximum, |
785 |
const CheckParameterValue check_function, const int count) { |
786 |
CheckIntegerRange * const check_integer_range = |
787 |
(CheckIntegerRange*)malloc(sizeof(*check_integer_range)); |
788 |
@@ -1539,7 +1539,7 @@ static void expect_range( |
789 |
void _expect_in_range( |
790 |
const char* const function, const char* const parameter, |
791 |
const char* const file, const int line, |
792 |
- const LargestIntegralType minimum, const LargestIntegralType maximum, |
793 |
+ const uintmax_t minimum, const uintmax_t maximum, |
794 |
const int count) { |
795 |
expect_range(function, parameter, file, line, minimum, maximum, |
796 |
check_in_range, count); |
797 |
@@ -1550,7 +1550,7 @@ void _expect_in_range( |
798 |
void _expect_not_in_range( |
799 |
const char* const function, const char* const parameter, |
800 |
const char* const file, const int line, |
801 |
- const LargestIntegralType minimum, const LargestIntegralType maximum, |
802 |
+ const uintmax_t minimum, const uintmax_t maximum, |
803 |
const int count) { |
804 |
expect_range(function, parameter, file, line, minimum, maximum, |
805 |
check_not_in_range, count); |
806 |
@@ -1559,8 +1559,8 @@ void _expect_not_in_range( |
807 |
|
808 |
/* CheckParameterValue callback to check whether a value is equal to an |
809 |
* expected value. */ |
810 |
-static int check_value(const LargestIntegralType value, |
811 |
- const LargestIntegralType check_value_data) { |
812 |
+static int check_value(const uintmax_t value, |
813 |
+ const uintmax_t check_value_data) { |
814 |
return values_equal_display_error(value, check_value_data); |
815 |
} |
816 |
|
817 |
@@ -1569,7 +1569,7 @@ static int check_value(const LargestIntegralType value, |
818 |
void _expect_value( |
819 |
const char* const function, const char* const parameter, |
820 |
const char* const file, const int line, |
821 |
- const LargestIntegralType value, const int count) { |
822 |
+ const uintmax_t value, const int count) { |
823 |
_expect_check(function, parameter, file, line, check_value, value, NULL, |
824 |
count); |
825 |
} |
826 |
@@ -1577,8 +1577,8 @@ void _expect_value( |
827 |
|
828 |
/* CheckParameterValue callback to check whether a value is not equal to an |
829 |
* expected value. */ |
830 |
-static int check_not_value(const LargestIntegralType value, |
831 |
- const LargestIntegralType check_value_data) { |
832 |
+static int check_not_value(const uintmax_t value, |
833 |
+ const uintmax_t check_value_data) { |
834 |
return values_not_equal_display_error(value, check_value_data); |
835 |
} |
836 |
|
837 |
@@ -1587,15 +1587,15 @@ static int check_not_value(const LargestIntegralType value, |
838 |
void _expect_not_value( |
839 |
const char* const function, const char* const parameter, |
840 |
const char* const file, const int line, |
841 |
- const LargestIntegralType value, const int count) { |
842 |
+ const uintmax_t value, const int count) { |
843 |
_expect_check(function, parameter, file, line, check_not_value, value, |
844 |
NULL, count); |
845 |
} |
846 |
|
847 |
|
848 |
/* CheckParameterValue callback to check whether a parameter equals a string. */ |
849 |
-static int check_string(const LargestIntegralType value, |
850 |
- const LargestIntegralType check_value_data) { |
851 |
+static int check_string(const uintmax_t value, |
852 |
+ const uintmax_t check_value_data) { |
853 |
return string_equal_display_error( |
854 |
cast_largest_integral_type_to_pointer(char*, value), |
855 |
cast_largest_integral_type_to_pointer(char*, check_value_data)); |
856 |
@@ -1616,8 +1616,8 @@ void _expect_string( |
857 |
|
858 |
/* CheckParameterValue callback to check whether a parameter is not equals to |
859 |
* a string. */ |
860 |
-static int check_not_string(const LargestIntegralType value, |
861 |
- const LargestIntegralType check_value_data) { |
862 |
+static int check_not_string(const uintmax_t value, |
863 |
+ const uintmax_t check_value_data) { |
864 |
return string_not_equal_display_error( |
865 |
cast_largest_integral_type_to_pointer(char*, value), |
866 |
cast_largest_integral_type_to_pointer(char*, check_value_data)); |
867 |
@@ -1637,8 +1637,8 @@ void _expect_not_string( |
868 |
|
869 |
/* CheckParameterValue callback to check whether a parameter equals an area of |
870 |
* memory. */ |
871 |
-static int check_memory(const LargestIntegralType value, |
872 |
- const LargestIntegralType check_value_data) { |
873 |
+static int check_memory(const uintmax_t value, |
874 |
+ const uintmax_t check_value_data) { |
875 |
CheckMemoryData * const check = cast_largest_integral_type_to_pointer( |
876 |
CheckMemoryData*, check_value_data); |
877 |
assert_non_null(check); |
878 |
@@ -1681,8 +1681,8 @@ void _expect_memory( |
879 |
|
880 |
/* CheckParameterValue callback to check whether a parameter is not equal to |
881 |
* an area of memory. */ |
882 |
-static int check_not_memory(const LargestIntegralType value, |
883 |
- const LargestIntegralType check_value_data) { |
884 |
+static int check_not_memory(const uintmax_t value, |
885 |
+ const uintmax_t check_value_data) { |
886 |
CheckMemoryData * const check = cast_largest_integral_type_to_pointer( |
887 |
CheckMemoryData*, check_value_data); |
888 |
assert_non_null(check); |
889 |
@@ -1704,8 +1704,8 @@ void _expect_not_memory( |
890 |
|
891 |
|
892 |
/* CheckParameterValue callback that always returns 1. */ |
893 |
-static int check_any(const LargestIntegralType value, |
894 |
- const LargestIntegralType check_value_data) { |
895 |
+static int check_any(const uintmax_t value, |
896 |
+ const uintmax_t check_value_data) { |
897 |
(void)value; |
898 |
(void)check_value_data; |
899 |
return 1; |
900 |
@@ -1723,7 +1723,7 @@ void _expect_any( |
901 |
|
902 |
void _check_expected( |
903 |
const char * const function_name, const char * const parameter_name, |
904 |
- const char* file, const int line, const LargestIntegralType value) { |
905 |
+ const char* file, const int line, const uintmax_t value) { |
906 |
void *result = NULL; |
907 |
const char* symbols[] = {function_name, parameter_name}; |
908 |
const int rc = get_symbol_value(&global_function_parameter_map_head, |
909 |
@@ -1780,7 +1780,7 @@ void mock_assert(const int result, const char* const expression, |
910 |
} |
911 |
|
912 |
|
913 |
-void _assert_true(const LargestIntegralType result, |
914 |
+void _assert_true(const uintmax_t result, |
915 |
const char * const expression, |
916 |
const char * const file, const int line) { |
917 |
if (!result) { |
918 |
@@ -1789,14 +1789,14 @@ void _assert_true(const LargestIntegralType result, |
919 |
} |
920 |
} |
921 |
|
922 |
-void _assert_return_code(const LargestIntegralType result, |
923 |
+void _assert_return_code(const uintmax_t result, |
924 |
size_t rlen, |
925 |
- const LargestIntegralType error, |
926 |
+ const uintmax_t error, |
927 |
const char * const expression, |
928 |
const char * const file, |
929 |
const int line) |
930 |
{ |
931 |
- LargestIntegralType valmax; |
932 |
+ uintmax_t valmax; |
933 |
|
934 |
|
935 |
switch (rlen) { |
936 |
@@ -1872,7 +1872,7 @@ void _assert_double_not_equal(const double a, |
937 |
} |
938 |
|
939 |
void _assert_int_equal( |
940 |
- const LargestIntegralType a, const LargestIntegralType b, |
941 |
+ const uintmax_t a, const uintmax_t b, |
942 |
const char * const file, const int line) { |
943 |
if (!values_equal_display_error(a, b)) { |
944 |
_fail(file, line); |
945 |
@@ -1881,7 +1881,7 @@ void _assert_int_equal( |
946 |
|
947 |
|
948 |
void _assert_int_not_equal( |
949 |
- const LargestIntegralType a, const LargestIntegralType b, |
950 |
+ const uintmax_t a, const uintmax_t b, |
951 |
const char * const file, const int line) { |
952 |
if (!values_not_equal_display_error(a, b)) { |
953 |
_fail(file, line); |
954 |
@@ -1925,8 +1925,8 @@ void _assert_memory_not_equal(const void * const a, const void * const b, |
955 |
|
956 |
|
957 |
void _assert_in_range( |
958 |
- const LargestIntegralType value, const LargestIntegralType minimum, |
959 |
- const LargestIntegralType maximum, const char* const file, |
960 |
+ const uintmax_t value, const uintmax_t minimum, |
961 |
+ const uintmax_t maximum, const char* const file, |
962 |
const int line) { |
963 |
if (!integer_in_range_display_error(value, minimum, maximum)) { |
964 |
_fail(file, line); |
965 |
@@ -1934,16 +1934,16 @@ void _assert_in_range( |
966 |
} |
967 |
|
968 |
void _assert_not_in_range( |
969 |
- const LargestIntegralType value, const LargestIntegralType minimum, |
970 |
- const LargestIntegralType maximum, const char* const file, |
971 |
+ const uintmax_t value, const uintmax_t minimum, |
972 |
+ const uintmax_t maximum, const char* const file, |
973 |
const int line) { |
974 |
if (!integer_not_in_range_display_error(value, minimum, maximum)) { |
975 |
_fail(file, line); |
976 |
} |
977 |
} |
978 |
|
979 |
-void _assert_in_set(const LargestIntegralType value, |
980 |
- const LargestIntegralType values[], |
981 |
+void _assert_in_set(const uintmax_t value, |
982 |
+ const uintmax_t values[], |
983 |
const size_t number_of_values, const char* const file, |
984 |
const int line) { |
985 |
CheckIntegerSet check_integer_set; |
986 |
@@ -1954,8 +1954,8 @@ void _assert_in_set(const LargestIntegralType value, |
987 |
} |
988 |
} |
989 |
|
990 |
-void _assert_not_in_set(const LargestIntegralType value, |
991 |
- const LargestIntegralType values[], |
992 |
+void _assert_not_in_set(const uintmax_t value, |
993 |
+ const uintmax_t values[], |
994 |
const size_t number_of_values, const char* const file, |
995 |
const int line) { |
996 |
CheckIntegerSet check_integer_set; |
997 |
@@ -3079,8 +3079,8 @@ int _cmocka_run_group_tests(const char *group_name, |
998 |
size_t i; |
999 |
int rc; |
1000 |
|
1001 |
- /* Make sure LargestIntegralType is at least the size of a pointer. */ |
1002 |
- assert_true(sizeof(LargestIntegralType) >= sizeof(void*)); |
1003 |
+ /* Make sure uintmax_t is at least the size of a pointer. */ |
1004 |
+ assert_true(sizeof(uintmax_t) >= sizeof(void*)); |
1005 |
|
1006 |
cm_tests = libc_calloc(1, sizeof(struct CMUnitTestState) * num_tests); |
1007 |
if (cm_tests == NULL) { |
1008 |
@@ -3370,8 +3370,8 @@ int _run_tests(const UnitTest * const tests, const size_t number_of_tests) { |
1009 |
print_message("[==========] Running %"PRIdS " test(s).\n", |
1010 |
number_of_tests - setups - teardowns); |
1011 |
|
1012 |
- /* Make sure LargestIntegralType is at least the size of a pointer. */ |
1013 |
- assert_true(sizeof(LargestIntegralType) >= sizeof(void*)); |
1014 |
+ /* Make sure uintmax_t is at least the size of a pointer. */ |
1015 |
+ assert_true(sizeof(uintmax_t) >= sizeof(void*)); |
1016 |
|
1017 |
while (current_test < number_of_tests) { |
1018 |
const ListNode *test_check_point = NULL; |
1019 |
diff --git a/tests/test_alloc.c b/tests/test_alloc.c |
1020 |
index 966814a..3948084 100644 |
1021 |
--- tests/test_alloc.c |
1022 |
+++ tests/test_alloc.c |
1023 |
@@ -3,6 +3,7 @@ |
1024 |
#include <stdarg.h> |
1025 |
#include <stddef.h> |
1026 |
#include <setjmp.h> |
1027 |
+#include <stdint.h> |
1028 |
#include <cmocka.h> |
1029 |
#include <cmocka_private.h> |
1030 |
|
1031 |
diff --git a/tests/test_assert_macros.c b/tests/test_assert_macros.c |
1032 |
index 1a00880..3a7a0fe 100644 |
1033 |
--- tests/test_assert_macros.c |
1034 |
+++ tests/test_assert_macros.c |
1035 |
@@ -3,6 +3,7 @@ |
1036 |
#include <stdarg.h> |
1037 |
#include <stddef.h> |
1038 |
#include <setjmp.h> |
1039 |
+#include <stdint.h> |
1040 |
#include <cmocka.h> |
1041 |
#include <cmocka_private.h> |
1042 |
|
1043 |
diff --git a/tests/test_assert_macros_fail.c b/tests/test_assert_macros_fail.c |
1044 |
index aea919a..fc354d4 100644 |
1045 |
--- tests/test_assert_macros_fail.c |
1046 |
+++ tests/test_assert_macros_fail.c |
1047 |
@@ -3,6 +3,7 @@ |
1048 |
#include <stdarg.h> |
1049 |
#include <stddef.h> |
1050 |
#include <setjmp.h> |
1051 |
+#include <stdint.h> |
1052 |
#include <cmocka.h> |
1053 |
#include <cmocka_private.h> |
1054 |
|
1055 |
diff --git a/tests/test_basics.c b/tests/test_basics.c |
1056 |
inde 1bb493f..9866d81 100644 |
1057 |
--- tests/test_basics.c |
1058 |
+++ tests/test_basics.c |
1059 |
@@ -20,6 +20,7 @@ |
1060 |
#include <stdarg.h> |
1061 |
#include <stddef.h> |
1062 |
#include <setjmp.h> |
1063 |
+#include <stdint.h> |
1064 |
#include <cmocka.h> |
1065 |
|
1066 |
static int setup(void **state) { |
1067 |
diff --git a/tests/test_cmockery.c b/tests/test_cmockery.c |
1068 |
index 83a7451..027b1ac 100644 |
1069 |
--- tests/test_cmockery.c |
1070 |
+++ tests/test_cmockery.c |
1071 |
@@ -17,6 +17,7 @@ |
1072 |
#include <stdarg.h> |
1073 |
#include <stddef.h> |
1074 |
#include <setjmp.h> |
1075 |
+#include <stdint.h> |
1076 |
#include <cmockery/cmockery.h> |
1077 |
|
1078 |
/* A test case that does nothing and succeeds. */ |
1079 |
diff --git a/tests/test_double_macros.c b/tests/test_double_macros.c |
1080 |
index 138c579..b892272 100644 |
1081 |
--- tests/test_double_macros.c |
1082 |
+++ tests/test_double_macros.c |
1083 |
@@ -20,6 +20,7 @@ |
1084 |
#include <stdarg.h> |
1085 |
#include <stddef.h> |
1086 |
#include <setjmp.h> |
1087 |
+#include <stdint.h> |
1088 |
#include <cmocka.h> |
1089 |
|
1090 |
/* A test case that does check if double is equal. */ |
1091 |
diff --git a/tests/test_exception_handler.c b/tests/test_exception_handler.c |
1092 |
index 23c19cd..769eed8 100644 |
1093 |
--- tests/test_exception_handler.c |
1094 |
+++ tests/test_exception_handler.c |
1095 |
@@ -1,6 +1,7 @@ |
1096 |
#include <stdarg.h> |
1097 |
#include <stddef.h> |
1098 |
#include <setjmp.h> |
1099 |
+#include <stdint.h> |
1100 |
#include <cmocka.h> |
1101 |
|
1102 |
#include <signal.h> |
1103 |
diff --git a/tests/test_fixtures.c b/tests/test_fixtures.c |
1104 |
index 6d39487..e6d05d1 100644 |
1105 |
--- tests/test_fixtures.c |
1106 |
+++ tests/test_fixtures.c |
1107 |
@@ -1,6 +1,7 @@ |
1108 |
#include <stdarg.h> |
1109 |
#include <stddef.h> |
1110 |
#include <setjmp.h> |
1111 |
+#include <stdint.h> |
1112 |
#include <cmocka.h> |
1113 |
|
1114 |
#include <stdlib.h> |
1115 |
diff --git a/tests/test_float_macros.c b/tests/test_float_macros.c |
1116 |
index a9c7251..6ce8906 100644 |
1117 |
--- tests/test_float_macros.c |
1118 |
+++ tests/test_float_macros.c |
1119 |
@@ -20,6 +20,7 @@ |
1120 |
#include <stdarg.h> |
1121 |
#include <stddef.h> |
1122 |
#include <setjmp.h> |
1123 |
+#include <stdint.h> |
1124 |
#include <cmocka.h> |
1125 |
|
1126 |
/* A test case that does check if float is equal. */ |
1127 |
diff --git a/tests/test_group_fixtures.c b/tests/test_group_fixtures.c |
1128 |
index 64f0ab7..e9b4ad3 100644 |
1129 |
--- tests/test_group_fixtures.c |
1130 |
+++ tests/test_group_fixtures.c |
1131 |
@@ -4,6 +4,7 @@ |
1132 |
#include <stdarg.h> |
1133 |
#include <stddef.h> |
1134 |
#include <setjmp.h> |
1135 |
+#include <stdint.h> |
1136 |
#include <cmocka.h> |
1137 |
|
1138 |
static int group_setup(void **state) |
1139 |
diff --git a/tests/test_group_setup_assert.c b/tests/test_group_setup_assert.c |
1140 |
index eef61f8..92f88b6 100644 |
1141 |
--- tests/test_group_setup_assert.c |
1142 |
+++ tests/test_group_setup_assert.c |
1143 |
@@ -4,6 +4,7 @@ |
1144 |
#include <stdarg.h> |
1145 |
#include <stddef.h> |
1146 |
#include <setjmp.h> |
1147 |
+#include <stdint.h> |
1148 |
#include <cmocka.h> |
1149 |
|
1150 |
static int group_setup_failing(void **state) |
1151 |
diff --git a/tests/test_group_setup_fail.c b/tests/test_group_setup_fail.c |
1152 |
index 7815c03..1f2e701 100644 |
1153 |
--- tests/test_group_setup_fail.c |
1154 |
+++ tests/test_group_setup_fail.c |
1155 |
@@ -4,6 +4,7 @@ |
1156 |
#include <stdarg.h> |
1157 |
#include <stddef.h> |
1158 |
#include <setjmp.h> |
1159 |
+#include <stdint.h> |
1160 |
#include <cmocka.h> |
1161 |
|
1162 |
static int group_setup_failing(void **state) |
1163 |
diff --git a/tests/test_groups.c b/tests/test_groups.c |
1164 |
index af9e2b8..ea936c0 100644 |
1165 |
--- tests/test_groups.c |
1166 |
+++ tests/test_groups.c |
1167 |
@@ -20,6 +20,7 @@ |
1168 |
#include <stdarg.h> |
1169 |
#include <stddef.h> |
1170 |
#include <setjmp.h> |
1171 |
+#include <stdint.h> |
1172 |
#include <cmocka.h> |
1173 |
|
1174 |
static int setup(void **state) { |
1175 |
diff --git a/tests/test_ordering.c b/tests/test_ordering.c |
1176 |
index 817c0ba..fab2568 100644 |
1177 |
--- tests/test_ordering.c |
1178 |
+++ tests/test_ordering.c |
1179 |
@@ -3,6 +3,7 @@ |
1180 |
#include <stdarg.h> |
1181 |
#include <stddef.h> |
1182 |
#include <setjmp.h> |
1183 |
+#include <stdint.h> |
1184 |
#include <cmocka.h> |
1185 |
#include <cmocka_private.h> |
1186 |
|
1187 |
diff --git a/tests/test_ordering_fail.c b/tests/test_ordering_fail.c |
1188 |
index 652f5ad..88b4e29 100644 |
1189 |
--- tests/test_ordering_fail.c |
1190 |
+++ tests/test_ordering_fail.c |
1191 |
@@ -3,6 +3,7 @@ |
1192 |
#include <stdarg.h> |
1193 |
#include <stddef.h> |
1194 |
#include <setjmp.h> |
1195 |
+#include <stdint.h> |
1196 |
#include <cmocka.h> |
1197 |
#include <cmocka_private.h> |
1198 |
|
1199 |
diff --git a/tests/test_returns.c b/tests/test_returns.c |
1200 |
index b9370c9..574fa00 100644 |
1201 |
--- tests/test_returns.c |
1202 |
+++ tests/test_returns.c |
1203 |
@@ -3,6 +3,7 @@ |
1204 |
#include <stdarg.h> |
1205 |
#include <stddef.h> |
1206 |
#include <setjmp.h> |
1207 |
+#include <stdint.h> |
1208 |
#include <cmocka.h> |
1209 |
#include <cmocka_private.h> |
1210 |
|
1211 |
diff --git a/tests/test_returns_fail.c b/tests/test_returns_fail.c |
1212 |
index 81197d3..fa7f291 100644 |
1213 |
--- tests/test_returns_fail.c |
1214 |
+++ tests/test_returns_fail.c |
1215 |
@@ -3,6 +3,7 @@ |
1216 |
#include <stdarg.h> |
1217 |
#include <stddef.h> |
1218 |
#include <setjmp.h> |
1219 |
+#include <stdint.h> |
1220 |
#include <cmocka.h> |
1221 |
#include <cmocka_private.h> |
1222 |
|
1223 |
diff --git a/tests/test_setup_fail.c b/tests/test_setup_fail.c |
1224 |
index e3f8df8..9affaa6 100644 |
1225 |
--- tests/test_setup_fail.c |
1226 |
+++ tests/test_setup_fail.c |
1227 |
@@ -3,6 +3,7 @@ |
1228 |
#include <stdarg.h> |
1229 |
#include <stddef.h> |
1230 |
#include <setjmp.h> |
1231 |
+#include <stdint.h> |
1232 |
#include <cmocka.h> |
1233 |
|
1234 |
static int setup_fail(void **state) { |
1235 |
diff --git a/tests/test_skip.c b/tests/test_skip.c |
1236 |
index 127161a..0a6953d 100644 |
1237 |
--- tests/test_skip.c |
1238 |
+++ tests/test_skip.c |
1239 |
@@ -17,6 +17,7 @@ |
1240 |
#include <stdarg.h> |
1241 |
#include <stddef.h> |
1242 |
#include <setjmp.h> |
1243 |
+#include <stdint.h> |
1244 |
#include <cmocka.h> |
1245 |
|
1246 |
/* A test case that does check if an int is equal. */ |
1247 |
diff --git a/tests/test_skip_filter.c b/tests/test_skip_filter.c |
1248 |
index e40209e..56dc262 100644 |
1249 |
--- tests/test_skip_filter.c |
1250 |
+++ tests/test_skip_filter.c |
1251 |
@@ -19,6 +19,7 @@ |
1252 |
#include <stdarg.h> |
1253 |
#include <stddef.h> |
1254 |
#include <setjmp.h> |
1255 |
+#include <stdint.h> |
1256 |
#include <cmocka.h> |
1257 |
|
1258 |
static void test_skip1(void **state) |
1259 |
diff --git a/tests/test_strmatch.c b/tests/test_strmatch.c |
1260 |
index f2d966b..f8d088c 100644 |
1261 |
--- tests/test_strmatch.c |
1262 |
+++ tests/test_strmatch.c |
1263 |
@@ -19,6 +19,7 @@ |
1264 |
#include <stdarg.h> |
1265 |
#include <stddef.h> |
1266 |
#include <setjmp.h> |
1267 |
+#include <stdint.h> |
1268 |
#include <cmocka.h> |
1269 |
|
1270 |
#include "../src/cmocka.c" |
1271 |
diff --git a/tests/test_wildcard.c b/tests/test_wildcard.c |
1272 |
index 10ee195..3b85bb3 100644 |
1273 |
--- tests/test_wildcard.c |
1274 |
+++ tests/test_wildcard.c |
1275 |
@@ -17,6 +17,7 @@ |
1276 |
#include <stdarg.h> |
1277 |
#include <stddef.h> |
1278 |
#include <setjmp.h> |
1279 |
+#include <stdint.h> |
1280 |
#include <cmocka.h> |
1281 |
|
1282 |
static void test_ok1(void **state) |