diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2015-02-11 07:55:47 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2015-02-11 17:08:56 +0100 |
commit | f02f7357187e9b80da1dd7539333bc0c3a134987 (patch) | |
tree | 5da55c29608d90e1ebab4a6a4012b9f4dec537e0 /include/cmocka.h | |
parent | c1332c257e73cb4c8f07158a4d6b639b6d6fb291 (diff) | |
download | cmocka-f02f7357187e9b80da1dd7539333bc0c3a134987.tar.gz cmocka-f02f7357187e9b80da1dd7539333bc0c3a134987.tar.bz2 cmocka-f02f7357187e9b80da1dd7539333bc0c3a134987.zip |
include: Fix pointer casting and add check_expected_ptr()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'include/cmocka.h')
-rw-r--r-- | include/cmocka.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/include/cmocka.h b/include/cmocka.h index b699652..d1c057b 100644 --- a/include/cmocka.h +++ b/include/cmocka.h @@ -116,7 +116,7 @@ int __stdcall IsDebuggerPresent(); /* Perform an unsigned cast to uintptr_t. */ #define cast_to_pointer_integral_type(value) \ - ((uintptr_t)(value)) + ((uintptr_t)((size_t)(value))) /* Perform a cast of a pointer to uintmax_t */ #define cast_ptr_to_largest_integral_type(value) \ @@ -948,6 +948,24 @@ void check_expected(#parameter); cast_to_largest_integral_type(parameter)) #endif +#ifdef DOXYGEN +/** + * @brief Determine whether a function parameter is correct. + * + * This ensures the next value queued by one of the expect_*() macros matches + * the specified variable. + * + * This function needs to be called in the mock object. + * + * @param[in] #parameter The pointer to check. + */ +void check_expected_ptr(#parameter); +#else +#define check_expected_ptr(parameter) \ + _check_expected(__func__, #parameter, __FILE__, __LINE__, \ + cast_ptr_to_largest_integral_type(parameter)) +#endif + /** @} */ /** |