Skip to content

Commit

Permalink
[Change] Sync test/archlinux/aur_poc/ with test/
Browse files Browse the repository at this point in the history
  • Loading branch information
buck-yeh committed Dec 11, 2024
1 parent 68dd3ce commit 3a545d7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
9 changes: 9 additions & 0 deletions test/archlinux/aur_poc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
23 changes: 23 additions & 0 deletions test/archlinux/aur_poc/test_lexbase.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Test cases are organized according to ZOMBIES rules
http://blog.wingman-sw.com/tdd-guided-by-zombies
*/
#include <bux/LexBase.h> // bux::asciiLiteral()
//#include <bux/UnicodeCvt.h> // bux::BOM()
#include <catch2/catch_test_macros.hpp>

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");
}
3 changes: 2 additions & 1 deletion test/archlinux/aur_poc/test_unicodecvt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Test cases are organized according to ZOMBIES rules
http://blog.wingman-sw.com/tdd-guided-by-zombies
*/
//#include <bux/LexBase.h> // bux::asciiLiteral()
#include <bux/UnicodeCvt.h> // bux::to_utf8(), bux::BOM()
#include <catch2/catch_test_macros.hpp>

Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 3a545d7

Please sign in to comment.