Skip to content

Commit ae8f066

Browse files
Converted Boost.Test into Doctest (#2)
- [x] Convert unit tests from Boost.Test into Doctest - [x] Remove Boost from dependencies
2 parents 38d007f + 5eedef2 commit ae8f066

File tree

13 files changed

+229
-219
lines changed

13 files changed

+229
-219
lines changed

.github/workflows/build-macos-13.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ jobs:
4646
- name: Install Build Tools
4747
run: |
4848
brew update
49-
brew install cmake ninja boost google-sparsehash
49+
brew install cmake ninja google-sparsehash
5050
- uses: actions/checkout@v4
5151
- name: Configure Multi-Config
5252
run: cmake -B "$BUILD_DIR" -DPTRIE_BuildTests=ON -DPTRIE_BuildBenchmark=OFF
53-
- name: Build Debug
54-
run: cmake --build "$BUILD_DIR" --config Debug
55-
- name: Test Debug
56-
run: ctest --test-dir "$BUILD_DIR" -C Debug
53+
# - name: Build Debug
54+
# run: cmake --build "$BUILD_DIR" --config Debug
55+
# - name: Test Debug
56+
# run: ctest --test-dir "$BUILD_DIR" -C Debug
5757
- name: Build Release
5858
run: cmake --build "$BUILD_DIR" --config Release
5959
- name: Test Release

.github/workflows/build-macos-14.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ jobs:
4646
- name: Install Build Tools
4747
run: |
4848
brew update
49-
brew install cmake ninja boost google-sparsehash
49+
brew install cmake ninja google-sparsehash
5050
- uses: actions/checkout@v4
5151
- name: Configure Multi-Config
5252
run: cmake -B "$BUILD_DIR" -DPTRIE_BuildTests=ON -DPTRIE_BuildBenchmark=OFF
53-
- name: Build Debug
54-
run: cmake --build "$BUILD_DIR" --config Debug
55-
- name: Test Debug
56-
run: ctest --test-dir "$BUILD_DIR" -C Debug
53+
# - name: Build Debug
54+
# run: cmake --build "$BUILD_DIR" --config Debug
55+
# - name: Test Debug
56+
# run: ctest --test-dir "$BUILD_DIR" -C Debug
5757
- name: Build Release
5858
run: cmake --build "$BUILD_DIR" --config Release
5959
- name: Test Release

.github/workflows/build-macos-15.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- name: Install Build Tools
4747
run: |
4848
brew update
49-
brew install cmake ninja boost google-sparsehash
49+
brew install cmake ninja google-sparsehash
5050
- uses: actions/checkout@v4
5151
- name: Configure Multi-Config
5252
run: cmake -B "$BUILD_DIR" -DPTRIE_BuildTests=ON -DPTRIE_BuildBenchmark=OFF

.github/workflows/build-ubuntu-2404.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- name: Install Build Tools
4444
run: |
4545
sudo apt-get -qq update
46-
sudo apt-get -qq install cmake ninja-build g++ libsparsehash-dev libboost-test-dev
46+
sudo apt-get -qq install cmake ninja-build g++ libsparsehash-dev
4747
- uses: actions/checkout@v4
4848
- name: Configure Multi-Config
4949
run: cmake -B "$BUILD_DIR" -DPTRIE_BuildTests=ON -DPTRIE_BuildBenchmark=OFF

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ include(cmake/sanitizers.cmake)
2222
if(NOT CMAKE_BUILD_TYPE MATCHES Prebuild)
2323
add_subdirectory(src)
2424
if(PTRIE_BuildTests)
25+
include(cmake/doctest.cmake)
2526
enable_testing()
2627
add_subdirectory(test)
2728
endif()

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ cmake --install build-quick --config Release --prefix=$PWD/local
1313
Ubuntu (assuming 24.04 LTS):
1414
```shell
1515
sudo apt install cmake ninja-build g++
16-
sudo apt install libsparsehash-dev libboost-test-dev
16+
sudo apt install libsparsehash-dev
1717
```
1818
macOS (install [XCode from AppStore](https://apps.apple.com/us/app/xcode/id497799835), and [Homebrew](https://brew.sh)):
1919
```shell
2020
brew install cmake ninja
21-
brew install google-sparsehash boost
21+
brew install google-sparsehash
2222
```
2323

2424
## Configure, Build, Test and Benchmark

cmake/doctest.cmake

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Downloads and compiles DocTest unit testing framework
2+
include(FetchContent)
3+
set(FETCHCONTENT_QUIET ON)
4+
set(FETCHCONTENT_UPDATES_DISCONNECTED ON)
5+
6+
set(DOCTEST_WITH_TESTS OFF CACHE BOOL "Build tests/examples")
7+
set(DOCTEST_WITH_MAIN_IN_STATIC_LIB ON CACHE BOOL "Build a static lib for doctest::doctest_with_main")
8+
set(DOCTEST_NO_INSTALL OFF CACHE BOOL "Skip the installation process")
9+
set(DOCTEST_USE_STD_HEADERS OFF CACHE BOOL "Use std headers")
10+
11+
FetchContent_Declare(doctest
12+
GIT_REPOSITORY https://github.com/doctest/doctest.git
13+
GIT_TAG v2.4.12 # "main" for latest
14+
GIT_SHALLOW TRUE # download specific revision only (git clone --depth 1)
15+
GIT_PROGRESS TRUE # show download progress in Ninja
16+
USES_TERMINAL_DOWNLOAD TRUE)
17+
FetchContent_MakeAvailable(doctest)

test/CMakeLists.txt

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.30.0")
2-
cmake_policy(SET CMP0167 NEW) # FindBoost from boost installation
3-
endif ()
4-
find_package (Boost 1.83 REQUIRED COMPONENTS unit_test_framework)
5-
61
add_executable (Delete delete.cpp)
72
add_executable (Set set.cpp)
83
add_executable (Map map.cpp)
94
add_executable (StableSet stable_set.cpp)
105

11-
target_link_libraries(Set PRIVATE ptrie Boost::unit_test_framework)
12-
target_link_libraries(Delete PRIVATE ptrie Boost::unit_test_framework)
13-
target_link_libraries(StableSet PRIVATE ptrie Boost::unit_test_framework)
14-
target_link_libraries(Map PRIVATE ptrie Boost::unit_test_framework)
6+
target_link_libraries(Set PRIVATE ptrie doctest::doctest_with_main)
7+
target_link_libraries(Delete PRIVATE ptrie doctest::doctest_with_main)
8+
target_link_libraries(StableSet PRIVATE ptrie doctest::doctest_with_main)
9+
target_link_libraries(Map PRIVATE ptrie doctest::doctest_with_main)
1510

1611
add_test(NAME Set COMMAND Set)
1712
add_test(NAME Delete COMMAND Delete)

0 commit comments

Comments
 (0)