UnitTest: redesing to avoid #include ".cpp" in Xcode

Each unit test .cpp file is not a separate compilation unit in Xcode project
like it is in Visual Studio. Hopefully, Visual Studio test tool still likes
this arrangement.

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman
2024-02-08 15:18:42 +01:00
parent 1e627e1c6b
commit 9acd185d44
14 changed files with 951 additions and 902 deletions

View File

@@ -12,31 +12,27 @@ using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTests
{
TEST_CLASS(string)
void string::sprintf()
{
public:
TEST_METHOD(sprintf)
{
stdex::locale locale(stdex::create_locale(LC_ALL, "en_US.UTF-8"));
stdex::locale locale(stdex::create_locale(LC_ALL, "en_US.UTF-8"));
Assert::AreEqual(L"This is a test.", stdex::sprintf(L"This is %ls.", locale, L"a test").c_str());
Assert::AreEqual<size_t>(15, stdex::sprintf(L"This is %ls.", locale, L"a test").size());
Assert::AreEqual("This is a test.", stdex::sprintf("This is %s.", locale, "a test").c_str());
Assert::AreEqual<size_t>(15, stdex::sprintf("This is %s.", locale, "a test").size());
Assert::AreEqual(L"This is a test.", stdex::sprintf(L"This is %ls.", locale, L"a test").c_str());
Assert::AreEqual<size_t>(15, stdex::sprintf(L"This is %ls.", locale, L"a test").size());
Assert::AreEqual("This is a test.", stdex::sprintf("This is %s.", locale, "a test").c_str());
Assert::AreEqual<size_t>(15, stdex::sprintf("This is %s.", locale, "a test").size());
Assert::AreEqual(L"This is a 🐔Test🐮.", stdex::sprintf(L"This is %ls.", locale, L"a 🐔Test🐮").c_str());
Assert::AreEqual("This is a 🐔Test🐮.", stdex::sprintf("This is %s.", locale, "a 🐔Test🐮").c_str());
Assert::AreEqual(L"This is a 🐔Test🐮.", stdex::sprintf(L"This is %ls.", locale, L"a 🐔Test🐮").c_str());
Assert::AreEqual("This is a 🐔Test🐮.", stdex::sprintf("This is %s.", locale, "a 🐔Test🐮").c_str());
wstring wstr;
std::string str;
for (size_t i = 0; i < 200; i++) {
wstr += L"🐔Test🐮\r\n";
str += "🐔Test🐮\r\n";
}
Assert::AreEqual(wstr.c_str(), stdex::sprintf(L"%ls", locale, wstr.data()).c_str());
Assert::AreEqual(wstr.size(), stdex::sprintf(L"%ls", locale, wstr.data()).size());
Assert::AreEqual(str.c_str(), stdex::sprintf("%s", locale, str.data()).c_str());
Assert::AreEqual(str.size(), stdex::sprintf("%s", locale, str.data()).size());
wstring wstr;
std::string str;
for (size_t i = 0; i < 200; i++) {
wstr += L"🐔Test🐮\r\n";
str += "🐔Test🐮\r\n";
}
};
Assert::AreEqual(wstr.c_str(), stdex::sprintf(L"%ls", locale, wstr.data()).c_str());
Assert::AreEqual(wstr.size(), stdex::sprintf(L"%ls", locale, wstr.data()).size());
Assert::AreEqual(str.c_str(), stdex::sprintf("%s", locale, str.data()).c_str());
Assert::AreEqual(str.size(), stdex::sprintf("%s", locale, str.data()).size());
}
}