Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
fnc12 committed Sep 22, 2023
1 parent 856132b commit 328673c
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 48 deletions.
7 changes: 3 additions & 4 deletions tests/statement_serializer_tests/ast/match.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
using namespace sqlite_orm;

TEST_CASE("statement_serializer match") {
struct User {
struct User {
int id = 0;
std::string name;
};
auto table = make_virtual_table("users",
using_fts5(make_column("id", &User::id),
make_column("name", &User::name)));
auto table =
make_virtual_table("users", using_fts5(make_column("id", &User::id), make_column("name", &User::name)));
using db_objects_t = internal::db_objects_tuple<decltype(table)>;
auto dbObjects = db_objects_t{table};
using context_t = internal::serializer_context<db_objects_t>;
Expand Down
12 changes: 6 additions & 6 deletions tests/statement_serializer_tests/ast/rank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ TEST_CASE("statement_serializer rank") {
std::string value;
std::string expected;
SECTION("rank") {
auto node = rank();
value = serialize(node, context);
expected = "rank";
auto node = rank();
value = serialize(node, context);
expected = "rank";
}
SECTION("order by rank") {
auto node = order_by(rank());
value = serialize(node, context);
expected = "ORDER BY rank";
auto node = order_by(rank());
value = serialize(node, context);
expected = "ORDER BY rank";
}
REQUIRE(value == expected);
}
54 changes: 27 additions & 27 deletions tests/statement_serializer_tests/schema/column.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,38 @@
using namespace sqlite_orm;

TEST_CASE("statement_serializer column") {
struct User {
int id = 0;
std::string name;
};
internal::db_objects_tuple<> storage;
internal::serializer_context<internal::db_objects_tuple<>> context{storage};
struct User {
int id = 0;
std::string name;
};
internal::db_objects_tuple<> storage;
internal::serializer_context<internal::db_objects_tuple<>> context{storage};
std::string value;
std::string expected;
SECTION("with types and constraints") {
SECTION("id INTEGER NOT NULL") {
auto column = make_column("id", &User::id);
value = serialize(column, context);
expected = "\"id\" INTEGER NOT NULL";
}
SECTION("name TEXT NOT NULL") {
auto column = make_column("name", &User::name);
value = serialize(column, context);
expected = "\"name\" TEXT NOT NULL";
}
SECTION("id INTEGER NOT NULL") {
auto column = make_column("id", &User::id);
value = serialize(column, context);
expected = "\"id\" INTEGER NOT NULL";
}
SECTION("name TEXT NOT NULL") {
auto column = make_column("name", &User::name);
value = serialize(column, context);
expected = "\"name\" TEXT NOT NULL";
}
}
SECTION("without types and constraints") {
auto subContext = internal::make_serializer_context_with_no_types_and_constraints(context);
SECTION("id INTEGER NOT NULL") {
auto column = make_column("id", &User::id);
value = serialize(column, context);
expected = "\"id\"";
}
SECTION("name TEXT NOT NULL") {
auto column = make_column("name", &User::name);
value = serialize(column, context);
expected = "\"name\"";
}
auto subContext = internal::make_serializer_context_with_no_types_and_constraints(context);
SECTION("id INTEGER NOT NULL") {
auto column = make_column("id", &User::id);
value = serialize(column, context);
expected = "\"id\"";
}
SECTION("name TEXT NOT NULL") {
auto column = make_column("name", &User::name);
value = serialize(column, context);
expected = "\"name\"";
}
}
REQUIRE(value == expected);
}
8 changes: 3 additions & 5 deletions tests/statement_serializer_tests/schema/using_fts5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
using namespace sqlite_orm;

TEST_CASE("statement_serializer using_fts5") {
struct Post {
struct Post {
std::string title;
std::string body;
};
internal::db_objects_tuple<> storage;
internal::db_objects_tuple<> storage;
internal::serializer_context<internal::db_objects_tuple<>> context{storage};
auto node = using_fts5(
make_column("title", &Post::title),
make_column("body", &Post::body));
auto node = using_fts5(make_column("title", &Post::title), make_column("body", &Post::body));
auto value = serialize(node, context);
REQUIRE(value == "USING FTS5(\"title\", \"body\")");
}
11 changes: 5 additions & 6 deletions tests/statement_serializer_tests/schema/virtual_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
using namespace sqlite_orm;

TEST_CASE("statement_serializer FTS5") {
struct Post {
struct Post {
std::string title;
std::string body;
};
internal::db_objects_tuple<> storage;
internal::serializer_context<internal::db_objects_tuple<>> context{storage};
auto node = make_virtual_table("posts", using_fts5(
make_column("title", &Post::title),
make_column("body", &Post::body)));
auto value = serialize(node, context);
REQUIRE(value == "CREATE VIRTUAL TABLE IF NOT EXISTS \"posts\" USING FTS5(\"title\", \"body\")");
auto node =
make_virtual_table("posts", using_fts5(make_column("title", &Post::title), make_column("body", &Post::body)));
auto value = serialize(node, context);
REQUIRE(value == "CREATE VIRTUAL TABLE IF NOT EXISTS \"posts\" USING FTS5(\"title\", \"body\")");
}

0 comments on commit 328673c

Please sign in to comment.