Add some more Windows types (as needed) (#325)

This commit is contained in:
Dan Cristoloveanu 2023-12-13 12:48:19 -08:00 коммит произвёл GitHub
Родитель d2bfcd9501
Коммит 8babedf006
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 49 добавлений и 6 удалений

Просмотреть файл

@ -87,6 +87,12 @@ int umocktypes_windows_register_types(void);
- **SRS_UMOCKTYPES_WINDOWS_43_036: [** `SHORT` as an alias of `int16_t`. **]**
- **SRS_UMOCKTYPES_WINDOWS_01_036: [** `SIZE_T` as an alias of `size_t`. **]**
- **SRS_UMOCKTYPES_WINDOWS_01_037: [** `PSIZE_T` as an alias of `void*`. **]**
- **SRS_UMOCKTYPES_WINDOWS_01_038: [** `PHANDLE` as an alias of `void*`. **]**
**SRS_UMOCKTYPES_WINDOWS_01_005: [** On success, `umocktypes_windows_register_types` shall return 0. **]**
**SRS_UMOCKTYPES_WINDOWS_01_006: [** If registering any of the types fails, `umocktypes_windows_register_types` shall fail and return a non-zero value. **]**

Просмотреть файл

@ -45,6 +45,9 @@
/* Codes_SRS_UMOCKTYPES_WINDOWS_01_032: [ LPCWSTR as an alias of const wchar_t*. ]*/
/* Codes_SRS_UMOCKTYPES_WINDOWS_01_034: [ LONG64 as an alias of int64_t. ]*/
/* Codes_SRS_UMOCKTYPES_WINDOWS_43_036: [ SHORT as an alias of int16_t. ]*/
/* Codes_SRS_UMOCKTYPES_WINDOWS_01_036: [ SIZE_T as an alias of size_t. ]*/
/* Codes_SRS_UMOCKTYPES_WINDOWS_01_037: [ PSIZE_T as an alias of void*. ]*/
/* Codes_SRS_UMOCKTYPES_WINDOWS_01_038: [ PHANDLE as an alias of void*. ]*/
#define WINDOWS_TYPES_ALIAS_PAIRS \
LONG, long, \
LONGLONG, long long, \
@ -75,7 +78,10 @@
ULONG, unsigned long, \
LPCWSTR, const wchar_t*, \
LONG64, int64_t ,\
SHORT, int16_t \
SHORT, int16_t, \
SIZE_T, size_t, \
PSIZE_T, void*, \
PHANDLE, void* \
#define REGISTER_ALIAS_PAIR(alias_pair_type, alias_pair_is_type) \
if ( \

Просмотреть файл

@ -36,6 +36,9 @@
MOCKABLE_FUNCTION(, void, test_dependency_BOOLEAN_arg, BOOLEAN, BOOLEAN_arg);
MOCKABLE_FUNCTION(, void, test_dependency_ULONG_arg, ULONG, ULONG_arg);
MOCKABLE_FUNCTION(, void, test_dependency_LONG64_arg, LONG64, LONG64_arg);
MOCKABLE_FUNCTION(, void, test_dependency_SHORT_arg, SHORT, SHORT_arg);
MOCKABLE_FUNCTION(, void, test_dependency_SIZE_T_arg, SIZE_T, SIZE_T_arg);
MOCKABLE_FUNCTION(, void, test_dependency_PSIZE_T_arg, PSIZE_T, PSIZE_T_arg);
MOCKABLE_FUNCTION(, void, test_dependency_PHANDLE_arg, PHANDLE, PHANDLE_arg);
#endif /* TEST_DEPENDENCY_H */

Просмотреть файл

@ -54,7 +54,11 @@ static char* build_calls_string(void)
"[test_dependency_BYTE_arg(43)]"
"[test_dependency_BOOLEAN_arg(2)]"
"[test_dependency_ULONG_arg(44)]"
"[test_dependency_LONG64_arg(45)]";
"[test_dependency_LONG64_arg(45)]"
"[test_dependency_SHORT_arg(46)]"
"[test_dependency_SIZE_T_arg(47)]"
"[test_dependency_PSIZE_T_arg(%p)]"
"[test_dependency_PHANDLE_arg(%p)]";
int needed_bytes = snprintf(NULL, 0, test_expected_string,
(void*)0x4242, (void*)0x4243, (void*)0x4244,
@ -62,7 +66,8 @@ static char* build_calls_string(void)
(void*)0x4248, (void*)0x4249, (void*)0x424A,
(void*)0x424B, (void*)0x424C, (void*)0x424D,
(void*)0x424E, (void*)0x424F, (void*)0x4250,
(void*)0x4251, (void*)0x4252);
(void*)0x4251, (void*)0x4252, (void*)0x4253,
(void*)0x4254);
ASSERT_IS_TRUE(needed_bytes > 0);
result = malloc(needed_bytes + 1);
@ -74,7 +79,8 @@ static char* build_calls_string(void)
(void*)0x4248, (void*)0x4249, (void*)0x424A,
(void*)0x424B, (void*)0x424C, (void*)0x424D,
(void*)0x424E, (void*)0x424F, (void*)0x4250,
(void*)0x4251, (void*)0x4252);
(void*)0x4251, (void*)0x4252, (void*)0x4253,
(void*)0x4254);
ASSERT_IS_TRUE(snprintf_result > 0);
return result;
@ -136,6 +142,10 @@ TEST_FUNCTION(unmatched_expected_calls_with_windows_args_are_reported)
STRICT_EXPECTED_CALL(test_dependency_BOOLEAN_arg(2));
STRICT_EXPECTED_CALL(test_dependency_ULONG_arg(44));
STRICT_EXPECTED_CALL(test_dependency_LONG64_arg(45));
STRICT_EXPECTED_CALL(test_dependency_SHORT_arg(46));
STRICT_EXPECTED_CALL(test_dependency_SIZE_T_arg(47));
STRICT_EXPECTED_CALL(test_dependency_PSIZE_T_arg((PSIZE_T)0x4253));
STRICT_EXPECTED_CALL(test_dependency_PHANDLE_arg((PHANDLE)0x4254));
// assert
char* calls_string = build_calls_string();
@ -180,6 +190,10 @@ TEST_FUNCTION(unmatched_actual_calls_with_windows_args_are_reported)
test_dependency_BOOLEAN_arg(2);
test_dependency_ULONG_arg(44);
test_dependency_LONG64_arg(45);
test_dependency_SHORT_arg(46);
test_dependency_SIZE_T_arg(47);
test_dependency_PSIZE_T_arg((PSIZE_T)0x4253);
test_dependency_PHANDLE_arg((PHANDLE)0x4254);
// assert
ASSERT_ARE_EQUAL(char_ptr, "", umock_c_get_expected_calls());
@ -222,6 +236,10 @@ TEST_FUNCTION(matched_calls_with_windows_args_are_not_reported)
STRICT_EXPECTED_CALL(test_dependency_BOOLEAN_arg(2));
STRICT_EXPECTED_CALL(test_dependency_ULONG_arg(44));
STRICT_EXPECTED_CALL(test_dependency_LONG64_arg(45));
STRICT_EXPECTED_CALL(test_dependency_SHORT_arg(46));
STRICT_EXPECTED_CALL(test_dependency_SIZE_T_arg(47));
STRICT_EXPECTED_CALL(test_dependency_PSIZE_T_arg((PSIZE_T)0x4253));
STRICT_EXPECTED_CALL(test_dependency_PHANDLE_arg((PHANDLE)0x4254));
// act
test_dependency_LONG_arg(42);
@ -252,6 +270,10 @@ TEST_FUNCTION(matched_calls_with_windows_args_are_not_reported)
test_dependency_BOOLEAN_arg(2);
test_dependency_ULONG_arg(44);
test_dependency_LONG64_arg(45);
test_dependency_SHORT_arg(46);
test_dependency_SIZE_T_arg(47);
test_dependency_PSIZE_T_arg((PSIZE_T)0x4253);
test_dependency_PHANDLE_arg((PHANDLE)0x4254);
// assert
ASSERT_ARE_EQUAL(char_ptr, "", umock_c_get_expected_calls());

