added conversion from/to blob

This commit is contained in:
2024-03-10 16:55:55 +01:00
parent dd94ed1020
commit 6bbc870362
3 changed files with 30 additions and 2 deletions
+16 -2
View File
@@ -2,10 +2,10 @@
#include "matador/sql/field.hpp"
using namespace matador::sql;
using namespace matador;
TEST_CASE("Field test", "[field]") {
field f("name");
sql::field f("name");
REQUIRE(f.name() == "name");
REQUIRE(f.is_null());
@@ -35,4 +35,18 @@ TEST_CASE("Field test", "[field]") {
auto bool_val = f.as<bool>();
REQUIRE(bool_val.has_value());
REQUIRE(bool_val.value());
f = utils::blob{ 7,8,6,5,4,3 };
REQUIRE(!f.is_null());
REQUIRE(!f.is_integer());
REQUIRE(!f.is_floating_point());
REQUIRE(f.is_blob());
REQUIRE(!f.is_bool());
REQUIRE(!f.is_string());
auto blob_val = f.as<utils::blob>();
REQUIRE(blob_val.has_value());
REQUIRE(blob_val.value() == utils::blob{ 7,8,6,5,4,3 });
REQUIRE_THROWS_AS(f.as<std::string>(), std::logic_error);
}