зеркало из https://github.com/microsoft/mso.git
Rename `FEmptyGuid` to `IsEmptyGuid`
This commit is contained in:
Родитель
af1df76665
Коммит
133415783d
|
@ -206,7 +206,7 @@ inline void UnformattedStringToGUID(const std::wstring& str, GUID& guid)
|
|||
StringToGUID(localStr, guid);
|
||||
}
|
||||
|
||||
inline bool FEmptyGuid(const GUID& guid) noexcept
|
||||
inline bool IsEmptyGuid(const GUID& guid) noexcept
|
||||
{
|
||||
static const GUID emptyGuid = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}};
|
||||
return static_cast<bool>(IsEqualGUID(emptyGuid, guid));
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
#include <optional>
|
||||
|
||||
// {7714B323-69D2-4B37-B6A1-1B433E6EA023}
|
||||
const GUID nonNullTestGuid = { 0x7714b323, 0x69d2, 0x4b37, { 0xb6, 0xa1, 0x1b, 0x43, 0x3e, 0x6e, 0xa0, 0x23 } };
|
||||
const GUID nonNullTestGuid = {0x7714b323, 0x69d2, 0x4b37, {0xb6, 0xa1, 0x1b, 0x43, 0x3e, 0x6e, 0xa0, 0x23}};
|
||||
|
||||
TEST_CLASS(Creation)
|
||||
TEST_CLASS (Creation)
|
||||
{
|
||||
TEST_METHOD(createstring)
|
||||
{
|
||||
|
@ -27,7 +27,7 @@ TEST_CLASS(Creation)
|
|||
}
|
||||
};
|
||||
|
||||
TEST_CLASS(Conversions)
|
||||
TEST_CLASS (Conversions)
|
||||
{
|
||||
TEST_METHOD(Success_FullForm)
|
||||
{
|
||||
|
@ -84,27 +84,28 @@ TEST_CLASS(Conversions)
|
|||
|
||||
TEST_METHOD(string_view)
|
||||
{
|
||||
std::string_view s { "{7714B323-69D2-4B37-B6A1-1B433E6EA023}" };
|
||||
std::string_view s{"{7714B323-69D2-4B37-B6A1-1B433E6EA023}"};
|
||||
TestAssert::IsTrue(OGuid::StringToGUID(s) == nonNullTestGuid);
|
||||
}
|
||||
|
||||
TEST_METHOD(WstringView)
|
||||
{
|
||||
std::wstring_view s { L"{7714B323-69D2-4B37-B6A1-1B433E6EA023}" };
|
||||
std::wstring_view s{L"{7714B323-69D2-4B37-B6A1-1B433E6EA023}"};
|
||||
TestAssert::IsTrue(OGuid::StringToGUID(s) == nonNullTestGuid);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
static void IsSmallerOrEqualTestHelper(const GUID& lhs, const GUID& rhs)
|
||||
{
|
||||
bool fIsSmallerEqual = Mso::Guid::LexicalCompare::LessOrEqual( lhs, rhs );
|
||||
wchar_t wzlhs[128]; ::StringFromGUID2(lhs, RgC(wzlhs));
|
||||
wchar_t wzrhs[128]; ::StringFromGUID2(rhs, RgC(wzrhs));
|
||||
bool fIsSmallerEqual = Mso::Guid::LexicalCompare::LessOrEqual(lhs, rhs);
|
||||
wchar_t wzlhs[128];
|
||||
::StringFromGUID2(lhs, RgC(wzlhs));
|
||||
wchar_t wzrhs[128];
|
||||
::StringFromGUID2(rhs, RgC(wzrhs));
|
||||
TestAssert::AreEqual(fIsSmallerEqual, wcscmp(wzlhs, wzrhs) <= 0);
|
||||
}
|
||||
|
||||
TEST_CLASS(Comparison)
|
||||
TEST_CLASS (Comparison)
|
||||
{
|
||||
TEST_METHOD(IsSmallerOrEqual)
|
||||
{
|
||||
|
@ -112,38 +113,47 @@ TEST_CLASS(Comparison)
|
|||
IsSmallerOrEqualTestHelper(guid1, guid1);
|
||||
|
||||
// Data1
|
||||
GUID guid2 = GUID(); guid2.Data1 = 1;
|
||||
GUID guid2 = GUID();
|
||||
guid2.Data1 = 1;
|
||||
IsSmallerOrEqualTestHelper(guid2, guid2);
|
||||
IsSmallerOrEqualTestHelper(guid1, guid2);
|
||||
IsSmallerOrEqualTestHelper(guid2, guid1);
|
||||
|
||||
// Data2
|
||||
guid2 = GUID(); guid2.Data2 = 1;
|
||||
guid2 = GUID();
|
||||
guid2.Data2 = 1;
|
||||
IsSmallerOrEqualTestHelper(guid2, guid2);
|
||||
IsSmallerOrEqualTestHelper(guid1, guid2);
|
||||
IsSmallerOrEqualTestHelper(guid2, guid1);
|
||||
|
||||
// Data3
|
||||
guid2 = GUID(); guid2.Data3 = 1;
|
||||
guid2 = GUID();
|
||||
guid2.Data3 = 1;
|
||||
IsSmallerOrEqualTestHelper(guid2, guid2);
|
||||
IsSmallerOrEqualTestHelper(guid1, guid2);
|
||||
IsSmallerOrEqualTestHelper(guid2, guid1);
|
||||
|
||||
// Data4
|
||||
guid1 = GUID(); guid1.Data4[0] = 1;
|
||||
guid2 = GUID(); guid2.Data4[7] = 1;
|
||||
guid1 = GUID();
|
||||
guid1.Data4[0] = 1;
|
||||
guid2 = GUID();
|
||||
guid2.Data4[7] = 1;
|
||||
IsSmallerOrEqualTestHelper(guid2, guid2);
|
||||
IsSmallerOrEqualTestHelper(guid1, guid2);
|
||||
IsSmallerOrEqualTestHelper(guid2, guid1);
|
||||
|
||||
guid1 = GUID(); guid1.Data4[6] = 1;
|
||||
guid2 = GUID(); guid2.Data4[7] = 1;
|
||||
guid1 = GUID();
|
||||
guid1.Data4[6] = 1;
|
||||
guid2 = GUID();
|
||||
guid2.Data4[7] = 1;
|
||||
IsSmallerOrEqualTestHelper(guid2, guid2);
|
||||
IsSmallerOrEqualTestHelper(guid1, guid2);
|
||||
IsSmallerOrEqualTestHelper(guid2, guid1);
|
||||
|
||||
guid1 = GUID(); guid1.Data4[5] = 1;
|
||||
guid2 = GUID(); guid2.Data4[6] = 1;
|
||||
guid1 = GUID();
|
||||
guid1.Data4[5] = 1;
|
||||
guid2 = GUID();
|
||||
guid2.Data4[6] = 1;
|
||||
IsSmallerOrEqualTestHelper(guid2, guid2);
|
||||
IsSmallerOrEqualTestHelper(guid1, guid2);
|
||||
IsSmallerOrEqualTestHelper(guid2, guid1);
|
||||
|
@ -155,7 +165,7 @@ TEST_CLASS(Comparison)
|
|||
IsSmallerOrEqualTestHelper(guid2, guid2);
|
||||
IsSmallerOrEqualTestHelper(guid1, guid2);
|
||||
IsSmallerOrEqualTestHelper(guid2, guid1);
|
||||
TestAssert::IsTrue( Mso::Guid::LexicalCompare::LessOrEqual(guid1, guid2));
|
||||
TestAssert::IsTrue(Mso::Guid::LexicalCompare::LessOrEqual(guid1, guid2));
|
||||
|
||||
guid1 = guid2;
|
||||
OGuid::StringToGUID(std::wstring(L"{F9C8B96E-84DD-4DBC-9C72-277C6B9CCA0E}"), guid2);
|
||||
|
@ -176,10 +186,11 @@ TEST_CLASS(Comparison)
|
|||
{
|
||||
GUID guid1 = {};
|
||||
TestAssert::IsTrue(guid1 == GUID_NULL);
|
||||
TestAssert::IsTrue(OGuid::FEmptyGuid(guid1));
|
||||
TestAssert::IsTrue(OGuid::IsEmptyGuid(guid1));
|
||||
|
||||
GUID guid2 = GUID(); guid2.Data1 = 1;
|
||||
GUID guid2 = GUID();
|
||||
guid2.Data1 = 1;
|
||||
TestAssert::IsFalse(guid2 == GUID_NULL);
|
||||
TestAssert::IsFalse(OGuid::FEmptyGuid(guid2));
|
||||
TestAssert::IsFalse(OGuid::IsEmptyGuid(guid2));
|
||||
}
|
||||
};
|
Загрузка…
Ссылка в новой задаче