#include #include "matador/object/attribute_definition.hpp" using namespace matador::object; using namespace matador::utils; TEST_CASE("Test create empty column", "[column]") { attribute_definition c("name"); REQUIRE(c.name() == "name"); REQUIRE(c.index() == -1); REQUIRE(c.type() == basic_type::type_null); REQUIRE(c.ref_table().empty()); REQUIRE(c.ref_column().empty()); c.set(std::string{"george"}, 255); REQUIRE(c.type() == basic_type::type_varchar); REQUIRE(c.as() == "george"); c.set(7); REQUIRE(c.type() == basic_type::type_int32); REQUIRE(c.as() == "7"); REQUIRE(c.as() == 7); REQUIRE(c.str() == "7"); } TEST_CASE("Test copy and move column", "[column]") { attribute_definition c("name"); c.set(std::string{"george"}, 255); REQUIRE(c.name() == "name"); REQUIRE(c.index() == -1); REQUIRE(c.ref_table().empty()); REQUIRE(c.ref_column().empty()); REQUIRE(c.type() == basic_type::type_varchar); REQUIRE(c.as() == "george"); REQUIRE(c.attributes().size() == 255); auto c2 = c; REQUIRE(c2.name() == "name"); REQUIRE(c2.index() == -1); REQUIRE(c2.ref_table().empty()); REQUIRE(c2.ref_column().empty()); REQUIRE(c2.type() == basic_type::type_varchar); REQUIRE(c2.as() == "george"); REQUIRE(c2.attributes().size() == 255); auto c3 = std::move(c2); REQUIRE(c3.name() == "name"); REQUIRE(c3.index() == -1); REQUIRE(c3.ref_table().empty()); REQUIRE(c3.ref_column().empty()); REQUIRE(c3.type() == basic_type::type_varchar); REQUIRE(c3.as() == "george"); REQUIRE(c3.attributes().size() == 255); REQUIRE(c2.name().empty()); REQUIRE(c2.index() == -1); REQUIRE(c2.ref_table().empty()); REQUIRE(c2.ref_column().empty()); REQUIRE(c2.type() == basic_type::type_null); // REQUIRE(!c2.as().has_value()); REQUIRE(c2.attributes().size() == 255); }