Skip to content

Commit 905edac

Browse files
committed
test: extend static checks for the get operators class
Validate positive cases only
1 parent fc30ca2 commit 905edac

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

tests/static_tests/get_pk_ids.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include <sqlite_orm/sqlite_orm.h>
2+
#include <catch2/catch_all.hpp>
3+
4+
#include <type_traits> // std::is_same
5+
#include <memory> // std::unique_ptr, std::shared_ptr
6+
#include <string> // std::string
7+
#ifdef SQLITE_ORM_OPTIONAL_SUPPORTED
8+
#include <optional> // std::optional
9+
#endif
10+
11+
using namespace sqlite_orm;
12+
13+
TEST_CASE("get* and remove accept bindable pk types") {
14+
struct User {
15+
int id = 0;
16+
std::string name;
17+
};
18+
19+
using Storage = decltype(make_storage(
20+
"",
21+
make_table("users", make_column("id", &User::id, primary_key()), make_column("name", &User::name))));
22+
23+
STATIC_REQUIRE(std::is_same_v<decltype(std::declval<Storage>().get<User>(std::declval<int>())), User>);
24+
25+
STATIC_REQUIRE(std::is_same_v<decltype(std::declval<Storage>().get_pointer<User>(std::declval<int>())),
26+
std::unique_ptr<User>>);
27+
28+
STATIC_REQUIRE(std::is_same_v<decltype(std::declval<Storage>().get_no_throw<User>(std::declval<int>())),
29+
std::shared_ptr<User>>);
30+
31+
#ifdef SQLITE_ORM_OPTIONAL_SUPPORTED
32+
STATIC_REQUIRE(
33+
std::is_same_v<decltype(std::declval<Storage>().get_optional<User>(std::declval<int>())), std::optional<User>>);
34+
#endif
35+
36+
STATIC_REQUIRE(std::is_same_v<decltype(std::declval<Storage>().remove<User>(std::declval<int>())), void>);
37+
}

0 commit comments

Comments
 (0)