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