-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dan Smith
committed
Jun 28, 2022
1 parent
a8c24fc
commit bb1654c
Showing
26 changed files
with
1,037 additions
and
1,232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,43 @@ | ||
#include "pch.h" | ||
#include "TestCase.h" | ||
|
||
#include "str/EncodedStringView.h" | ||
|
||
using namespace Microsoft::VisualStudio::CppUnitTestFramework; | ||
|
||
// EQUALS_MESSAGE() wants ToString() specializations (or overloads) for our types, which is a nusiance. | ||
// This hooks up our existing str::toString() into the VC++ unit-test infrastructure | ||
|
||
// C++ hack to call private methods | ||
// https://stackoverflow.com/questions/6873138/calling-private-method-in-c?msclkid=dd8b1f8bd09711ec8610b4501a04de94 | ||
|
||
using FailOnCondition_t = void(bool condition, const unsigned short* message, const __LineInfo* pLineInfo); // declare method's type | ||
using GetAssertMessage_t = std::wstring(bool equality, const std::wstring& expected, const std::wstring& actual, const wchar_t *message); // declare method's type | ||
template <FailOnCondition_t fFailOnCondition, GetAssertMessage_t fGetAssertMessage> | ||
struct caller final // helper structure to inject call() code | ||
{ | ||
friend void FailOnCondition(bool condition, const unsigned short* message, const __LineInfo* pLineInfo) | ||
{ | ||
fFailOnCondition(condition, message, pLineInfo); | ||
} | ||
|
||
friend std::wstring GetAssertMessage(bool equality, const std::wstring& expected, const std::wstring& actual, const wchar_t *message) | ||
{ | ||
return fGetAssertMessage(equality, expected, actual, message); | ||
} | ||
}; | ||
template struct caller<&Assert::FailOnCondition, &Assert::GetAssertMessage>; // even instantiation of the helper | ||
|
||
void FailOnCondition(bool condition, const unsigned short* message, const __LineInfo* pLineInfo); // declare caller | ||
void test::Assert::FailOnCondition(bool condition, const unsigned short* message, const __LineInfo* pLineInfo) | ||
{ | ||
::FailOnCondition(condition, message, pLineInfo); // and call! | ||
} | ||
|
||
std::wstring GetAssertMessage(bool equality, const std::wstring& expected, const std::wstring& actual, const wchar_t *message); // declare caller | ||
std::wstring test::Assert::GetAssertMessage(bool equality, const std::string& expected, const std::string& actual, const wchar_t *message) | ||
{ | ||
const str::EncodedStringView vExpected(expected); | ||
const str::EncodedStringView vActual(actual); | ||
return ::GetAssertMessage(equality, vExpected.wstring(), vActual.wstring(), message); // and call! | ||
} | ||
#include "pch.h" | ||
#include "TestCase.h" | ||
|
||
#include "str/EncodedStringView.h" | ||
|
||
using namespace Microsoft::VisualStudio::CppUnitTestFramework; | ||
|
||
// EQUALS_MESSAGE() wants ToString() specializations (or overloads) for our types, which is a nusiance. | ||
// This hooks up our existing str::toString() into the VC++ unit-test infrastructure | ||
|
||
// C++ hack to call private methods | ||
// https://stackoverflow.com/a/71578383/8877 | ||
|
||
using FailOnCondition_t = void(bool condition, const unsigned short* message, const __LineInfo* pLineInfo); // declare method's type | ||
using GetAssertMessage_t = std::wstring(bool equality, const std::wstring& expected, const std::wstring& actual, const wchar_t *message); // declare method's type | ||
template <FailOnCondition_t fFailOnCondition, GetAssertMessage_t fGetAssertMessage> | ||
struct caller final // helper structure to inject call() code | ||
{ | ||
friend void FailOnCondition(bool condition, const unsigned short* message, const __LineInfo* pLineInfo) | ||
{ | ||
fFailOnCondition(condition, message, pLineInfo); | ||
} | ||
|
||
friend std::wstring GetAssertMessage(bool equality, const std::wstring& expected, const std::wstring& actual, const wchar_t *message) | ||
{ | ||
return fGetAssertMessage(equality, expected, actual, message); | ||
} | ||
}; | ||
template struct caller<&Assert::FailOnCondition, &Assert::GetAssertMessage>; // even instantiation of the helper | ||
|
||
void FailOnCondition(bool condition, const unsigned short* message, const __LineInfo* pLineInfo); // declare caller | ||
void test::Assert::FailOnCondition(bool condition, const unsigned short* message, const __LineInfo* pLineInfo) | ||
{ | ||
::FailOnCondition(condition, message, pLineInfo); // and call! | ||
} | ||
|
||
std::wstring GetAssertMessage(bool equality, const std::wstring& expected, const std::wstring& actual, const wchar_t *message); // declare caller | ||
std::wstring test::Assert::GetAssertMessage(bool equality, const std::string& expected, const std::string& actual, const wchar_t *message) | ||
{ | ||
const str::EncodedStringView vExpected(expected); | ||
const str::EncodedStringView vActual(actual); | ||
return ::GetAssertMessage(equality, vExpected.wstring(), vActual.wstring(), message); // and call! | ||
} |
Oops, something went wrong.