From a6381a981ee5d4702ed5785ca770860da5404d90 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Wed, 17 Jan 2024 12:40:27 -0800 Subject: [PATCH] Add test scaffolding --- .clangd | 2 ++ CMakeLists.txt | 10 +++++++++- ConflictSet.cpp | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 .clangd diff --git a/.clangd b/.clangd new file mode 100644 index 0000000..8b1da38 --- /dev/null +++ b/.clangd @@ -0,0 +1,2 @@ +CompileFlags: + Add: [-DENABLE_TESTS] diff --git a/CMakeLists.txt b/CMakeLists.txt index f21ec18..3ee35c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,4 +7,12 @@ project( set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) -add_library(conflict_set ConflictSet.cpp ConflictSet.h) \ No newline at end of file +add_library(conflict_set ConflictSet.cpp ConflictSet.h) + +add_executable(conflict_set_test ConflictSet.cpp ConflictSet.h) +target_compile_definitions(conflict_set_test PRIVATE ENABLE_TESTS) +# keep asserts for test +target_compile_options(conflict_set_test PRIVATE -UNDEBUG) + +include(CTest) +add_test(NAME conflict_set_test COMMAND conflict_set_test) \ No newline at end of file diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 8c7eef5..0246588 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -149,3 +149,7 @@ ConflictSet &ConflictSet::operator=(ConflictSet &&other) noexcept { impl = std::exchange(other.impl, nullptr); return *this; } + +#ifdef ENABLE_TESTS +int main(void) { ConflictSet cs{0}; } +#endif \ No newline at end of file