diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index dd879a9..b3f2aea 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -52,7 +52,13 @@ jobs: run: | sudo apt-get update -y sudo apt-get install -y libarchive-dev libssl-dev autoconf libtool pkg-config cmake make gcc g++ - ${{ env.build_command }} + ${{ env.build_command }} -DULIB_BUILD_TESTS=ON + + - name: run_gtest + if: matrix.toolchain == 'host.toolchain.cmake' + run: | + cd ${{ github.workspace }} + cmake --build build --config ${{ matrix.build_type }} --target test - name: build-afl if: matrix.toolchain == 'host-afl.toolchain.cmake' diff --git a/.gitignore b/.gitignore index ab09395..22b0db6 100644 --- a/.gitignore +++ b/.gitignore @@ -47,4 +47,5 @@ _deps # Clion .idea/ -cmake-* +cmake-build-* +build/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..923464d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "3party/googletest"] + path = 3party/googletest + url = https://code.uocat.com/3party/googletest + branch = release-1.8.1 diff --git a/3party/googletest b/3party/googletest new file mode 160000 index 0000000..b3a9ba2 --- /dev/null +++ b/3party/googletest @@ -0,0 +1 @@ +Subproject commit b3a9ba2b8e975550799838332803d468797ae2e1 diff --git a/CMakeLists.txt b/CMakeLists.txt index 5edac56..6e2254b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,3 +36,9 @@ add_executable(ulib_main_test src/main.cpp) target_link_libraries(ulib_main_test PRIVATE ${PROJECT_NAME}) install(TARGETS ${PROJECT_NAME} DESTINATION lib) + +if(ULIB_BUILD_TESTS) + enable_testing() + add_subdirectory(3party/googletest) + add_subdirectory(tests) +endif() \ No newline at end of file diff --git a/src/sigslot/sigslot.h b/src/ulib/sigslot/sigslot.h similarity index 100% rename from src/sigslot/sigslot.h rename to src/ulib/sigslot/sigslot.h diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..2ae4de3 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.10) +project(ulib_test) + +set(CMAKE_CXX_STANDARD 98) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +add_executable(ulib_test src/ulib/sigslot/sigslot_test.cpp) +target_link_libraries(ulib_test gtest gtest_main) + +add_test(NAME ulib_test COMMAND ulib_test) diff --git a/tests/src/ulib/sigslot/sigslot_test.cpp b/tests/src/ulib/sigslot/sigslot_test.cpp new file mode 100644 index 0000000..09cde97 --- /dev/null +++ b/tests/src/ulib/sigslot/sigslot_test.cpp @@ -0,0 +1,3 @@ +// +// Created by tqcq on 2023/12/5. +//