test:添加测试模块。

This commit is contained in:
taynpg 2024-11-29 12:02:56 +08:00
parent 837a4c8dd6
commit 320b01eab4
3 changed files with 23 additions and 2 deletions

View File

@ -23,6 +23,7 @@ set(SRC_FILES
include_directories(include)
if(DEFINED USE_TEST)
message(STATUS "USE TEST")
enable_testing()
add_subdirectory(test)
endif()

View File

@ -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)
target_link_libraries(ofTest PRIVATE Ofen)
add_test(NAME ofTest COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ofTest)

View File

@ -1,7 +1,27 @@
#include <iostream>
#include "of_path.h"
#include <cassert>
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;
}