fixed column generator test

This commit is contained in:
2025-02-11 21:48:47 +01:00
parent 1d83abcb1b
commit 55f9f8cf67
3 changed files with 53 additions and 35 deletions
+23 -15
View File
@@ -11,8 +11,7 @@ TEST_CASE("Test create empty column", "[column]") {
REQUIRE(c.name() == "name");
REQUIRE(c.index() == -1);
REQUIRE(c.type() == basic_type::type_null);
REQUIRE(c.reference_column()->table_name().empty());
REQUIRE(c.reference_column()->name().empty());
REQUIRE(!c.reference_column());
c.set(std::string{"george"}, 255);
REQUIRE(c.type() == basic_type::type_varchar);
@@ -26,38 +25,47 @@ TEST_CASE("Test create empty column", "[column]") {
}
TEST_CASE("Test copy and move column", "[column]") {
attribute_definition c("name");
attribute_definition c(
"name",
basic_type::type_varchar,
2,
std::make_shared<attribute_definition>("author", "books", basic_type::type_uint32, constraints::FOREIGN_KEY),
constraints::FOREIGN_KEY,
null_option::NOT_NULL
);
c.set(std::string{"george"}, 255);
REQUIRE(c.name() == "name");
REQUIRE(c.index() == -1);
REQUIRE(c.reference_column()->table_name().empty());
REQUIRE(c.reference_column()->name().empty());
REQUIRE(c.index() == 2);
REQUIRE(c.reference_column());
REQUIRE(c.reference_column()->name() == "author");
REQUIRE(c.reference_column()->table_name() == "books");
REQUIRE(c.type() == basic_type::type_varchar);
REQUIRE(c.as<std::string>() == "george");
REQUIRE(c.attributes().size() == 255);
auto c2 = c;
REQUIRE(c2.name() == "name");
REQUIRE(c2.index() == -1);
REQUIRE(c2.reference_column()->table_name().empty());
REQUIRE(c2.reference_column()->name().empty());
REQUIRE(c2.index() == 2);
REQUIRE(c2.reference_column());
REQUIRE(c2.reference_column()->name() == "author");
REQUIRE(c2.reference_column()->table_name() == "books");
REQUIRE(c2.type() == basic_type::type_varchar);
REQUIRE(c2.as<std::string>() == "george");
REQUIRE(c2.attributes().size() == 255);
auto c3 = std::move(c2);
REQUIRE(c3.name() == "name");
REQUIRE(c3.index() == -1);
REQUIRE(c3.reference_column()->table_name().empty());
REQUIRE(c3.reference_column()->name().empty());
REQUIRE(c3.index() == 2);
REQUIRE(c3.reference_column());
REQUIRE(c3.reference_column()->name() == "author");
REQUIRE(c3.reference_column()->table_name() == "books");
REQUIRE(c3.type() == basic_type::type_varchar);
REQUIRE(c3.as<std::string>() == "george");
REQUIRE(c3.attributes().size() == 255);
REQUIRE(c2.name().empty());
REQUIRE(c2.index() == -1);
REQUIRE(c2.reference_column()->table_name().empty());
REQUIRE(c2.reference_column()->name().empty());
REQUIRE(c2.index() == 2);
REQUIRE(!c2.reference_column());
REQUIRE(c2.type() == basic_type::type_null);
// REQUIRE(!c2.as<std::string>().has_value());
REQUIRE(c2.attributes().size() == 255);