diff --git a/six/modules/c++/six.sicd/unittests/test_CollectionInfo.cpp b/six/modules/c++/six.sicd/unittests/test_CollectionInfo.cpp index 8b6e84847..a7db81ab7 100644 --- a/six/modules/c++/six.sicd/unittests/test_CollectionInfo.cpp +++ b/six/modules/c++/six.sicd/unittests/test_CollectionInfo.cpp @@ -39,16 +39,6 @@ #include "TestCase.h" -// It seems that a macro is better than a utility routine, see https://github.com/tahonermann/char8_t-remediation -// C++20 changed the type of u8 to char8_t* https://en.cppreference.com/w/cpp/language/string_literal -// Not putting this everywhere because (1) well, it's a macro, and (2) it's mostly -// only test code that uses string literals. -#if CODA_OSS_cpp20 -#define U8(s) u8##s -#else -#define U8(s) static_cast(static_cast(s)) -#endif - static void test_DummyData_parameters(const std::string& testName, const six::ParameterCollection& parameters, std::optional preserveCharacterData = std::optional()) { @@ -135,8 +125,10 @@ TEST_CASE(ClassificationCanada) { #ifdef _WIN32 const std::string classificationText("NON CLASSIFI\xc9 / UNCLASSIFIED"); // ISO8859-1 "NON CLASSIFIÉ / UNCLASSIFIED" + const auto E_ = str::u8FromString("\xc9"); // ISO8859-1 "É" #else const std::string classificationText("NON CLASSIFI\xc3\x89 / UNCLASSIFIED"); // UTF-8 "NON CLASSIFIÉ / UNCLASSIFIED" + const auto E_ = str::u8FromString("\xc3\x89"); // UTF-8 "É" #endif auto data = createData(types::RowCol(10, 10)); @@ -145,14 +137,14 @@ TEST_CASE(ClassificationCanada) const auto strXml = six::sicd::Utilities::toXMLString(*data, nullptr /*pSchemaPaths*/); - const auto NON_CLASSIFI = strXml.find(U8("NON CLASSIFI")); + const auto NON_CLASSIFI = strXml.find(str::u8FromString("NON CLASSIFI")); TEST_ASSERT(NON_CLASSIFI != std::string::npos); - const auto UNCLASSIFIED = strXml.find(U8(" / UNCLASSIFIED")); + const auto UNCLASSIFIED = strXml.find(str::u8FromString(" / UNCLASSIFIED")); TEST_ASSERT(UNCLASSIFIED != std::string::npos); const auto utf8 = strXml.substr(NON_CLASSIFI, UNCLASSIFIED - NON_CLASSIFI); TEST_ASSERT_EQ(utf8.size(), std::string("NON CLASSIFI\xc3\x89").size()); // UTF-8, "NON CLASSIFIÉ" - const auto E_ = utf8.find(U8("\xc3\x89")); // UTF-8, "É" - TEST_ASSERT(E_ != std::string::npos); + const auto posE_ = utf8.find(E_); + TEST_ASSERT(posE_ != std::string::npos); io::U8StringStream ss; ss.stream() << strXml;