column, placeholder and column_value generator progress
This commit is contained in:
@@ -27,6 +27,7 @@ add_executable(OrmTests
|
||||
sql/StatementCacheTest.cpp
|
||||
utils/auto_reset_event.cpp
|
||||
utils/auto_reset_event.hpp
|
||||
query/GeneratorTests.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(OrmTests matador-orm matador-core Catch2::Catch2WithMain)
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "matador/query/generator.hpp"
|
||||
|
||||
#include "matador/sql/column.hpp"
|
||||
|
||||
#include "../../models/airplane.hpp"
|
||||
#include "../../models/flight.hpp"
|
||||
|
||||
using namespace matador::utils;
|
||||
using namespace matador::query;
|
||||
using namespace matador::sql;
|
||||
using namespace matador::test;
|
||||
|
||||
TEST_CASE("Test placeholder generator", "[generator][placeholder]") {
|
||||
REQUIRE(generator::placeholders<airplane>() == std::vector{_, _, _});
|
||||
}
|
||||
|
||||
TEST_CASE("Test column value generator", "[generator][column_value]") {
|
||||
SECTION("Test column value generator for simple table") {
|
||||
const airplane a380{1, "Airbus", "A380"};
|
||||
const auto pairs = generator::column_value_pairs(a380);
|
||||
const std::vector<internal::column_value_pair> expected_result{
|
||||
{ "id", 1U },
|
||||
{ "brand", std::string{"Airbus"} },
|
||||
{ "model", std::string{"A380"} }
|
||||
};
|
||||
REQUIRE(pairs.size() == 3);
|
||||
REQUIRE(pairs == expected_result);
|
||||
}
|
||||
|
||||
SECTION("Test column value generator for table with foreign key") {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Test column generator", "[generator][column]") {
|
||||
SECTION("Test column generator for simple table") {
|
||||
const std::vector expected_columns {
|
||||
column("id"),
|
||||
column("brand"),
|
||||
column("model"),
|
||||
};
|
||||
const auto result = generator::columns<airplane>();
|
||||
REQUIRE(result.size() == expected_columns.size());
|
||||
auto it = result.begin();
|
||||
for (const auto& c : expected_columns) {
|
||||
REQUIRE(c.equals( *it++));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user