Просмотреть файл

@ -284,7 +284,10 @@ TEST_FUNCTION_CLEANUP(test_function_cleanup)
ULONG, unsigned long, \
LPCWSTR, const wchar_t*, \
LONG64, int64_t, \
SHORT, int16_t \
SHORT, int16_t, \
SIZE_T, size_t, \
PSIZE_T, void*, \
PHANDLE, void* \
#define ASSERT_EXPECTED_ALIAS_PAIR(alias_pair_type, alias_pair_is_type) \
ASSERT_ARE_EQUAL(char_ptr, MU_TOSTRING(alias_pair_type), umocktypes_register_alias_type_calls[i].type); \
@ -324,6 +327,9 @@ TEST_FUNCTION_CLEANUP(test_function_cleanup)
/* Tests_SRS_UMOCKTYPES_WINDOWS_01_032: [ LPCWSTR as an alias of const wchar_t*. ]*/
/* Tests_SRS_UMOCKTYPES_WINDOWS_01_034: [ LONG64 as an alias of int64_t. ]*/
/* Tests_SRS_UMOCKTYPES_WINDOWS_43_036: [ SHORT as an alias of int16_t. ]*/
/* Tests_SRS_UMOCKTYPES_WINDOWS_01_036: [ SIZE_T as an alias of size_t. ]*/
/* Tests_SRS_UMOCKTYPES_WINDOWS_01_037: [ PSIZE_T as an alias of void*. ]*/
/* Tests_SRS_UMOCKTYPES_WINDOWS_01_038: [ PHANDLE as an alias of void*. ]*/
/* Tests_SRS_UMOCKTYPES_WINDOWS_01_005: [ On success, umocktypes_windows_register_types shall return 0. ]*/
TEST_FUNCTION(umocktypes_windows_register_types_registers_all_types)
{