-
Notifications
You must be signed in to change notification settings - Fork 39
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
Aug 21, 2023
1 parent
993d755
commit b0fcd34
Showing
116 changed files
with
12,808 additions
and
12,860 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/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! | ||
} | ||
#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! | ||
} |
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,96 +1,96 @@ | ||
#include "pch.h" | ||
#include "Test.h" | ||
|
||
#include <std/filesystem> | ||
|
||
#include <sys/OS.h> | ||
|
||
namespace fs = std::filesystem; | ||
|
||
static bool is_x64_Configuration(const fs::path& path) // "Configuration" is typically "Debug" or "Release" | ||
{ | ||
const std::string build_configuration = | ||
#if defined(NDEBUG) // i.e., release | ||
"Release"; | ||
#else | ||
"Debug"; | ||
#endif | ||
|
||
const auto Configuration = path.filename(); | ||
const auto path_parent_path = path.parent_path(); | ||
const auto x64 = path_parent_path.filename(); | ||
return (Configuration == build_configuration) && (x64 == "x64"); | ||
} | ||
|
||
static bool is_install_unittests(const fs::path& path) | ||
{ | ||
const auto unittests = path.filename(); | ||
const auto path_parent_path = path.parent_path(); | ||
const auto install = path_parent_path.filename(); | ||
return (unittests == "unittests") && (install == "install"); | ||
} | ||
static bool is_install_tests(const fs::path& path) | ||
{ | ||
const auto tests = path.filename(); | ||
const auto path_parent_path = path.parent_path(); | ||
const auto install = path_parent_path.filename(); | ||
return (tests == "tests") && (install == "install"); | ||
} | ||
|
||
fs::path six::Test::buildSchemaDir() | ||
{ | ||
const auto cwd = fs::current_path(); | ||
|
||
const sys::OS os; | ||
const auto exec = fs::path(os.getCurrentExecutable()); | ||
const auto argv0 = exec.filename(); | ||
if ((argv0 == "Test.exe") || (argv0 == "testhost.exe")) | ||
{ | ||
// Running GTest unit-tests in Visual Studio on Windows | ||
if (is_x64_Configuration(cwd)) | ||
{ | ||
const auto root_path = cwd.parent_path().parent_path(); | ||
return root_path / "six" / "modules" / "c++" / "six.sidd" / "conf" / "schema"; | ||
} | ||
} | ||
|
||
if (argv0 == "unittests.exe") | ||
{ | ||
// stand-alone unittest executable on Windows (ends in .EXE) | ||
const auto parent_path = exec.parent_path(); | ||
if (is_x64_Configuration(parent_path)) | ||
{ | ||
const auto parent_path_ = parent_path.parent_path().parent_path(); | ||
return parent_path_ / "dev" / "tests" / "images"; | ||
} | ||
} | ||
|
||
// stand-alone unit-test on Linux | ||
const auto exec_dir = exec.parent_path(); | ||
if (is_install_unittests(exec_dir)) | ||
{ | ||
const auto install = exec_dir.parent_path(); | ||
return install / "unittests" / "data"; | ||
} | ||
if (is_install_tests(exec_dir)) | ||
{ | ||
const auto install = exec_dir.parent_path(); | ||
return install / "unittests" / "data"; | ||
} | ||
|
||
if (argv0 == "unittests") | ||
{ | ||
// stand-alone unittest executable on Linux | ||
const auto bin = exec.parent_path(); | ||
if (bin.filename() == "bin") | ||
{ | ||
const auto unittests = bin.parent_path(); | ||
return unittests / "unittests" / "data"; | ||
} | ||
} | ||
|
||
//fprintf(stderr, "cwd = %s\n", cwd.c_str()); | ||
//fprintf(stderr, "exec = %s\n", exec.c_str()); | ||
|
||
return cwd; | ||
} | ||
#include "pch.h" | ||
#include "Test.h" | ||
|
||
#include <std/filesystem> | ||
|
||
#include <sys/OS.h> | ||
|
||
namespace fs = std::filesystem; | ||
|
||
static bool is_x64_Configuration(const fs::path& path) // "Configuration" is typically "Debug" or "Release" | ||
{ | ||
const std::string build_configuration = | ||
#if defined(NDEBUG) // i.e., release | ||
"Release"; | ||
#else | ||
"Debug"; | ||
#endif | ||
|
||
const auto Configuration = path.filename(); | ||
const auto path_parent_path = path.parent_path(); | ||
const auto x64 = path_parent_path.filename(); | ||
return (Configuration == build_configuration) && (x64 == "x64"); | ||
} | ||
|
||
static bool is_install_unittests(const fs::path& path) | ||
{ | ||
const auto unittests = path.filename(); | ||
const auto path_parent_path = path.parent_path(); | ||
const auto install = path_parent_path.filename(); | ||
return (unittests == "unittests") && (install == "install"); | ||
} | ||
static bool is_install_tests(const fs::path& path) | ||
{ | ||
const auto tests = path.filename(); | ||
const auto path_parent_path = path.parent_path(); | ||
const auto install = path_parent_path.filename(); | ||
return (tests == "tests") && (install == "install"); | ||
} | ||
|
||
fs::path six::Test::buildSchemaDir() | ||
{ | ||
const auto cwd = fs::current_path(); | ||
|
||
const sys::OS os; | ||
const auto exec = fs::path(os.getCurrentExecutable()); | ||
const auto argv0 = exec.filename(); | ||
if ((argv0 == "Test.exe") || (argv0 == "testhost.exe")) | ||
{ | ||
// Running GTest unit-tests in Visual Studio on Windows | ||
if (is_x64_Configuration(cwd)) | ||
{ | ||
const auto root_path = cwd.parent_path().parent_path(); | ||
return root_path / "six" / "modules" / "c++" / "six.sidd" / "conf" / "schema"; | ||
} | ||
} | ||
|
||
if (argv0 == "unittests.exe") | ||
{ | ||
// stand-alone unittest executable on Windows (ends in .EXE) | ||
const auto parent_path = exec.parent_path(); | ||
if (is_x64_Configuration(parent_path)) | ||
{ | ||
const auto parent_path_ = parent_path.parent_path().parent_path(); | ||
return parent_path_ / "dev" / "tests" / "images"; | ||
} | ||
} | ||
|
||
// stand-alone unit-test on Linux | ||
const auto exec_dir = exec.parent_path(); | ||
if (is_install_unittests(exec_dir)) | ||
{ | ||
const auto install = exec_dir.parent_path(); | ||
return install / "unittests" / "data"; | ||
} | ||
if (is_install_tests(exec_dir)) | ||
{ | ||
const auto install = exec_dir.parent_path(); | ||
return install / "unittests" / "data"; | ||
} | ||
|
||
if (argv0 == "unittests") | ||
{ | ||
// stand-alone unittest executable on Linux | ||
const auto bin = exec.parent_path(); | ||
if (bin.filename() == "bin") | ||
{ | ||
const auto unittests = bin.parent_path(); | ||
return unittests / "unittests" / "data"; | ||
} | ||
} | ||
|
||
//fprintf(stderr, "cwd = %s\n", cwd.c_str()); | ||
//fprintf(stderr, "exec = %s\n", exec.c_str()); | ||
|
||
return cwd; | ||
} |
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,11 +1,11 @@ | ||
#pragma once | ||
|
||
#include <std/filesystem> | ||
|
||
namespace six | ||
{ | ||
namespace Test | ||
{ | ||
extern std::filesystem::path buildSchemaDir(); | ||
} | ||
#pragma once | ||
|
||
#include <std/filesystem> | ||
|
||
namespace six | ||
{ | ||
namespace Test | ||
{ | ||
extern std::filesystem::path buildSchemaDir(); | ||
} | ||
} |
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
Oops, something went wrong.