From f2d795c4d490ce103a380de8d02b5b9179073d36 Mon Sep 17 00:00:00 2001 From: Mark Koh Date: Fri, 29 Mar 2024 18:46:53 -0600 Subject: [PATCH] Start to replace Catch2 with doctest. Dummy test only --- .gitmodules | 6 ++--- cpp/include/CMakeLists.txt | 7 ++++-- cpp/include/Catch2 | 1 - cpp/include/doctest | 1 + cpp/test/CMakeLists.txt | 5 ++-- cpp/test/test_main.cpp | 49 ++++++++++++++++++++------------------ 6 files changed, 38 insertions(+), 31 deletions(-) delete mode 160000 cpp/include/Catch2 create mode 160000 cpp/include/doctest diff --git a/.gitmodules b/.gitmodules index 7b78b421..ad8e9471 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "cpp/include/Catch2"] - path = cpp/include/Catch2 - url = git@github.com:catchorg/Catch2.git +[submodule "cpp/include/doctest"] + path = cpp/include/doctest + url = git@github.com:doctest/doctest.git diff --git a/cpp/include/CMakeLists.txt b/cpp/include/CMakeLists.txt index 2d465b52..09236b80 100644 --- a/cpp/include/CMakeLists.txt +++ b/cpp/include/CMakeLists.txt @@ -1,3 +1,6 @@ -add_subdirectory(Catch2) -include(Catch) +add_library(doctest INTERFACE) +target_include_directories(doctest + INTERFACE + doctest/doctest +) \ No newline at end of file diff --git a/cpp/include/Catch2 b/cpp/include/Catch2 deleted file mode 160000 index 863c662c..00000000 --- a/cpp/include/Catch2 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 863c662c0eff026300f4d729a7054e90d6d12cdd diff --git a/cpp/include/doctest b/cpp/include/doctest new file mode 160000 index 00000000..ae7a1353 --- /dev/null +++ b/cpp/include/doctest @@ -0,0 +1 @@ +Subproject commit ae7a13539fb71f270b87eb2e874fbac80bc8dda2 diff --git a/cpp/test/CMakeLists.txt b/cpp/test/CMakeLists.txt index a153e455..a60eff8e 100644 --- a/cpp/test/CMakeLists.txt +++ b/cpp/test/CMakeLists.txt @@ -1,12 +1,13 @@ add_executable(test test_main.cpp) + + target_link_libraries(test PUBLIC VoyagerLib PRIVATE - Catch2::Catch2WithMain + doctest ) target_compile_options(test PRIVATE -O2 -g) include(CTest) -catch_discover_tests(test) diff --git a/cpp/test/test_main.cpp b/cpp/test/test_main.cpp index b99af38b..9c893cb9 100644 --- a/cpp/test/test_main.cpp +++ b/cpp/test/test_main.cpp @@ -1,18 +1,15 @@ +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include "TypedIndex.h" -#include -#include -#include -#include -#include +#include "doctest.h" -#include -#include -#include -#include -#include -#include -#include +// #include +// #include +// #include +// #include +// #include +// #include +// #include // TODO: Extract data generation as a function or as a Catch2 Generator @@ -57,17 +54,23 @@ // }; TEST_CASE("Basic init") { - auto space = GENERATE(SpaceType::Euclidean, SpaceType::InnerProduct); - auto num_dimensions = GENERATE(4, 16, 128, 256); - auto num_elements = GENERATE(100, 1000); - - SECTION("(num_dimensions, num_elements, space): (" + std::to_string(num_dimensions) + "," + - std::to_string(num_elements) + "," + std::to_string(space) + ")") { - auto index = TypedIndex(space, num_dimensions); - REQUIRE(index.getSpace() == space); - REQUIRE(index.getStorageDataType() == StorageDataType::Float32); - REQUIRE(index.getNumDimensions() == num_dimensions); - } + // auto space = GENERATE(SpaceType::Euclidean, SpaceType::InnerProduct); + // auto num_dimensions = GENERATE(4, 16, 128, 256); + // auto num_elements = GENERATE(100, 1000); + + // SECTION("(num_dimensions, num_elements, space): (" + std::to_string(num_dimensions) + "," + + // std::to_string(num_elements) + "," + std::to_string(space) + ")") { + // auto index = TypedIndex(space, num_dimensions); + // REQUIRE(index.getSpace() == space); + // REQUIRE(index.getStorageDataType() == StorageDataType::Float32); + // REQUIRE(index.getNumDimensions() == num_dimensions); + // } + + CHECK(1 == 1); + // SpaceType space = SpaceType::Euclidean; + // int num_dimensions = 10; + // TypedIndex index = TypedIndex(space, num_dimensions); + // CHECK(index.getSpace() == space); } // // dist_t, data_t, scalefactor, tolerance