/
UCS
/
sqlite_orm
Обзор
Документация
Войти
/
UCS
/
sqlite_orm
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
tests/statement_serializer_tests/conditions.cpp
45 строк
1 KB
klaus triendl
Updated to Catch2 v3
15 янв 2023, 22:59
15 янв 2023, 22:59
3154d24
Код
Авторство
О чём код?
#include <sqlite_orm/sqlite_orm.h> #include <catch2/catch_all.hpp> using namespace sqlite_orm; TEST_CASE("statement_serializer conditions") { std::string value, expected; SECTION("using") { struct User { int64 id; }; auto t1 = make_table("user", make_column("id", &User::id)); auto storage = internal::db_objects_tuple<decltype(t1)>{t1}; using db_objects_tuple = decltype(storage); internal::serializer_context<db_objects_tuple> ctx{storage}; SECTION("using column") { auto expression = using_(&User::id); value = serialize(expression, ctx); expected = R"(USING ("id"))"; } SECTION("using explicit column") { auto expression = using_(column<User>(&User::id)); value = serialize(expression, ctx); expected = R"(USING ("id"))"; } } SECTION("order by") { auto storage = internal::db_objects_tuple<>{}; using db_objects_tuple = decltype(storage); internal::serializer_context<db_objects_tuple> ctx{storage}; SECTION("positional ordinal") { auto expression = order_by(1); value = serialize(expression, ctx); expected = "ORDER BY 1"; } } REQUIRE(value == expected); }