diff --git a/test/archlinux/aur_poc/CMakeLists.txt b/test/archlinux/aur_poc/CMakeLists.txt index dad3811..f677401 100644 --- a/test/archlinux/aur_poc/CMakeLists.txt +++ b/test/archlinux/aur_poc/CMakeLists.txt @@ -168,3 +168,12 @@ else() target_link_libraries(test_unicodecvt PRIVATE bux Catch2::Catch2WithMain stdc++ m) endif() add_test(NAME test_unicodecvt_All COMMAND test_unicodecvt) + +add_executable(test_lexbase test_lexbase.cpp) +target_include_directories(test_lexbase PRIVATE ../include) +if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") +target_link_libraries(test_lexbase PRIVATE bux Catch2::Catch2WithMain) +else() +target_link_libraries(test_lexbase PRIVATE bux Catch2::Catch2WithMain stdc++ m) +endif() +add_test(NAME test_lexbase_All COMMAND test_lexbase) diff --git a/test/archlinux/aur_poc/test_lexbase.cpp b/test/archlinux/aur_poc/test_lexbase.cpp new file mode 100644 index 0000000..71b2037 --- /dev/null +++ b/test/archlinux/aur_poc/test_lexbase.cpp @@ -0,0 +1,23 @@ +/* + Test cases are organized according to ZOMBIES rules + http://blog.wingman-sw.com/tdd-guided-by-zombies +*/ +#include // bux::asciiLiteral() +//#include // bux::BOM() +#include + +TEST_CASE("Regression errors", "[S]") +{ + CHECK(bux::asciiLiteral("::") == "::"); + CHECK(bux::asciiLiteral("::=") == "::="); +} + +TEST_CASE("Expectations", "[S]") +{ + CHECK(bux::asciiLiteral("\n") == "\\n"); + CHECK(bux::asciiLiteral("\r") == "\\r"); + CHECK(bux::asciiLiteral("\t") == "\\t"); + // + CHECK(bux::asciiLiteral((const char*)u8"\u1234") == (const char*)u8"\u1234"); + CHECK(bux::asciiLiteral((const char*)u8"\uABCD") == (const char*)u8"\uABCD"); +} diff --git a/test/archlinux/aur_poc/test_unicodecvt.cpp b/test/archlinux/aur_poc/test_unicodecvt.cpp index 888f443..da22073 100644 --- a/test/archlinux/aur_poc/test_unicodecvt.cpp +++ b/test/archlinux/aur_poc/test_unicodecvt.cpp @@ -2,7 +2,6 @@ Test cases are organized according to ZOMBIES rules http://blog.wingman-sw.com/tdd-guided-by-zombies */ -//#include // bux::asciiLiteral() #include // bux::to_utf8(), bux::BOM() #include @@ -40,8 +39,10 @@ TEST_CASE("String to utf-8 vs stringview to utf-8", "[S]") CHECK(bux::to_utf8(u16str) == (const char*)u8"一律轉成 utf-8"); for (auto &ch: u16str) ch = std::byteswap(ch); +#ifdef __unix__ static constinit const char *const CHSETS_UTF16BE[] = {"UTF-16BE", "UTF16BE", "UCS-2BE", "USC2BE", 0}; CHECK(bux::to_utf8(u16str, 0, CHSETS_UTF16BE) == (const char*)u8"一律轉成 utf-8"); +#endif CHECK(bux::to_utf8(u16str) == (const char*)u8"一律轉成 utf-8"); CHECK(bux::to_utf8(u8"一律轉成 utf-8", 0, bux::ENCODING_UTF8) == (const char*)u8"一律轉成 utf-8");