From 8bea03e0811588e741050b598b8123865b333999 Mon Sep 17 00:00:00 2001 From: Yuqian Yang Date: Tue, 4 Nov 2025 22:06:39 +0800 Subject: Move toml to base. --- test/CMakeLists.txt | 1 - test/base/CMakeLists.txt | 1 + test/base/toml/ParserTest.cpp | 31 +++++++++++++++++++++++++++++++ test/toml/CMakeLists.txt | 6 ------ test/toml/ParserTest.cpp | 31 ------------------------------- 5 files changed, 32 insertions(+), 38 deletions(-) create mode 100644 test/base/toml/ParserTest.cpp delete mode 100644 test/toml/CMakeLists.txt delete mode 100644 test/toml/ParserTest.cpp (limited to 'test') diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 22f66e40..d9b5bc3a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -17,5 +17,4 @@ endfunction() add_subdirectory(base) add_subdirectory(platform) -add_subdirectory(toml) add_subdirectory(ui) diff --git a/test/base/CMakeLists.txt b/test/base/CMakeLists.txt index b36bbd23..38cb9d57 100644 --- a/test/base/CMakeLists.txt +++ b/test/base/CMakeLists.txt @@ -6,6 +6,7 @@ add_executable(CruBaseTest StringUtilTest.cpp SubProcessTest.cpp TimerTest.cpp + toml/ParserTest.cpp xml/ParserTest.cpp ) target_link_libraries(CruBaseTest PRIVATE CruBase CruTestBase) diff --git a/test/base/toml/ParserTest.cpp b/test/base/toml/ParserTest.cpp new file mode 100644 index 00000000..2582e3c3 --- /dev/null +++ b/test/base/toml/ParserTest.cpp @@ -0,0 +1,31 @@ +#include "cru/base/toml/TomlDocument.h" +#include "cru/base/toml/TomlParser.h" + +#include + +using namespace cru::toml; + +TEST_CASE("CruTomlParserTest Simple", "[toml]") { + TomlParser parser( + R"( +a1 = v1 +a2 = v2 +# comment + +[s1] +# comment +a3 = v3 +a4 = v4 + +[s2] +a5 = v5 +a6 = v6 + )"); + auto document = parser.Parse(); + REQUIRE(document.GetSection("")->GetValue("a1") == "v1"); + REQUIRE(document.GetSection("")->GetValue("a2") == "v2"); + REQUIRE(document.GetSection("s1")->GetValue("a3") == "v3"); + REQUIRE(document.GetSection("s1")->GetValue("a4") == "v4"); + REQUIRE(document.GetSection("s2")->GetValue("a5") == "v5"); + REQUIRE(document.GetSection("s2")->GetValue("a6") == "v6"); +} diff --git a/test/toml/CMakeLists.txt b/test/toml/CMakeLists.txt deleted file mode 100644 index a0909349..00000000 --- a/test/toml/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -add_executable(CruTomlTest - ParserTest.cpp -) -target_link_libraries(CruTomlTest PRIVATE CruToml CruTestBase) - -cru_catch_discover_tests(CruTomlTest) diff --git a/test/toml/ParserTest.cpp b/test/toml/ParserTest.cpp deleted file mode 100644 index 4a4ba212..00000000 --- a/test/toml/ParserTest.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "cru/toml/TomlDocument.h" -#include "cru/toml/TomlParser.h" - -#include - -using namespace cru::toml; - -TEST_CASE("CruTomlParserTest Simple", "[toml]") { - TomlParser parser( - R"( -a1 = v1 -a2 = v2 -# comment - -[s1] -# comment -a3 = v3 -a4 = v4 - -[s2] -a5 = v5 -a6 = v6 - )"); - auto document = parser.Parse(); - REQUIRE(document.GetSection("")->GetValue("a1") == "v1"); - REQUIRE(document.GetSection("")->GetValue("a2") == "v2"); - REQUIRE(document.GetSection("s1")->GetValue("a3") == "v3"); - REQUIRE(document.GetSection("s1")->GetValue("a4") == "v4"); - REQUIRE(document.GetSection("s2")->GetValue("a5") == "v5"); - REQUIRE(document.GetSection("s2")->GetValue("a6") == "v6"); -} -- cgit v1.2.3