have inverse conversion from UUID_T to GUID (#143)

This commit is contained in:
anporumb 2022-01-14 13:30:33 -08:00 коммит произвёл GitHub
Родитель c6badba773
Коммит 1d25f96a06
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
11 изменённых файлов: 288 добавлений и 77 удалений

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

@ -15,8 +15,33 @@ typedef unsigned char UUID_T[16]; /*introduces UUID_T as "array of 16 bytes"*/
MOCKABLE_FUNCTION(, int, uuid_produce, UUID_T, destination);
#ifdef WIN32 /*some functions only exists in Windows realm*/
#ifdef WIN32 /*some functions, format specifiers only exists in Windows realm*/
MOCKABLE_FUNCTION(, int, uuid_from_GUID, UUID_T, destination, const GUID*, source);
MOCKABLE_FUNCTION(, int, GUID_from_uuid, GUID*, destination, const UUID_T, source);
/*
below macros can be used with printf. example:
printf("PartitionId = %" GUID_FORMAT "\n", GUID_VALUES(fabricDeployedStatefulServiceReplicaQueryResultItem->PartitionId)); produces on the screen:
PartitionId=316132b8-96a0-4bc7-aecc-a16e7c5a6bf6
*/
#define PRI_GUID "8.8" PRIx32 "-%4.4" PRIx16 "-%4.4" PRIx16 "-%4.4" PRIx16 "-%12.12" PRIx64
#define GUID_VALUES(guid) \
(guid).Data1, \
(guid).Data2, \
(guid).Data3, \
((guid).Data4[0]<<8) + (guid).Data4[1], \
((uint64_t)((guid).Data4[2])<<40) + ((uint64_t)((guid).Data4[3])<<32) + (((uint64_t)(guid).Data4[4])<<24) + ((guid).Data4[5]<<16) + ((guid).Data4[6]<<8) + ((guid).Data4[7])
#define GUID_VALUES_OR_NULL(pguid) \
(pguid == NULL) ? 0 : (pguid)->Data1, \
(pguid == NULL) ? 0 : (pguid)->Data2, \
(pguid == NULL) ? 0 : (pguid)->Data3, \
(pguid == NULL) ? 0 : ((pguid)->Data4[0] << 8) + (pguid)->Data4[1], \
(pguid == NULL) ? 0 : ((uint64_t)((pguid)->Data4[2]) << 40) + ((uint64_t)((pguid)->Data4[3]) << 32) + (((uint64_t)(pguid)->Data4[4]) << 24) + ((pguid)->Data4[5] << 16) + ((pguid)->Data4[6] << 8) + ((pguid)->Data4[7])
/*for backward compatibility*/
#define GUID_FORMAT PRI_GUID
#endif
/* These 2 strings can be conveniently used directly in printf-like statements
@ -57,5 +82,15 @@ MOCKABLE_FUNCTION(, int, uuid_from_GUID, UUID_T, destination, const GUID*, sourc
`uuid_from_GUID` converts a `GUID` to a `UUID_T`. This function only exists on Windows platforms.
See [uuid requirements](../../win32/devdoc/uuid_win32_requirements.md) for further requirements.
See [uuid_win32_requirements](../../win32/devdoc/uuid_win32_requirements.md) for further requirements.
### GUID_from_uuid
```c
MOCKABLE_FUNCTION(, int, GUID_from_uuid, GUID*, destination, const UUID_T, source);
```
`GUID_from_uuid` converts a `UUID_T` to a `GUID`. This function only exists on Windows platforms.
See [uuid_win32_requirements](../../win32/devdoc/uuid_win32_requirements.md) for further requirements.

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

@ -4,6 +4,8 @@
#ifndef UUID_H
#define UUID_H
#include <inttypes.h>
#ifdef WIN32
#include "windows.h"
#endif
@ -18,8 +20,33 @@ extern "C" {
MOCKABLE_FUNCTION(, int, uuid_produce, UUID_T, destination);
#ifdef WIN32 /*some functions only exists in Windows realm*/
#ifdef WIN32 /*some functions, format specifiers only exists in Windows realm*/
MOCKABLE_FUNCTION(, int, uuid_from_GUID, UUID_T, destination, const GUID*, source);
MOCKABLE_FUNCTION(, int, GUID_from_uuid, GUID*, destination, const UUID_T, source);
/*
below macros can be used with printf. example:
printf("PartitionId = %" GUID_FORMAT "\n", GUID_VALUES(fabricDeployedStatefulServiceReplicaQueryResultItem->PartitionId)); produces on the screen:
PartitionId=316132b8-96a0-4bc7-aecc-a16e7c5a6bf6
*/
#define PRI_GUID "8.8" PRIx32 "-%4.4" PRIx16 "-%4.4" PRIx16 "-%4.4" PRIx16 "-%12.12" PRIx64
#define GUID_VALUES(guid) \
(guid).Data1, \
(guid).Data2, \
(guid).Data3, \
((guid).Data4[0]<<8) + (guid).Data4[1], \
((uint64_t)((guid).Data4[2])<<40) + ((uint64_t)((guid).Data4[3])<<32) + (((uint64_t)(guid).Data4[4])<<24) + ((guid).Data4[5]<<16) + ((guid).Data4[6]<<8) + ((guid).Data4[7])
#define GUID_VALUES_OR_NULL(pguid) \
(pguid == NULL) ? 0 : (pguid)->Data1, \
(pguid == NULL) ? 0 : (pguid)->Data2, \
(pguid == NULL) ? 0 : (pguid)->Data3, \
(pguid == NULL) ? 0 : ((pguid)->Data4[0] << 8) + (pguid)->Data4[1], \
(pguid == NULL) ? 0 : ((uint64_t)((pguid)->Data4[2]) << 40) + ((uint64_t)((pguid)->Data4[3]) << 32) + (((uint64_t)(pguid)->Data4[4]) << 24) + ((pguid)->Data4[5] << 16) + ((pguid)->Data4[6] << 8) + ((pguid)->Data4[7])
/*for backward compatibility*/
#define GUID_FORMAT PRI_GUID
#endif
/* These 2 strings can be conveniently used directly in printf-like statements

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

@ -108,8 +108,114 @@ TEST_FUNCTION(uuid_from_GUID_succeeds)
ASSERT_ARE_EQUAL(uint8_t, g.Data4[5], destination[13]);
ASSERT_ARE_EQUAL(uint8_t, g.Data4[6], destination[14]);
ASSERT_ARE_EQUAL(uint8_t, g.Data4[7], destination[15]);
}
TEST_FUNCTION(GUID_from_uuid_succeeds)
{
///arrange
UUID_T u;
(void)uuid_produce(u);
GUID destination = { 0 };
int result;
///act
result = GUID_from_uuid(&destination, u);
///assert
ASSERT_ARE_EQUAL(int, 0, result);
ASSERT_ARE_EQUAL(uint8_t, u[0],(destination.Data1>>24) & 0xFF);
ASSERT_ARE_EQUAL(uint8_t, u[1], (destination.Data1 >> 16) & 0xFF);
ASSERT_ARE_EQUAL(uint8_t, u[2], (destination.Data1 >> 8) & 0xFF);
ASSERT_ARE_EQUAL(uint8_t, u[3], (destination.Data1 ) & 0xFF);
ASSERT_ARE_EQUAL(uint8_t, u[4], (destination.Data2 >> 8) & 0xFF);
ASSERT_ARE_EQUAL(uint8_t, u[5], (destination.Data2 ) & 0xFF);
ASSERT_ARE_EQUAL(uint8_t, u[6], (destination.Data3 >> 8) & 0xFF);
ASSERT_ARE_EQUAL(uint8_t, u[7], (destination.Data3 ) & 0xFF);
ASSERT_ARE_EQUAL(uint8_t, u[8], destination.Data4[0]);
ASSERT_ARE_EQUAL(uint8_t, u[9], destination.Data4[1]);
ASSERT_ARE_EQUAL(uint8_t, u[10],destination.Data4[2]);
ASSERT_ARE_EQUAL(uint8_t, u[11],destination.Data4[3]);
ASSERT_ARE_EQUAL(uint8_t, u[12],destination.Data4[4]);
ASSERT_ARE_EQUAL(uint8_t, u[13],destination.Data4[5]);
ASSERT_ARE_EQUAL(uint8_t, u[14],destination.Data4[6]);
ASSERT_ARE_EQUAL(uint8_t, u[15],destination.Data4[7]);
}
TEST_FUNCTION(PRI_GUID_succeeds)
{
GUID g = { 0x10213243, 0x5465, 0x7687, {0x98, 0xA9, 0xBA, 0xCB, 0xDE, 0xED, 0xFE, 0x0F } };
char temp[1000]; /*a vast array greatly bigger than the stringification of GUID*/
int r = snprintf(temp, sizeof(temp), "%" PRI_GUID "", GUID_VALUES(g));
ASSERT_IS_TRUE((r >= 0) && (r < sizeof(temp)));
ASSERT_ARE_EQUAL(char_ptr, "10213243-5465-7687-98a9-bacbdeedfe0f", temp);
}
TEST_FUNCTION(PRI_GUID_with_NULL_succeeds)
{
GUID* g = NULL;
char temp[1000]; /*a vast array greatly bigger than the stringification of GUID*/
int r = snprintf(temp, sizeof(temp), "%" PRI_GUID "", GUID_VALUES_OR_NULL(g));
ASSERT_IS_TRUE((r >= 0) && (r < sizeof(temp)));
ASSERT_ARE_EQUAL(char_ptr, "00000000-0000-0000-0000-000000000000", temp);
}
TEST_FUNCTION(PRI_GUID_and_friends)
{
///arrange
struct GUID_AND_EXPECTED_STRINGS
{
GUID guid;
const char* expectedGuidAsString;
} guidAndExpectedStrings[] =
{
{/*[0]*/
{
0, /*unsigned long Data1; */
0, /*unsigned short Data2; */
0, /*unsigned short Data3; */
{0,0,0,0,0,0,0,0} /*unsigned char Data4[8]; */
},
"00000000-0000-0000-0000-000000000000"
},
{/*[1]*/
{
0xFFFFFFFF, /*unsigned long Data1; */
0xFFFF, /*unsigned short Data2; */
0xFFFF, /*unsigned short Data3; */
{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF} /*unsigned char Data4[8]; */
},
"ffffffff-ffff-ffff-ffff-ffffffffffff"
},
{/*[2]*/
/*a most famous bug that needed testing - it was producing 1f018f1a-1b1f-40ad-b78d-d577f2b27821
instead of the expected 1f018f1a-1b1f-40ad-b78d-d578f2b27821 and we had great fun with it!*/
{
0x1f018f1a, /*unsigned long Data1; */
0x1b1f, /*unsigned short Data2; */
0x40ad, /*unsigned short Data3; */
{0xb7,0x8d,0xd5,0x78,0xf2,0xb2,0x78,0x21} /*unsigned char Data4[8]; */
},
"1f018f1a-1b1f-40ad-b78d-d578f2b27821"
}
};
///act
for (size_t i = 0; i < sizeof(guidAndExpectedStrings) / sizeof(guidAndExpectedStrings[0]); i++)
{
char temp[1000];
int r = snprintf(temp, sizeof(temp), "%" PRI_GUID "", GUID_VALUES(guidAndExpectedStrings[i].guid));
ASSERT_IS_TRUE((r >= 0) && (r < sizeof(temp)));
///assert
ASSERT_ARE_EQUAL(char_ptr, guidAndExpectedStrings[i].expectedGuidAsString, temp);
///clean
}
}
#endif
TEST_FUNCTION(PRI_UUID_T_compiles)

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

