Skip to content

Commit

Permalink
Start to replace Catch2 with doctest. Dummy test only
Browse files Browse the repository at this point in the history
  • Loading branch information
markkohdev committed Mar 30, 2024
1 parent 0474c19 commit f2d795c
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 31 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "cpp/include/Catch2"]
path = cpp/include/Catch2
url = [email protected]:catchorg/Catch2.git
[submodule "cpp/include/doctest"]
path = cpp/include/doctest
url = [email protected]:doctest/doctest.git
7 changes: 5 additions & 2 deletions cpp/include/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@

add_subdirectory(Catch2)
include(Catch)
add_library(doctest INTERFACE)
target_include_directories(doctest
INTERFACE
doctest/doctest
)
1 change: 0 additions & 1 deletion cpp/include/Catch2
Submodule Catch2 deleted from 863c66
1 change: 1 addition & 0 deletions cpp/include/doctest
Submodule doctest added at ae7a13
5 changes: 3 additions & 2 deletions cpp/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
49 changes: 26 additions & 23 deletions cpp/test/test_main.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "TypedIndex.h"

#include <catch2/catch_template_test_macros.hpp>
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <catch2/generators/catch_generators_range.hpp>
#include <catch2/matchers/catch_matchers_templated.hpp>
#include "doctest.h"

#include <algorithm>
#include <cstdint>
#include <filesystem>
#include <memory>
#include <random>
#include <type_traits>
#include <utility>
// #include <algorithm>
// #include <cstdint>
// #include <filesystem>
// #include <memory>
// #include <random>
// #include <type_traits>
// #include <utility>

// TODO: Extract data generation as a function or as a Catch2 Generator

Expand Down Expand Up @@ -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<float>(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<float>(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<float> index = TypedIndex<float>(space, num_dimensions);
// CHECK(index.getSpace() == space);
}

// // dist_t, data_t, scalefactor, tolerance
Expand Down

0 comments on commit f2d795c

Please sign in to comment.