Skip to content

Commit

Permalink
Unit tests for index sequence utils
Browse files Browse the repository at this point in the history
  • Loading branch information
trueqbit committed May 15, 2024
1 parent 5d9ffac commit 92eee16
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ add_executable(unit_tests
static_tests/functional/static_if_tests.cpp
static_tests/functional/mpl.cpp
static_tests/functional/same_or_void.cpp
static_tests/functional/index_sequence_util.cpp
static_tests/functional/tuple_conc.cpp
static_tests/functional/tuple_filter.cpp
static_tests/functional/tuple_traits.cpp
Expand Down
23 changes: 23 additions & 0 deletions tests/static_tests/functional/index_sequence_util.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <sqlite_orm/sqlite_orm.h>
#include <catch2/catch_all.hpp>

using std::index_sequence;
using namespace sqlite_orm;
using internal::flatten_idxseq_t;
using internal::index_sequence_value_at;

TEST_CASE("index sequence value at") {
STATIC_REQUIRE(index_sequence_value_at<0>(index_sequence<1, 3>{}) == 1);
#if defined(SQLITE_ORM_PACK_INDEXING_SUPPORTED) || defined(SQLITE_ORM_FOLD_EXPRESSIONS_SUPPORTED)
STATIC_REQUIRE(index_sequence_value_at<1>(index_sequence<1, 3>{}) == 3);
#endif
}

TEST_CASE("flatten index sequence") {
STATIC_REQUIRE(std::is_same<flatten_idxseq_t<>, index_sequence<>>::value);
STATIC_REQUIRE(std::is_same<flatten_idxseq_t<index_sequence<1, 3>>, index_sequence<1, 3>>::value);
STATIC_REQUIRE(
std::is_same<flatten_idxseq_t<index_sequence<1, 3>, index_sequence<1, 3>>, index_sequence<1, 3, 1, 3>>::value);
STATIC_REQUIRE(std::is_same<flatten_idxseq_t<index_sequence<1, 3>, index_sequence<1, 3>, index_sequence<1, 3>>,
index_sequence<1, 3, 1, 3, 1, 3>>::value);
}

0 comments on commit 92eee16

Please sign in to comment.