@ -40,15 +40,6 @@ MOCKABLE_INTERFACE(string_utils_printf,
FUNCTION(, wchar_t*, vsprintf_wchar, const wchar_t*, format, va_list, va)
)
/*
below macros can be used with printf. example:
printf("PartitionId = %" GUID_FORMAT "\n", GUID_VALUES(fabricDeployedStatefulServiceReplicaQueryResultItem->PartitionId)); produces on the screen:
PartitionId=316132b8-96a0-4bc7-aecc-a16e7c5a6bf6
*/
#define GUID_FORMAT "8.8" PRIx32 "-%4.4" PRIx16 "-%4.4" PRIx16 "-%4.4" PRIx16 "-%12.12" PRIx64
#define GUID_VALUES(guid) (guid).Data1, (guid).Data2, (guid).Data3, ((guid).Data4[0]<<8) + (guid).Data4[1], ((uint64_t)((guid).Data4[2])<<40) + ((uint64_t)((guid).Data4[3])<<32) + (((uint64_t)(guid).Data4[4])<<24) + ((guid).Data4[5]<<16) + ((guid).Data4[6]<<8) + ((guid).Data4[7])
MOCKABLE_INTERFACE(string_utils_convert,
/*produces the wchar_t* string representation of source (which is assumed to be multibyte). Returns NULL on any failure.*/
FUNCTION(, wchar_t*, mbs_to_wcs, const char*, source),

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

@ -16,13 +16,14 @@ typedef unsigned char UUID_T[16]; /*introduces UUID_T as "array of 16 bytes"*/
#ifdef WIN32 /*some functions only exists in Windows realm*/
MOCKABLE_FUNCTION(, int, uuid_from_GUID, UUID_T, destination, const GUID*, source);
MOCKABLE_FUNCTION(, int, GUID_from_uuid, GUID*, destination, const UUID_T, source);
#endif
/* These 2 strings can be conveniently used directly in printf-like statements
Notice that PRI_UUID has to be used like any other print format specifier, meaning it
Notice that PRI_UUID_T has to be used like any other print format specifier, meaning it
has to be preceded with % */
#define PRI_UUID "02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
#define PRI_UUID_T "02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
#define UUID_VALUES(uuid) \
(uuid)[0], (uuid)[1], (uuid)[2], (uuid)[3], (uuid)[4], (uuid)[5], (uuid)[6], (uuid)[7], \
@ -66,3 +67,13 @@ MOCKABLE_FUNCTION(, int, uuid_from_GUID, UUID_T, destination, const GUID*, sourc
**SRS_UUID_WIN32_02_008: [** `uuid_from_GUID` shall convert `GUID` to `UUID_T`, succeed and return 0. **]**
### GUID_from_uuid
```c
MOCKABLE_FUNCTION(, int, GUID_from_uuid, GUID*, destination, const UUID_T, source);
```
**SRS_UUID_WIN32_02_009: [** If `destination` is `NULL` then `GUID_from_uuid` shall fail and return a non-zero value. **]**
**SRS_UUID_WIN32_02_010: [** If `source` is `NULL` then `GUID_from_uuid` shall fail and return a non-zero value. **]**
**SRS_UUID_WIN32_02_011: [** `GUID_from_uuid` shall convert `UUID_T` to `GUID`, succeed and return 0. **]**

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

@ -44,14 +44,6 @@ MOCKABLE_INTERFACE(string_utils_printf,
FUNCTION(, wchar_t*, vsprintf_wchar, const wchar_t*, format, va_list, va)
)
/*
below macros can be used with printf. example:
printf("PartitionId = %" GUID_FORMAT "\n", GUID_VALUES(fabricDeployedStatefulServiceReplicaQueryResultItem->PartitionId)); produces on the screen:
PartitionId=316132b8-96a0-4bc7-aecc-a16e7c5a6bf6
*/
#define GUID_FORMAT "8.8" PRIx32 "-%4.4" PRIx16 "-%4.4" PRIx16 "-%4.4" PRIx16 "-%12.12" PRIx64
#define GUID_VALUES(guid) (uint32_t)(guid).Data1, (uint16_t)(guid).Data2, (uint16_t)(guid).Data3, (uint16_t)(((guid).Data4[0]<<8) + (guid).Data4[1]), (uint64_t)((uint64_t)((guid).Data4[2])<<40) + ((uint64_t)((guid).Data4[3])<<32) + (((uint64_t)(guid).Data4[4])<<24) + ((guid).Data4[5]<<16) + ((guid).Data4[6]<<8) + ((guid).Data4[7])
/*takes a FILETIME, returns a nice string representation of it*/
MOCKABLE_FUNCTION(, char*, FILETIME_toAsciiArray, const FILETIME*, fileTime);

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

@ -20,6 +20,7 @@ extern "C" {
#ifdef WIN32 /*some functions only exists in Windows realm*/
int real_uuid_from_GUID(UUID_T destination, const GUID* source);
int real_GUID_from_uuid(GUID* destination, const UUID_T source);
#endif
#ifdef __cplusplus

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

@ -4,6 +4,7 @@
#ifdef WIN32 /*some functions only exists in Windows realm*/
#define uuid_from_GUID real_uuid_from_GUID
#define GUID_from_uuid real_GUID_from_uuid
#endif
#define UUID_T_FROM_STRING_RESULT real_UUID_T_FROM_STRING_RESULT

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

@ -95,3 +95,36 @@ int uuid_from_GUID(UUID_T destination, const GUID* source)
}
return result;
}
int GUID_from_uuid(GUID* destination, const UUID_T source)
{
int result;
if (
/*Codes_SRS_UUID_WIN32_02_009: [ If destination is NULL then GUID_from_uuid shall fail and return a non-zero value. ]*/
(destination == NULL) ||
/*Codes_SRS_UUID_WIN32_02_010: [ If source is NULL then GUID_from_uuid shall fail and return a non-zero value. ]*/
(source == NULL)
)
{
LogError("invalid argument GUID* destination=%" PRI_GUID ", const UUID_T source=%" PRI_UUID_T "", GUID_VALUES_OR_NULL(destination), UUID_T_VALUES_OR_NULL(source));
result = MU_FAILURE;
}
else
{
/*Codes_SRS_UUID_WIN32_02_011: [ GUID_from_uuid shall convert UUID_T to GUID, succeed and return 0. ]*/
destination->Data1 =
(source[0] << 24) +
(source[1] << 16) +
(source[2] << 8) +
(source[3]);
destination->Data2 =
(source[4] << 8) +
(source[5]);
destination->Data3 =
(source[6] << 8) +
(source[7]);
(void)memcpy(destination->Data4, source + 8, 8);
result = 0;
}
return result;
}

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

@ -120,60 +120,6 @@ TEST_FUNCTION(wcs_to_mbs_converts_a_Japanese_string)
ASSERT_IS_NOT_NULL(localeInfo);
}
TEST_FUNCTION(GUID_FORMAT_AND_VALUES)
{
///arrange
struct GUID_AND_EXPECTED_STRINGS
{
GUID guid;
const char* expectedGuidAsString;
} guidAndExpectedStrings[] =
{
{/*[0]*/
{
0, /*unsigned long Data1; */
0, /*unsigned short Data2; */
0, /*unsigned short Data3; */
{0,0,0,0,0,0,0,0} /*unsigned char Data4[8]; */
},
"00000000-0000-0000-0000-000000000000"
},
{/*[1]*/
{
0xFFFFFFFF, /*unsigned long Data1; */
0xFFFF, /*unsigned short Data2; */
0xFFFF, /*unsigned short Data3; */
{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF} /*unsigned char Data4[8]; */
},
"ffffffff-ffff-ffff-ffff-ffffffffffff"
},
{/*[2]*/
/*a most famous bug that needed testing - it was producing 1f018f1a-1b1f-40ad-b78d-d577f2b27821
instead of the expected 1f018f1a-1b1f-40ad-b78d-d578f2b27821 and we had great fun with it!*/
{
0x1f018f1a, /*unsigned long Data1; */
0x1b1f, /*unsigned short Data2; */
0x40ad, /*unsigned short Data3; */
{0xb7,0x8d,0xd5,0x78,0xf2,0xb2,0x78,0x21} /*unsigned char Data4[8]; */
},
"1f018f1a-1b1f-40ad-b78d-d578f2b27821"
}
};
///act
for (size_t i = 0; i < sizeof(guidAndExpectedStrings) / sizeof(guidAndExpectedStrings[0]); i++)
{
char* actual = sprintf_char("%" GUID_FORMAT "", GUID_VALUES(guidAndExpectedStrings[i].guid));
ASSERT_IS_NOT_NULL(actual);
///assert
ASSERT_ARE_EQUAL(char_ptr, guidAndExpectedStrings[i].expectedGuidAsString, actual);
///clean
free(actual);
}
}
TEST_FUNCTION(sprintf_char_with_empty_string_succeeds)
{
///arrange

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

@ -108,6 +108,7 @@ TEST_FUNCTION(uuid_produce_with_destination_NULL_fails)
///assert
ASSERT_ARE_NOT_EQUAL(int, 0, result);
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
}
@ -146,6 +147,8 @@ TEST_FUNCTION(uuid_produce_succeeds_1) /*when it returns default RPC_S_OK*/
ASSERT_ARE_EQUAL(uint8_t, TEST_DATA_4_5, u[13]);
ASSERT_ARE_EQUAL(uint8_t, TEST_DATA_4_6, u[14]);
ASSERT_ARE_EQUAL(uint8_t, TEST_DATA_4_7, u[15]);
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
}
@ -185,6 +188,8 @@ TEST_FUNCTION(uuid_produce_succeeds_2) /*when it returns default RPC_S_UUID_LOCA
ASSERT_ARE_EQUAL(uint8_t, TEST_DATA_4_5, u[13]);
ASSERT_ARE_EQUAL(uint8_t, TEST_DATA_4_6, u[14]);
ASSERT_ARE_EQUAL(uint8_t, TEST_DATA_4_7, u[15]);
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
}
/*Tests_SRS_UUID_WIN32_02_005: [ If there are any failures then uuid_produce shall fail and return a non-zero value. ]*/
@ -202,6 +207,7 @@ TEST_FUNCTION(uuid_produce_unhappy_path) /*when it returns RPC_S_UUID_LOCAL_ONLY
///assert
ASSERT_ARE_NOT_EQUAL(int, 0, result);
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
}
/*Tests_SRS_UUID_WIN32_02_006: [ If destination is NULL then uuid_from_GUID shall fail and return a non-zero value. ]*/
@ -216,6 +222,7 @@ TEST_FUNCTION(uuid_from_GUID_with_destination_NULL_fails)
///assert
ASSERT_ARE_NOT_EQUAL(int, 0, result);
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
}
/*Tests_SRS_UUID_WIN32_02_007: [ If source is NULL then uuid_from_GUID shall fail and return a non-zero value. ]*/
@ -230,6 +237,7 @@ TEST_FUNCTION(uuid_from_GUID_with_source_NULL_fails)
///assert
ASSERT_ARE_NOT_EQUAL(int, 0, result);
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
}
/*Tests_SRS_UUID_WIN32_02_008: [ uuid_from_GUID shall convert GUID to UUID_T, succeed and return 0. ]*/
@ -266,4 +274,64 @@ TEST_FUNCTION(uuid_from_GUID_succeeds)
ASSERT_ARE_EQUAL(uint8_t, TEST_DATA_4_7, destination[15]);
}
/*Tests_SRS_UUID_WIN32_02_009: [ If destination is NULL then GUID_from_uuid shall fail and return a non-zero value. ]*/
TEST_FUNCTION(GUID_from_uuid_with_NULL_destination_fails)
{
///arrange
int result;
UUID_T source = { 0 };
///act
result = GUID_from_uuid(NULL, source);
///assert
ASSERT_ARE_NOT_EQUAL(int, 0, result);
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
}
/*Tests_SRS_UUID_WIN32_02_010: [ If source is NULL then GUID_from_uuid shall fail and return a non-zero value. ]*/
TEST_FUNCTION(GUID_from_uuid_with_NULL_source_fails)
{
///arrange
int result;
GUID destination;
///act
result = GUID_from_uuid(&destination, NULL);
///assert
ASSERT_ARE_NOT_EQUAL(int, 0, result);
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
}
/*Tests_SRS_UUID_WIN32_02_011: [ GUID_from_uuid shall convert UUID_T to GUID, succeed and return 0. ]*/
TEST_FUNCTION(GUID_from_uuid_succeeds)
{
///arrange
int result;
UUID_T source = {
((TEST_DATA_1 >> 24) & 0xFF),
((TEST_DATA_1 >> 16) & 0xFF),
((TEST_DATA_1 >> 8) & 0xFF),
((TEST_DATA_1 ) & 0xFF),
((TEST_DATA_2 >> 8) &0xFF),
((TEST_DATA_2 ) & 0xFF),
((TEST_DATA_3 >> 8) & 0xFF),
((TEST_DATA_3 ) & 0xFF),
TEST_DATA_4_0, TEST_DATA_4_1, TEST_DATA_4_2, TEST_DATA_4_3, TEST_DATA_4_4, TEST_DATA_4_5, TEST_DATA_4_6, TEST_DATA_4_7};
GUID destination;
///act
result = GUID_from_uuid(&destination, source);
///assert
ASSERT_ARE_EQUAL(int, 0, result);
ASSERT_IS_TRUE(TEST_DATA_1 == destination.Data1);
ASSERT_IS_TRUE(TEST_DATA_2 == destination.Data2);
ASSERT_IS_TRUE(TEST_DATA_3 == destination.Data3);
ASSERT_IS_TRUE(0 == memcmp(source+8, destination.Data4, 8));
ASSERT_ARE_EQUAL(char_ptr, umock_c_get_expected_calls(), umock_c_get_actual_calls());
}
END_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)