diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index db0a34a..98eb0b5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,8 +2,8 @@ set(CMAKE_CXX_STANDARD 98) set(CMAKE_CXX_STANDARD_REQUIRED ON) add_executable(ulib_test - src/ulib/base/types_test.cpp - src/ulib/log/log_test.cpp + ulib/base/types_test.cpp + ulib/log/log_test.cpp ) target_link_libraries(ulib_test PRIVATE ulib diff --git a/tests/src/ulib/log/log_test.cpp b/tests/src/ulib/log/log_test.cpp deleted file mode 100644 index 3971a3f..0000000 --- a/tests/src/ulib/log/log_test.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include - -static const char* kLogTag = "UnitTest"; - -TEST(ULIB_LOG_TEST, base_test) -{ - ULOG_TRACE(kLogTag, "trace log"); - ULOG_DEBUG(kLogTag, "debug log"); - ULOG_INFO(kLogTag, "info log"); - ULOG_WARN(kLogTag, "warn log"); - ULOG_ERROR(kLogTag, "error log"); - ULOG_FATAL(kLogTag, "fatal log"); -} diff --git a/tests/src/ulib/base/types_test.cpp b/tests/ulib/base/types_test.cpp similarity index 96% rename from tests/src/ulib/base/types_test.cpp rename to tests/ulib/base/types_test.cpp index 4189275..c47a3f4 100644 --- a/tests/src/ulib/base/types_test.cpp +++ b/tests/ulib/base/types_test.cpp @@ -2,7 +2,7 @@ // Created by tqcq on 2023/12/5. // -#include +#include "ulib/base/types.h" #include TEST(ULIB_BASE_TYPES, SIZE_OF) diff --git a/tests/ulib/log/log_test.cpp b/tests/ulib/log/log_test.cpp new file mode 100644 index 0000000..2d2509d --- /dev/null +++ b/tests/ulib/log/log_test.cpp @@ -0,0 +1,24 @@ +#include +#include "ulib/log/log.h" +#include + +static const char* kLogTag = "UnitTest"; + +class ULIB_LOG : public testing::Test { +protected: + void SetUp() override { + static const size_t full_file_path_len = strlen(__FILE__); + static const size_t project_file_path_len = strlen("tests/ulib/log/log_test.cpp"); + ULOG_SET_STRIPPED_PREFIX_LEN(full_file_path_len - project_file_path_len); + } +}; + +TEST_F(ULIB_LOG, base_test) +{ + ULOG_TRACE(kLogTag, "trace log"); + ULOG_DEBUG(kLogTag, "debug log"); + ULOG_INFO(kLogTag, "info log"); + ULOG_WARN(kLogTag, "warn log"); + ULOG_ERROR(kLogTag, "error log"); + ULOG_FATAL(kLogTag, "fatal log"); +}