summaryrefslogtreecommitdiff
path: root/libpqpp/unittests/testpq.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2017-06-05 19:35:21 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2017-06-05 19:35:21 +0100
commit0349af8ee92590994d232baa4a72576b28d92a2d (patch)
treeef16004ea302a2df71f735556c81f5d3ab84cc9e /libpqpp/unittests/testpq.cpp
parentSupport fetching data in binary format (no numeric, datetime, interval suppor... (diff)
downloadlibdbpp-postgresql-0349af8ee92590994d232baa4a72576b28d92a2d.tar.bz2
libdbpp-postgresql-0349af8ee92590994d232baa4a72576b28d92a2d.tar.xz
libdbpp-postgresql-0349af8ee92590994d232baa4a72576b28d92a2d.zip
Use DB::Blob's own comparator
Diffstat (limited to 'libpqpp/unittests/testpq.cpp')
-rw-r--r--libpqpp/unittests/testpq.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/libpqpp/unittests/testpq.cpp b/libpqpp/unittests/testpq.cpp
index f9ebf64..9fb5f98 100644
--- a/libpqpp/unittests/testpq.cpp
+++ b/libpqpp/unittests/testpq.cpp
@@ -389,7 +389,8 @@ BOOST_AUTO_TEST_CASE( blobs )
std::vector<char> buf(29);
memcpy(&buf[0], "This is some binary text data", 29);
auto ins = ro->modify("INSERT INTO blobtest(data) VALUES(?)");
- ins->bindParamBLOB(0, buf);
+ DB::Blob blob(buf);
+ ins->bindParamBLOB(0, blob);
ins->execute();
ro->execute("UPDATE blobtest SET md5 = md5(data)");
@@ -403,7 +404,7 @@ BOOST_AUTO_TEST_CASE( blobs )
BOOST_REQUIRE_EQUAL(r.value<0>().len, buf.size());
std::string str((const char *)r.value<0>().data, r.value<0>().len);
BOOST_REQUIRE_EQUAL(str, "This is some binary text data");
- BOOST_REQUIRE(memcmp(r.value<0>().data, &buf[0], 29) == 0);
+ BOOST_REQUIRE_EQUAL(r.value<0>(), blob);
}
}
@@ -412,6 +413,7 @@ BOOST_AUTO_TEST_CASE( fetchAsBinary )
auto ro = DB::ConnectionPtr(DB::MockDatabase::openConnectionTo("PQmock"));
std::vector<char> buf(29);
memcpy(&buf[0], "This is some binary text data", 29);
+ DB::Blob blob(buf);
PQ::CommandOptions opts(0);
opts.fetchBinary = true;
opts.useCursor = false;
@@ -422,8 +424,7 @@ BOOST_AUTO_TEST_CASE( fetchAsBinary )
BOOST_REQUIRE(r.value<1>());
BOOST_REQUIRE_EQUAL(*r.value<1>(), "37c7c3737f93e8d17e845deff8fa74d2");
// Assert the fetch of the data is correct
- BOOST_REQUIRE_EQUAL(r.value<0>().len, buf.size());
- BOOST_REQUIRE(memcmp(r.value<0>().data, &buf[0], 29) == 0);
+ BOOST_REQUIRE_EQUAL(r.value<0>(), blob);
}
*opts.hash += 1;
sel = ro->select("SELECT CAST(length(data) AS BIGINT) big, CAST(length(data) AS SMALLINT) small FROM blobtest", &opts);