Patch-Source: https://gitlab.com/cmocka/cmocka/-/commit/0e70150002ab7bcb626109b287f23c62ecf97565 -- From 0e70150002ab7bcb626109b287f23c62ecf97565 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 5 Oct 2020 13:28:11 +0200 Subject: [PATCH] cmocka: Replace LargestIntegralType with uintmax_t This requires #include Fixes #38 Fixes #49 --- example/allocate_module_test.c | 1 + example/assert_macro_test.c | 1 + example/assert_module_test.c | 1 + example/calculator_test.c | 1 + example/mock/chef_wrap/chef.c | 1 + example/mock/chef_wrap/waiter_test_wrap.c | 1 + include/cmocka.h | 162 ++++++++-------------- src/cmocka.c | 148 ++++++++++---------- tests/test_alloc.c | 1 + tests/test_assert_macros.c | 1 + tests/test_assert_macros_fail.c | 1 + tests/test_basics.c | 1 + tests/test_cmockery.c | 1 + tests/test_double_macros.c | 1 + tests/test_exception_handler.c | 1 + tests/test_fixtures.c | 1 + tests/test_float_macros.c | 1 + tests/test_group_fixtures.c | 1 + tests/test_group_setup_assert.c | 1 + tests/test_group_setup_fail.c | 1 + tests/test_groups.c | 1 + tests/test_ordering.c | 1 + tests/test_ordering_fail.c | 1 + tests/test_returns.c | 1 + tests/test_returns_fail.c | 1 + tests/test_setup_fail.c | 1 + tests/test_skip.c | 1 + tests/test_skip_filter.c | 1 + tests/test_strmatch.c | 1 + tests/test_wildcard.c | 1 + 30 files changed, 156 insertions(+), 182 deletions(-) diff --git a/example/allocate_module_test.c b/example/allocate_module_test.c index 562aea2..eb3602f 100644 --- example/allocate_module_test.c +++ example/allocate_module_test.c @@ -16,6 +16,7 @@ #include #include #include +#include #include extern void leak_memory(void); diff --git a/example/assert_macro_test.c b/example/assert_macro_test.c index 2cd355c..093a884 100644 --- example/assert_macro_test.c +++ example/assert_macro_test.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include "assert_macro.h" diff --git a/example/assert_module_test.c b/example/assert_module_test.c index f387754..41b5a75 100644 --- example/assert_module_test.c +++ example/assert_module_test.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include "assert_module.h" diff --git a/example/calculator_test.c b/example/calculator_test.c index ab8cad8..a3d862a 100644 --- example/calculator_test.c +++ example/calculator_test.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "cmocka.h" #include diff --git a/example/mock/chef_wrap/chef.c b/example/mock/chef_wrap/chef.c index 1429cde..1c74125 100644 --- example/mock/chef_wrap/chef.c +++ example/mock/chef_wrap/chef.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include diff --git a/example/mock/chef_wrap/waiter_test_wrap.c b/example/mock/chef_wrap/waiter_test_wrap.c index 4146818..04fe721 100644 --- example/mock/chef_wrap/waiter_test_wrap.c +++ example/mock/chef_wrap/waiter_test_wrap.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "waiter_test_wrap.h" diff --git a/include/cmocka.h b/include/cmocka.h index a21d965..6f56520 100644 --- include/cmocka.h +++ include/cmocka.h @@ -57,32 +57,13 @@ int __stdcall IsDebuggerPresent(); * @{ */ -/* If __WORDSIZE is not set, try to figure it out and default to 32 bit. */ -#ifndef __WORDSIZE -# if (defined(__x86_64__) && !defined(__ILP32__)) || defined(__sparc_v9__) || defined(__sparcv9) -# define __WORDSIZE 64 -# else -# define __WORDSIZE 32 -# endif -#endif +/* XXX: stdint.h is a new requirement to include, but things haven't adapted + to it yet, so include it here too. + since it's a requirement to use the header at all, there's no harm in + including it? */ +#include -#ifdef DOXYGEN -/** - * Largest integral type. This type should be large enough to hold any - * pointer or integer supported by the compiler. - */ -typedef uintmax_t LargestIntegralType; -#else /* DOXGEN */ -#ifndef LargestIntegralType -# if __WORDSIZE == 64 && !defined(_WIN64) -# define LargestIntegralType unsigned long int -# else -# define LargestIntegralType unsigned long long int -# endif -#endif /* LargestIntegralType */ -#endif /* DOXYGEN */ - -/* Printf format used to display LargestIntegralType as a hexidecimal. */ +/* Printf format used to display uintmax_t as a hexidecimal. */ #ifndef LargestIntegralTypePrintfFormat # ifdef _WIN32 # define LargestIntegralTypePrintfFormat "0x%I64x" @@ -95,7 +76,7 @@ typedef uintmax_t LargestIntegralType; # endif /* _WIN32 */ #endif /* LargestIntegralTypePrintfFormat */ -/* Printf format used to display LargestIntegralType as a decimal. */ +/* Printf format used to display uintmax_t as a decimal. */ #ifndef LargestIntegralTypePrintfFormatDecimal # ifdef _WIN32 # define LargestIntegralTypePrintfFormatDecimal "%I64u" @@ -116,44 +97,15 @@ typedef uintmax_t LargestIntegralType; # define DoublePrintfFormat "%f" #endif /* DoublePrintfFormat */ -/* Perform an unsigned cast to LargestIntegralType. */ +/* Perform an unsigned cast to uintmax_t. */ #define cast_to_largest_integral_type(value) \ - ((LargestIntegralType)(value)) - -/* Smallest integral type capable of holding a pointer. */ -#if !defined(_UINTPTR_T) && !defined(_UINTPTR_T_DEFINED) && !defined(HAVE_UINTPTR_T) -# if defined(_WIN32) - /* WIN32 is an ILP32 platform */ - typedef unsigned int uintptr_t; -# elif defined(_WIN64) - typedef unsigned long int uintptr_t; -# else /* _WIN32 */ - -/* ILP32 and LP64 platforms */ -# ifdef __WORDSIZE /* glibc */ -# if __WORDSIZE == 64 - typedef unsigned long int uintptr_t; -# else - typedef unsigned int uintptr_t; -# endif /* __WORDSIZE == 64 */ -# else /* __WORDSIZE */ -# if defined(_LP64) || defined(_I32LPx) - typedef unsigned long int uintptr_t; -# else - typedef unsigned int uintptr_t; -# endif -# endif /* __WORDSIZE */ -# endif /* _WIN32 */ - -# define _UINTPTR_T -# define _UINTPTR_T_DEFINED -#endif /* !defined(_UINTPTR_T) || !defined(_UINTPTR_T_DEFINED) */ + ((uintmax_t)(value)) /* Perform an unsigned cast to uintptr_t. */ #define cast_to_pointer_integral_type(value) \ - ((uintptr_t)((size_t)(value))) + ((uintptr_t)(value)) -/* Perform a cast of a pointer to LargestIntegralType */ +/* Perform a cast of a pointer to uintmax_t */ #define cast_ptr_to_largest_integral_type(value) \ cast_to_largest_integral_type(cast_to_pointer_integral_type(value)) @@ -240,7 +192,7 @@ cast_to_largest_integral_type(cast_to_pointer_integral_type(value)) * * @see will_return() */ -LargestIntegralType mock(void); +uintmax_t mock(void); #else #define mock() _mock(__func__, __FILE__, __LINE__) #endif @@ -324,7 +276,7 @@ type mock_ptr_type(#type); * @see mock() * @see will_return_count() */ -void will_return(#function, LargestIntegralType value); +void will_return(#function, uintmax_t value); #else #define will_return(function, value) \ _will_return(#function, __FILE__, __LINE__, \ @@ -347,7 +299,7 @@ void will_return(#function, LargestIntegralType value); * * @see mock() */ -void will_return_count(#function, LargestIntegralType value, int count); +void will_return_count(#function, uintmax_t value, int count); #else #define will_return_count(function, value, count) \ _will_return(#function, __FILE__, __LINE__, \ @@ -370,7 +322,7 @@ void will_return_count(#function, LargestIntegralType value, int count); * @see will_return_count() * @see mock() */ -void will_return_always(#function, LargestIntegralType value); +void will_return_always(#function, uintmax_t value); #else #define will_return_always(function, value) \ will_return_count(function, (value), WILL_RETURN_ALWAYS) @@ -398,7 +350,7 @@ void will_return_always(#function, LargestIntegralType value); * @see will_return_count() * @see mock() */ -void will_return_maybe(#function, LargestIntegralType value); +void will_return_maybe(#function, uintmax_t value); #else #define will_return_maybe(function, value) \ will_return_count(function, (value), WILL_RETURN_ONCE) @@ -494,7 +446,7 @@ void expect_check(#function, #parameter, #check_function, const void *check_data * * @see check_expected(). */ -void expect_in_set(#function, #parameter, LargestIntegralType value_array[]); +void expect_in_set(#function, #parameter, uintmax_t value_array[]); #else #define expect_in_set(function, parameter, value_array) \ expect_in_set_count(function, parameter, value_array, 1) @@ -519,7 +471,7 @@ void expect_in_set(#function, #parameter, LargestIntegralType value_array[]); * * @see check_expected(). */ -void expect_in_set_count(#function, #parameter, LargestIntegralType value_array[], size_t count); +void expect_in_set_count(#function, #parameter, uintmax_t value_array[], size_t count); #else #define expect_in_set_count(function, parameter, value_array, count) \ _expect_in_set(#function, #parameter, __FILE__, __LINE__, value_array, \ @@ -541,7 +493,7 @@ void expect_in_set_count(#function, #parameter, LargestIntegralType value_array[ * * @see check_expected(). */ -void expect_not_in_set(#function, #parameter, LargestIntegralType value_array[]); +void expect_not_in_set(#function, #parameter, uintmax_t value_array[]); #else #define expect_not_in_set(function, parameter, value_array) \ expect_not_in_set_count(function, parameter, value_array, 1) @@ -566,7 +518,7 @@ void expect_not_in_set(#function, #parameter, LargestIntegralType value_array[]) * * @see check_expected(). */ -void expect_not_in_set_count(#function, #parameter, LargestIntegralType value_array[], size_t count); +void expect_not_in_set_count(#function, #parameter, uintmax_t value_array[], size_t count); #else #define expect_not_in_set_count(function, parameter, value_array, count) \ _expect_not_in_set( \ @@ -592,7 +544,7 @@ void expect_not_in_set_count(#function, #parameter, LargestIntegralType value_ar * * @see check_expected(). */ -void expect_in_range(#function, #parameter, LargestIntegralType minimum, LargestIntegralType maximum); +void expect_in_range(#function, #parameter, uintmax_t minimum, uintmax_t maximum); #else #define expect_in_range(function, parameter, minimum, maximum) \ expect_in_range_count(function, parameter, minimum, maximum, 1) @@ -619,7 +571,7 @@ void expect_in_range(#function, #parameter, LargestIntegralType minimum, Largest * * @see check_expected(). */ -void expect_in_range_count(#function, #parameter, LargestIntegralType minimum, LargestIntegralType maximum, size_t count); +void expect_in_range_count(#function, #parameter, uintmax_t minimum, uintmax_t maximum, size_t count); #else #define expect_in_range_count(function, parameter, minimum, maximum, count) \ _expect_in_range(#function, #parameter, __FILE__, __LINE__, minimum, \ @@ -643,7 +595,7 @@ void expect_in_range_count(#function, #parameter, LargestIntegralType minimum, L * * @see check_expected(). */ -void expect_not_in_range(#function, #parameter, LargestIntegralType minimum, LargestIntegralType maximum); +void expect_not_in_range(#function, #parameter, uintmax_t minimum, uintmax_t maximum); #else #define expect_not_in_range(function, parameter, minimum, maximum) \ expect_not_in_range_count(function, parameter, minimum, maximum, 1) @@ -670,7 +622,7 @@ void expect_not_in_range(#function, #parameter, LargestIntegralType minimum, Lar * * @see check_expected(). */ -void expect_not_in_range_count(#function, #parameter, LargestIntegralType minimum, LargestIntegralType maximum, size_t count); +void expect_not_in_range_count(#function, #parameter, uintmax_t minimum, uintmax_t maximum, size_t count); #else #define expect_not_in_range_count(function, parameter, minimum, maximum, \ count) \ @@ -695,7 +647,7 @@ void expect_not_in_range_count(#function, #parameter, LargestIntegralType minimu * @see expect_memory() * @see expect_any() */ -void expect_value(#function, #parameter, LargestIntegralType value); +void expect_value(#function, #parameter, uintmax_t value); #else #define expect_value(function, parameter, value) \ expect_value_count(function, parameter, value, 1) @@ -722,7 +674,7 @@ void expect_value(#function, #parameter, LargestIntegralType value); * @see expect_not_string() * @see expect_not_memory() */ -void expect_value_count(#function, #parameter, LargestIntegralType value, size_t count); +void expect_value_count(#function, #parameter, uintmax_t value, size_t count); #else #define expect_value_count(function, parameter, value, count) \ _expect_value(#function, #parameter, __FILE__, __LINE__, \ @@ -743,7 +695,7 @@ void expect_value_count(#function, #parameter, LargestIntegralType value, size_t * * @see check_expected(). */ -void expect_not_value(#function, #parameter, LargestIntegralType value); +void expect_not_value(#function, #parameter, uintmax_t value); #else #define expect_not_value(function, parameter, value) \ expect_not_value_count(function, parameter, value, 1) @@ -767,7 +719,7 @@ void expect_not_value(#function, #parameter, LargestIntegralType value); * * @see check_expected(). */ -void expect_not_value_count(#function, #parameter, LargestIntegralType value, size_t count); +void expect_not_value_count(#function, #parameter, uintmax_t value, size_t count); #else #define expect_not_value_count(function, parameter, value, count) \ _expect_not_value(#function, #parameter, __FILE__, __LINE__, \ @@ -1438,7 +1390,7 @@ void assert_memory_not_equal(const void *a, const void *b, size_t size); * * @param[in] maximum The maximum value allowed. */ -void assert_in_range(LargestIntegralType value, LargestIntegralType minimum, LargestIntegralType maximum); +void assert_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum); #else #define assert_in_range(value, minimum, maximum) \ _assert_in_range( \ @@ -1461,7 +1413,7 @@ void assert_in_range(LargestIntegralType value, LargestIntegralType minimum, Lar * * @param[in] maximum The maximum value to compare. */ -void assert_not_in_range(LargestIntegralType value, LargestIntegralType minimum, LargestIntegralType maximum); +void assert_not_in_range(uintmax_t value, uintmax_t minimum, uintmax_t maximum); #else #define assert_not_in_range(value, minimum, maximum) \ _assert_not_in_range( \ @@ -1483,7 +1435,7 @@ void assert_not_in_range(LargestIntegralType value, LargestIntegralType minimum, * * @param[in] count The size of the values array. */ -void assert_in_set(LargestIntegralType value, LargestIntegralType values[], size_t count); +void assert_in_set(uintmax_t value, uintmax_t values[], size_t count); #else #define assert_in_set(value, values, number_of_values) \ _assert_in_set(value, values, number_of_values, __FILE__, __LINE__) @@ -1502,7 +1454,7 @@ void assert_in_set(LargestIntegralType value, LargestIntegralType values[], size * * @param[in] count The size of the values array. */ -void assert_not_in_set(LargestIntegralType value, LargestIntegralType values[], size_t count); +void assert_not_in_set(uintmax_t value, uintmax_t values[], size_t count); #else #define assert_not_in_set(value, values, number_of_values) \ _assert_not_in_set(value, values, number_of_values, __FILE__, __LINE__) @@ -2181,8 +2133,8 @@ void expect_assert_failure(function fn_call); typedef void (*UnitTestFunction)(void **state); /* Function that determines whether a function parameter value is correct. */ -typedef int (*CheckParameterValue)(const LargestIntegralType value, - const LargestIntegralType check_value_data); +typedef int (*CheckParameterValue)(const uintmax_t value, + const uintmax_t check_value_data); /* Type of the unit test function. */ typedef enum UnitTestFunctionType { @@ -2236,7 +2188,7 @@ typedef struct CheckParameterEvent { SourceLocation location; const char *parameter_name; CheckParameterValue check_value; - LargestIntegralType check_value_data; + uintmax_t check_value_data; } CheckParameterEvent; /* Used by expect_assert_failure() and mock_assert(). */ @@ -2245,7 +2197,7 @@ extern jmp_buf global_expect_assert_env; extern const char * global_last_failed_assert; /* Retrieves a value for the given function, as set by "will_return". */ -LargestIntegralType _mock(const char * const function, const char* const file, +uintmax_t _mock(const char * const function, const char* const file, const int line); void _expect_function_call( @@ -2261,36 +2213,36 @@ void _expect_check( const char* const function, const char* const parameter, const char* const file, const int line, const CheckParameterValue check_function, - const LargestIntegralType check_data, CheckParameterEvent * const event, + const uintmax_t check_data, CheckParameterEvent * const event, const int count); void _expect_in_set( const char* const function, const char* const parameter, - const char* const file, const int line, const LargestIntegralType values[], + const char* const file, const int line, const uintmax_t values[], const size_t number_of_values, const int count); void _expect_not_in_set( const char* const function, const char* const parameter, - const char* const file, const int line, const LargestIntegralType values[], + const char* const file, const int line, const uintmax_t values[], const size_t number_of_values, const int count); void _expect_in_range( const char* const function, const char* const parameter, const char* const file, const int line, - const LargestIntegralType minimum, - const LargestIntegralType maximum, const int count); + const uintmax_t minimum, + const uintmax_t maximum, const int count); void _expect_not_in_range( const char* const function, const char* const parameter, const char* const file, const int line, - const LargestIntegralType minimum, - const LargestIntegralType maximum, const int count); + const uintmax_t minimum, + const uintmax_t maximum, const int count); void _expect_value( const char* const function, const char* const parameter, - const char* const file, const int line, const LargestIntegralType value, + const char* const file, const int line, const uintmax_t value, const int count); void _expect_not_value( const char* const function, const char* const parameter, - const char* const file, const int line, const LargestIntegralType value, + const char* const file, const int line, const uintmax_t value, const int count); void _expect_string( @@ -2317,17 +2269,17 @@ void _expect_any( void _check_expected( const char * const function_name, const char * const parameter_name, - const char* file, const int line, const LargestIntegralType value); + const char* file, const int line, const uintmax_t value); void _will_return(const char * const function_name, const char * const file, - const int line, const LargestIntegralType value, + const int line, const uintmax_t value, const int count); -void _assert_true(const LargestIntegralType result, +void _assert_true(const uintmax_t result, const char* const expression, const char * const file, const int line); -void _assert_return_code(const LargestIntegralType result, +void _assert_return_code(const uintmax_t result, size_t rlen, - const LargestIntegralType error, + const uintmax_t error, const char * const expression, const char * const file, const int line); @@ -2344,10 +2296,10 @@ void _assert_double_not_equal(const double a, const double n, const double epsilon, const char* const file, const int line); void _assert_int_equal( - const LargestIntegralType a, const LargestIntegralType b, + const uintmax_t a, const uintmax_t b, const char * const file, const int line); void _assert_int_not_equal( - const LargestIntegralType a, const LargestIntegralType b, + const uintmax_t a, const uintmax_t b, const char * const file, const int line); void _assert_string_equal(const char * const a, const char * const b, const char * const file, const int line); @@ -2360,16 +2312,16 @@ void _assert_memory_not_equal(const void * const a, const void * const b, const size_t size, const char* const file, const int line); void _assert_in_range( - const LargestIntegralType value, const LargestIntegralType minimum, - const LargestIntegralType maximum, const char* const file, const int line); + const uintmax_t value, const uintmax_t minimum, + const uintmax_t maximum, const char* const file, const int line); void _assert_not_in_range( - const LargestIntegralType value, const LargestIntegralType minimum, - const LargestIntegralType maximum, const char* const file, const int line); + const uintmax_t value, const uintmax_t minimum, + const uintmax_t maximum, const char* const file, const int line); void _assert_in_set( - const LargestIntegralType value, const LargestIntegralType values[], + const uintmax_t value, const uintmax_t values[], const size_t number_of_values, const char* const file, const int line); void _assert_not_in_set( - const LargestIntegralType value, const LargestIntegralType values[], + const uintmax_t value, const uintmax_t values[], const size_t number_of_values, const char* const file, const int line); void* _test_malloc(const size_t size, const char* file, const int line); diff --git a/src/cmocka.c b/src/cmocka.c index 52897e1..62d4284 100644 --- src/cmocka.c +++ src/cmocka.c @@ -1,6 +1,6 @@ /* * Copyright 2008 Google Inc. - * Copyright 2014-2018 Andreas Schneider + * Copyright 2014-2020 Andreas Schneider * Copyright 2015 Jakub Hrozek * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -111,14 +111,14 @@ /* - * Declare and initialize a LargestIntegralType variable name + * Declare and initialize a uintmax_t variable name * with value the conversion of ptr. */ #define declare_initialize_value_pointer_pointer(name, ptr) \ - LargestIntegralType name ; \ - name = (LargestIntegralType) (uintptr_t) ptr + uintmax_t name ; \ + name = (uintmax_t)((uintptr_t)(ptr)) -/* Cast a LargestIntegralType to pointer_type. */ +/* Cast a uintmax_t to pointer_type. */ #define cast_largest_integral_type_to_pointer( \ pointer_type, largest_integral_type) \ ((pointer_type)(uintptr_t)(largest_integral_type)) @@ -158,7 +158,7 @@ typedef int (*EqualityFunction)(const void *left, const void *right); /* Value of a symbol and the place it was declared. */ typedef struct SymbolValue { SourceLocation location; - LargestIntegralType value; + uintmax_t value; } SymbolValue; /* @@ -183,14 +183,14 @@ typedef void (*CleanupListValue)(const void *value, void *cleanup_value_data); /* Structure used to check the range of integer types.a */ typedef struct CheckIntegerRange { CheckParameterEvent event; - LargestIntegralType minimum; - LargestIntegralType maximum; + uintmax_t minimum; + uintmax_t maximum; } CheckIntegerRange; /* Structure used to check whether an integer value is in a set. */ typedef struct CheckIntegerSet { CheckParameterEvent event; - const LargestIntegralType *set; + const uintmax_t *set; size_t size_of_set; } CheckIntegerSet; @@ -702,7 +702,7 @@ static void free_value(const void *value, void *cleanup_value_data) { static void free_symbol_map_value(const void *value, void *cleanup_value_data) { SymbolMapValue * const map_value = (SymbolMapValue*)value; - const LargestIntegralType children = cast_ptr_to_largest_integral_type(cleanup_value_data); + const uintmax_t children = cast_ptr_to_largest_integral_type(cleanup_value_data); assert_non_null(value); if (children == 0) { list_free(&map_value->symbol_values_list_head, @@ -947,14 +947,14 @@ static size_t check_for_leftover_values( /* Get the next return value for the specified mock function. */ -LargestIntegralType _mock(const char * const function, const char* const file, +uintmax_t _mock(const char * const function, const char* const file, const int line) { void *result; const int rc = get_symbol_value(&global_function_result_map_head, &function, 1, &result); if (rc) { SymbolValue * const symbol = (SymbolValue*)result; - const LargestIntegralType value = symbol->value; + const uintmax_t value = symbol->value; global_last_mock_value_location = symbol->location; if (rc == 1) { free(symbol); @@ -1055,7 +1055,7 @@ void _function_called(const char *const function, /* Add a return value for the specified mock function name. */ void _will_return(const char * const function_name, const char * const file, - const int line, const LargestIntegralType value, + const int line, const uintmax_t value, const int count) { SymbolValue * const return_value = (SymbolValue*)malloc(sizeof(*return_value)); @@ -1077,7 +1077,7 @@ void _expect_check( const char* const function, const char* const parameter, const char* const file, const int line, const CheckParameterValue check_function, - const LargestIntegralType check_data, + const uintmax_t check_data, CheckParameterEvent * const event, const int count) { CheckParameterEvent * const check = event ? event : (CheckParameterEvent*)malloc(sizeof(*check)); @@ -1241,8 +1241,8 @@ static int double_values_not_equal_display_error(const double left, /* Returns 1 if the specified values are equal. If the values are not equal * an error is displayed and 0 is returned. */ -static int values_equal_display_error(const LargestIntegralType left, - const LargestIntegralType right) { +static int values_equal_display_error(const uintmax_t left, + const uintmax_t right) { const int equal = left == right; if (!equal) { cm_print_error(LargestIntegralTypePrintfFormat " != " @@ -1254,8 +1254,8 @@ static int values_equal_display_error(const LargestIntegralType left, /* * Returns 1 if the specified values are not equal. If the values are equal * an error is displayed and 0 is returned. */ -static int values_not_equal_display_error(const LargestIntegralType left, - const LargestIntegralType right) { +static int values_not_equal_display_error(const uintmax_t left, + const uintmax_t right) { const int not_equal = left != right; if (!not_equal) { cm_print_error(LargestIntegralTypePrintfFormat " == " @@ -1273,12 +1273,12 @@ static int values_not_equal_display_error(const LargestIntegralType left, * displayed. */ static int value_in_set_display_error( - const LargestIntegralType value, + const uintmax_t value, const CheckIntegerSet * const check_integer_set, const int invert) { int succeeded = invert; assert_non_null(check_integer_set); { - const LargestIntegralType * const set = check_integer_set->set; + const uintmax_t * const set = check_integer_set->set; const size_t size_of_set = check_integer_set->size_of_set; size_t i; for (i = 0; i < size_of_set; i++) { @@ -1310,8 +1310,8 @@ static int value_in_set_display_error( * specified range an error is displayed and 0 is returned. */ static int integer_in_range_display_error( - const LargestIntegralType value, const LargestIntegralType range_min, - const LargestIntegralType range_max) { + const uintmax_t value, const uintmax_t range_min, + const uintmax_t range_max) { if (value >= range_min && value <= range_max) { return 1; } @@ -1330,8 +1330,8 @@ static int integer_in_range_display_error( * specified range an error is displayed and zero is returned. */ static int integer_not_in_range_display_error( - const LargestIntegralType value, const LargestIntegralType range_min, - const LargestIntegralType range_max) { + const uintmax_t value, const uintmax_t range_min, + const uintmax_t range_max) { if (value < range_min || value > range_max) { return 1; } @@ -1431,8 +1431,8 @@ static int memory_not_equal_display_error( /* CheckParameterValue callback to check whether a value is within a set. */ -static int check_in_set(const LargestIntegralType value, - const LargestIntegralType check_value_data) { +static int check_in_set(const uintmax_t value, + const uintmax_t check_value_data) { return value_in_set_display_error(value, cast_largest_integral_type_to_pointer(CheckIntegerSet*, check_value_data), 0); @@ -1440,8 +1440,8 @@ static int check_in_set(const LargestIntegralType value, /* CheckParameterValue callback to check whether a value isn't within a set. */ -static int check_not_in_set(const LargestIntegralType value, - const LargestIntegralType check_value_data) { +static int check_not_in_set(const uintmax_t value, + const uintmax_t check_value_data) { return value_in_set_display_error(value, cast_largest_integral_type_to_pointer(CheckIntegerSet*, check_value_data), 1); @@ -1453,12 +1453,12 @@ static int check_not_in_set(const LargestIntegralType value, static void expect_set( const char* const function, const char* const parameter, const char* const file, const int line, - const LargestIntegralType values[], const size_t number_of_values, + const uintmax_t values[], const size_t number_of_values, const CheckParameterValue check_function, const int count) { CheckIntegerSet * const check_integer_set = (CheckIntegerSet*)malloc(sizeof(*check_integer_set) + (sizeof(values[0]) * number_of_values)); - LargestIntegralType * const set = (LargestIntegralType*)( + uintmax_t * const set = (uintmax_t*)( check_integer_set + 1); declare_initialize_value_pointer_pointer(check_data, check_integer_set); assert_non_null(values); @@ -1476,7 +1476,7 @@ static void expect_set( void _expect_in_set( const char* const function, const char* const parameter, const char* const file, const int line, - const LargestIntegralType values[], const size_t number_of_values, + const uintmax_t values[], const size_t number_of_values, const int count) { expect_set(function, parameter, file, line, values, number_of_values, check_in_set, count); @@ -1487,7 +1487,7 @@ void _expect_in_set( void _expect_not_in_set( const char* const function, const char* const parameter, const char* const file, const int line, - const LargestIntegralType values[], const size_t number_of_values, + const uintmax_t values[], const size_t number_of_values, const int count) { expect_set(function, parameter, file, line, values, number_of_values, check_not_in_set, count); @@ -1495,8 +1495,8 @@ void _expect_not_in_set( /* CheckParameterValue callback to check whether a value is within a range. */ -static int check_in_range(const LargestIntegralType value, - const LargestIntegralType check_value_data) { +static int check_in_range(const uintmax_t value, + const uintmax_t check_value_data) { CheckIntegerRange * const check_integer_range = cast_largest_integral_type_to_pointer(CheckIntegerRange*, check_value_data); @@ -1507,8 +1507,8 @@ static int check_in_range(const LargestIntegralType value, /* CheckParameterValue callback to check whether a value is not within a range. */ -static int check_not_in_range(const LargestIntegralType value, - const LargestIntegralType check_value_data) { +static int check_not_in_range(const uintmax_t value, + const uintmax_t check_value_data) { CheckIntegerRange * const check_integer_range = cast_largest_integral_type_to_pointer(CheckIntegerRange*, check_value_data); @@ -1523,7 +1523,7 @@ static int check_not_in_range(const LargestIntegralType value, static void expect_range( const char* const function, const char* const parameter, const char* const file, const int line, - const LargestIntegralType minimum, const LargestIntegralType maximum, + const uintmax_t minimum, const uintmax_t maximum, const CheckParameterValue check_function, const int count) { CheckIntegerRange * const check_integer_range = (CheckIntegerRange*)malloc(sizeof(*check_integer_range)); @@ -1539,7 +1539,7 @@ static void expect_range( void _expect_in_range( const char* const function, const char* const parameter, const char* const file, const int line, - const LargestIntegralType minimum, const LargestIntegralType maximum, + const uintmax_t minimum, const uintmax_t maximum, const int count) { expect_range(function, parameter, file, line, minimum, maximum, check_in_range, count); @@ -1550,7 +1550,7 @@ void _expect_in_range( void _expect_not_in_range( const char* const function, const char* const parameter, const char* const file, const int line, - const LargestIntegralType minimum, const LargestIntegralType maximum, + const uintmax_t minimum, const uintmax_t maximum, const int count) { expect_range(function, parameter, file, line, minimum, maximum, check_not_in_range, count); @@ -1559,8 +1559,8 @@ void _expect_not_in_range( /* CheckParameterValue callback to check whether a value is equal to an * expected value. */ -static int check_value(const LargestIntegralType value, - const LargestIntegralType check_value_data) { +static int check_value(const uintmax_t value, + const uintmax_t check_value_data) { return values_equal_display_error(value, check_value_data); } @@ -1569,7 +1569,7 @@ static int check_value(const LargestIntegralType value, void _expect_value( const char* const function, const char* const parameter, const char* const file, const int line, - const LargestIntegralType value, const int count) { + const uintmax_t value, const int count) { _expect_check(function, parameter, file, line, check_value, value, NULL, count); } @@ -1577,8 +1577,8 @@ void _expect_value( /* CheckParameterValue callback to check whether a value is not equal to an * expected value. */ -static int check_not_value(const LargestIntegralType value, - const LargestIntegralType check_value_data) { +static int check_not_value(const uintmax_t value, + const uintmax_t check_value_data) { return values_not_equal_display_error(value, check_value_data); } @@ -1587,15 +1587,15 @@ static int check_not_value(const LargestIntegralType value, void _expect_not_value( const char* const function, const char* const parameter, const char* const file, const int line, - const LargestIntegralType value, const int count) { + const uintmax_t value, const int count) { _expect_check(function, parameter, file, line, check_not_value, value, NULL, count); } /* CheckParameterValue callback to check whether a parameter equals a string. */ -static int check_string(const LargestIntegralType value, - const LargestIntegralType check_value_data) { +static int check_string(const uintmax_t value, + const uintmax_t check_value_data) { return string_equal_display_error( cast_largest_integral_type_to_pointer(char*, value), cast_largest_integral_type_to_pointer(char*, check_value_data)); @@ -1616,8 +1616,8 @@ void _expect_string( /* CheckParameterValue callback to check whether a parameter is not equals to * a string. */ -static int check_not_string(const LargestIntegralType value, - const LargestIntegralType check_value_data) { +static int check_not_string(const uintmax_t value, + const uintmax_t check_value_data) { return string_not_equal_display_error( cast_largest_integral_type_to_pointer(char*, value), cast_largest_integral_type_to_pointer(char*, check_value_data)); @@ -1637,8 +1637,8 @@ void _expect_not_string( /* CheckParameterValue callback to check whether a parameter equals an area of * memory. */ -static int check_memory(const LargestIntegralType value, - const LargestIntegralType check_value_data) { +static int check_memory(const uintmax_t value, + const uintmax_t check_value_data) { CheckMemoryData * const check = cast_largest_integral_type_to_pointer( CheckMemoryData*, check_value_data); assert_non_null(check); @@ -1681,8 +1681,8 @@ void _expect_memory( /* CheckParameterValue callback to check whether a parameter is not equal to * an area of memory. */ -static int check_not_memory(const LargestIntegralType value, - const LargestIntegralType check_value_data) { +static int check_not_memory(const uintmax_t value, + const uintmax_t check_value_data) { CheckMemoryData * const check = cast_largest_integral_type_to_pointer( CheckMemoryData*, check_value_data); assert_non_null(check); @@ -1704,8 +1704,8 @@ void _expect_not_memory( /* CheckParameterValue callback that always returns 1. */ -static int check_any(const LargestIntegralType value, - const LargestIntegralType check_value_data) { +static int check_any(const uintmax_t value, + const uintmax_t check_value_data) { (void)value; (void)check_value_data; return 1; @@ -1723,7 +1723,7 @@ void _expect_any( void _check_expected( const char * const function_name, const char * const parameter_name, - const char* file, const int line, const LargestIntegralType value) { + const char* file, const int line, const uintmax_t value) { void *result = NULL; const char* symbols[] = {function_name, parameter_name}; const int rc = get_symbol_value(&global_function_parameter_map_head, @@ -1780,7 +1780,7 @@ void mock_assert(const int result, const char* const expression, } -void _assert_true(const LargestIntegralType result, +void _assert_true(const uintmax_t result, const char * const expression, const char * const file, const int line) { if (!result) { @@ -1789,14 +1789,14 @@ void _assert_true(const LargestIntegralType result, } } -void _assert_return_code(const LargestIntegralType result, +void _assert_return_code(const uintmax_t result, size_t rlen, - const LargestIntegralType error, + const uintmax_t error, const char * const expression, const char * const file, const int line) { - LargestIntegralType valmax; + uintmax_t valmax; switch (rlen) { @@ -1872,7 +1872,7 @@ void _assert_double_not_equal(const double a, } void _assert_int_equal( - const LargestIntegralType a, const LargestIntegralType b, + const uintmax_t a, const uintmax_t b, const char * const file, const int line) { if (!values_equal_display_error(a, b)) { _fail(file, line); @@ -1881,7 +1881,7 @@ void _assert_int_equal( void _assert_int_not_equal( - const LargestIntegralType a, const LargestIntegralType b, + const uintmax_t a, const uintmax_t b, const char * const file, const int line) { if (!values_not_equal_display_error(a, b)) { _fail(file, line); @@ -1925,8 +1925,8 @@ void _assert_memory_not_equal(const void * const a, const void * const b, void _assert_in_range( - const LargestIntegralType value, const LargestIntegralType minimum, - const LargestIntegralType maximum, const char* const file, + const uintmax_t value, const uintmax_t minimum, + const uintmax_t maximum, const char* const file, const int line) { if (!integer_in_range_display_error(value, minimum, maximum)) { _fail(file, line); @@ -1934,16 +1934,16 @@ void _assert_in_range( } void _assert_not_in_range( - const LargestIntegralType value, const LargestIntegralType minimum, - const LargestIntegralType maximum, const char* const file, + const uintmax_t value, const uintmax_t minimum, + const uintmax_t maximum, const char* const file, const int line) { if (!integer_not_in_range_display_error(value, minimum, maximum)) { _fail(file, line); } } -void _assert_in_set(const LargestIntegralType value, - const LargestIntegralType values[], +void _assert_in_set(const uintmax_t value, + const uintmax_t values[], const size_t number_of_values, const char* const file, const int line) { CheckIntegerSet check_integer_set; @@ -1954,8 +1954,8 @@ void _assert_in_set(const LargestIntegralType value, } } -void _assert_not_in_set(const LargestIntegralType value, - const LargestIntegralType values[], +void _assert_not_in_set(const uintmax_t value, + const uintmax_t values[], const size_t number_of_values, const char* const file, const int line) { CheckIntegerSet check_integer_set; @@ -3079,8 +3079,8 @@ int _cmocka_run_group_tests(const char *group_name, size_t i; int rc; - /* Make sure LargestIntegralType is at least the size of a pointer. */ - assert_true(sizeof(LargestIntegralType) >= sizeof(void*)); + /* Make sure uintmax_t is at least the size of a pointer. */ + assert_true(sizeof(uintmax_t) >= sizeof(void*)); cm_tests = libc_calloc(1, sizeof(struct CMUnitTestState) * num_tests); if (cm_tests == NULL) { @@ -3370,8 +3370,8 @@ int _run_tests(const UnitTest * const tests, const size_t number_of_tests) { print_message("[==========] Running %"PRIdS " test(s).\n", number_of_tests - setups - teardowns); - /* Make sure LargestIntegralType is at least the size of a pointer. */ - assert_true(sizeof(LargestIntegralType) >= sizeof(void*)); + /* Make sure uintmax_t is at least the size of a pointer. */ + assert_true(sizeof(uintmax_t) >= sizeof(void*)); while (current_test < number_of_tests) { const ListNode *test_check_point = NULL; diff --git a/tests/test_alloc.c b/tests/test_alloc.c index 966814a..3948084 100644 --- tests/test_alloc.c +++ tests/test_alloc.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include diff --git a/tests/test_assert_macros.c b/tests/test_assert_macros.c index 1a00880..3a7a0fe 100644 --- tests/test_assert_macros.c +++ tests/test_assert_macros.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include diff --git a/tests/test_assert_macros_fail.c b/tests/test_assert_macros_fail.c index aea919a..fc354d4 100644 --- tests/test_assert_macros_fail.c +++ tests/test_assert_macros_fail.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include diff --git a/tests/test_basics.c b/tests/test_basics.c inde 1bb493f..9866d81 100644 --- tests/test_basics.c +++ tests/test_basics.c @@ -20,6 +20,7 @@ #include #include #include +#include #include static int setup(void **state) { diff --git a/tests/test_cmockery.c b/tests/test_cmockery.c index 83a7451..027b1ac 100644 --- tests/test_cmockery.c +++ tests/test_cmockery.c @@ -17,6 +17,7 @@ #include #include #include +#include #include /* A test case that does nothing and succeeds. */ diff --git a/tests/test_double_macros.c b/tests/test_double_macros.c index 138c579..b892272 100644 --- tests/test_double_macros.c +++ tests/test_double_macros.c @@ -20,6 +20,7 @@ #include #include #include +#include #include /* A test case that does check if double is equal. */ diff --git a/tests/test_exception_handler.c b/tests/test_exception_handler.c index 23c19cd..769eed8 100644 --- tests/test_exception_handler.c +++ tests/test_exception_handler.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include diff --git a/tests/test_fixtures.c b/tests/test_fixtures.c index 6d39487..e6d05d1 100644 --- tests/test_fixtures.c +++ tests/test_fixtures.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include diff --git a/tests/test_float_macros.c b/tests/test_float_macros.c index a9c7251..6ce8906 100644 --- tests/test_float_macros.c +++ tests/test_float_macros.c @@ -20,6 +20,7 @@ #include #include #include +#include #include /* A test case that does check if float is equal. */ diff --git a/tests/test_group_fixtures.c b/tests/test_group_fixtures.c index 64f0ab7..e9b4ad3 100644 --- tests/test_group_fixtures.c +++ tests/test_group_fixtures.c @@ -4,6 +4,7 @@ #include #include #include +#include #include static int group_setup(void **state) diff --git a/tests/test_group_setup_assert.c b/tests/test_group_setup_assert.c index eef61f8..92f88b6 100644 --- tests/test_group_setup_assert.c +++ tests/test_group_setup_assert.c @@ -4,6 +4,7 @@ #include #include #include +#include #include static int group_setup_failing(void **state) diff --git a/tests/test_group_setup_fail.c b/tests/test_group_setup_fail.c index 7815c03..1f2e701 100644 --- tests/test_group_setup_fail.c +++ tests/test_group_setup_fail.c @@ -4,6 +4,7 @@ #include #include #include +#include #include static int group_setup_failing(void **state) diff --git a/tests/test_groups.c b/tests/test_groups.c index af9e2b8..ea936c0 100644 --- tests/test_groups.c +++ tests/test_groups.c @@ -20,6 +20,7 @@ #include #include #include +#include #include static int setup(void **state) { diff --git a/tests/test_ordering.c b/tests/test_ordering.c index 817c0ba..fab2568 100644 --- tests/test_ordering.c +++ tests/test_ordering.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include diff --git a/tests/test_ordering_fail.c b/tests/test_ordering_fail.c index 652f5ad..88b4e29 100644 --- tests/test_ordering_fail.c +++ tests/test_ordering_fail.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include diff --git a/tests/test_returns.c b/tests/test_returns.c index b9370c9..574fa00 100644 --- tests/test_returns.c +++ tests/test_returns.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include diff --git a/tests/test_returns_fail.c b/tests/test_returns_fail.c index 81197d3..fa7f291 100644 --- tests/test_returns_fail.c +++ tests/test_returns_fail.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include diff --git a/tests/test_setup_fail.c b/tests/test_setup_fail.c index e3f8df8..9affaa6 100644 --- tests/test_setup_fail.c +++ tests/test_setup_fail.c @@ -3,6 +3,7 @@ #include #include #include +#include #include static int setup_fail(void **state) { diff --git a/tests/test_skip.c b/tests/test_skip.c index 127161a..0a6953d 100644 --- tests/test_skip.c +++ tests/test_skip.c @@ -17,6 +17,7 @@ #include #include #include +#include #include /* A test case that does check if an int is equal. */ diff --git a/tests/test_skip_filter.c b/tests/test_skip_filter.c index e40209e..56dc262 100644 --- tests/test_skip_filter.c +++ tests/test_skip_filter.c @@ -19,6 +19,7 @@ #include #include #include +#include #include static void test_skip1(void **state) diff --git a/tests/test_strmatch.c b/tests/test_strmatch.c index f2d966b..f8d088c 100644 --- tests/test_strmatch.c +++ tests/test_strmatch.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "../src/cmocka.c" diff --git a/tests/test_wildcard.c b/tests/test_wildcard.c index 10ee195..3b85bb3 100644 --- tests/test_wildcard.c +++ tests/test_wildcard.c @@ -17,6 +17,7 @@ #include #include #include +#include #include static void test_ok1(void **state)