Skip to content

Commit 6042232

Browse files
committed
Use rapidcheck to enable property-based testing
1 parent b7c1a71 commit 6042232

File tree

7 files changed

+521
-810
lines changed

7 files changed

+521
-810
lines changed

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@
55
"--clang-tidy",
66
"--completion-style=detailed",
77
"--header-insertion=iwyu"
8-
]
8+
],
9+
"files.associations": {
10+
"algorithm": "cpp"
11+
}
912
}

CMakeLists.txt

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,21 @@ CPMAddPackage(
2323
VERSION 2.4.12
2424
)
2525

26+
# Add RapidCheck for property-based testing
27+
CPMAddPackage(
28+
NAME rapidcheck
29+
GITHUB_REPOSITORY emil-e/rapidcheck
30+
GIT_TAG master
31+
OPTIONS "RC_ENABLE_TESTS OFF" "RC_ENABLE_EXAMPLES OFF"
32+
)
33+
34+
# Suppress deprecation warnings originating from RapidCheck headers only
35+
if (TARGET rapidcheck)
36+
target_compile_options(rapidcheck INTERFACE
37+
$<$<CXX_COMPILER_ID:Clang,AppleClang,GNU>:-Wno-deprecated-declarations>
38+
)
39+
endif()
40+
2641
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
2742

2843
add_library(positionless INTERFACE)
@@ -32,8 +47,12 @@ target_compile_options(positionless INTERFACE
3247
$<$<CXX_COMPILER_ID:MSVC>:/W4>
3348
)
3449

35-
add_executable(unit_tests test/tests_main.cpp test/partitioning_tests.cpp test/algorithms_tests.cpp)
36-
target_link_libraries(unit_tests PRIVATE positionless doctest::doctest)
50+
add_executable(unit_tests
51+
test/tests_main.cpp
52+
test/partitioning_tests.cpp
53+
test/algorithms_tests.cpp
54+
)
55+
target_link_libraries(unit_tests PRIVATE positionless doctest::doctest rapidcheck)
3756

3857
enable_testing()
3958
add_test(NAME unit_tests COMMAND unit_tests)

include/positionless/partitioning.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ inline void partitioning<Iterator>::add_parts_begin(size_t part_index, size_t co
170170
template <std::forward_iterator Iterator>
171171
inline void partitioning<Iterator>::remove_part(size_t part_index) {
172172
assert(part_index < parts_count());
173-
boundaries_.erase(boundaries_.begin() + part_index + 1);
173+
boundaries_.erase(boundaries_.begin() + part_index);
174174
}
175175

176176
} // namespace positionless

0 commit comments

Comments
 (0)