chore: migrate repository to standard knowledge base layout

This commit is contained in:
tukuaiai
2026-05-02 03:29:06 +08:00
parent 40a721c24d
commit 628a3bc832
565 changed files with 687 additions and 711 deletions
@@ -0,0 +1,20 @@
# SPDX-License-Identifier: Apache-2.0
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.17.0
FIND_PACKAGE_ARGS NAMES GTest
)
FetchContent_MakeAvailable(googletest)
add_library(libbtop_test)
target_include_directories(libbtop_test PUBLIC ${PROJECT_SOURCE_DIR}/src)
target_link_libraries(libbtop_test libbtop GTest::gtest_main)
add_executable(btop_test tools.cpp)
target_link_libraries(btop_test libbtop_test)
include(GoogleTest)
gtest_discover_tests(btop_test)
@@ -0,0 +1,23 @@
// SPDX-License-Identifier: Apache-2.0
#include <vector>
#include <gtest/gtest.h>
#include "btop_tools.hpp"
TEST(tools, string_split) {
EXPECT_EQ(Tools::ssplit(""), std::vector<std::string> {});
EXPECT_EQ(Tools::ssplit("foo"), std::vector<std::string> { "foo" });
{
auto actual = Tools::ssplit("foo bar baz ");
auto expected = std::vector<std::string> { "foo", "bar", "baz" };
EXPECT_EQ(actual, expected);
}
{
auto actual = Tools::ssplit("foobo oho barbo bo bazbo", 'o');
auto expected = std::vector<std::string> { "f", "b", " ", "h", " barb", " b", " bazb" };
EXPECT_EQ(actual, expected);
}
}