From 320b01eab44d2668225077985d7cceaeb99fccf6 Mon Sep 17 00:00:00 2001 From: taynpg Date: Fri, 29 Nov 2024 12:02:56 +0800 Subject: [PATCH] =?UTF-8?q?test=EF=BC=9A=E6=B7=BB=E5=8A=A0=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E6=A8=A1=E5=9D=97=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 1 + test/CMakeLists.txt | 4 ++-- test/main.cpp | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a402fd..a6deb84 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,7 @@ set(SRC_FILES include_directories(include) if(DEFINED USE_TEST) message(STATUS "USE TEST") + enable_testing() add_subdirectory(test) endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d5a60fd..b37db26 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -8,6 +8,6 @@ if (MSVC) add_compile_options(/source-charset:utf-8) endif() - add_executable(ofTest main.cpp) -target_link_libraries(ofTest PRIVATE Ofen) \ No newline at end of file +target_link_libraries(ofTest PRIVATE Ofen) +add_test(NAME ofTest COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ofTest) \ No newline at end of file diff --git a/test/main.cpp b/test/main.cpp index 157fa26..21096e2 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -1,7 +1,27 @@ #include +#include "of_path.h" +#include + +using namespace ofen; + +void testA() +{ + assert(COfPath::isSamePath(ofT("D:/Java"), ofT("D:\\Java\\"))); +} + +void testB() +{ + auto home = COfPath::getHome(); + assert(!home.empty()); + + auto rp = COfPath::replaceStr(ofT("cpp/z"), ofT("p/"), ofT("Ni")); + assert(rp == ofT("cpNiz")); +} int main() { + testA(); + testB(); std::cout << "Done" << std::endl; return 0; } \ No newline at end of file