Skip to content

Commit

Permalink
Adapt test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzmbrzl committed May 1, 2024
1 parent 795ab44 commit 21b433d
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions tests/common-tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -6757,17 +6757,21 @@ TEST_CASE_METHOD(common_tests, "BLOB", "[core][blob]")
SECTION("Blob binding")
{
// Add data
soci::blob blob(sql);
soci::blob blob1(sql);
soci::blob blob2(sql);
static_assert(10 <= sizeof(dummy_data), "Underlying assumption violated");
blob.write_from_start(dummy_data, 10);
const int id = 42;
sql << "insert into soci_test (id, b) values(:id, :b)", soci::use(id), soci::use(blob);
blob1.write_from_start(dummy_data, 10);
blob2.write_from_start(dummy_data, 10);
const int id1 = 42;
const int id2 = 42;
sql << "insert into soci_test (id, b) values(:id, :b)", soci::use(id1), soci::use(blob1);
sql << "insert into soci_test (id, b) values(:id, :b)", soci::use(id2), soci::use(blob2);

SECTION("into")
{
soci::blob intoBlob(sql);

sql << "select b from soci_test where id=:id", soci::use(id), soci::into(intoBlob);
sql << "select b from soci_test where id=:id", soci::use(id1), soci::into(intoBlob);

char buffer[20];
std::size_t written = intoBlob.read_from_start(buffer, sizeof(buffer));
Expand All @@ -6779,8 +6783,7 @@ TEST_CASE_METHOD(common_tests, "BLOB", "[core][blob]")
}
SECTION("move_as")
{
//soci::rowset< soci::row > rowSet = (sql.prepare << "select b from soci_test where id=:id", soci::use(id));
soci::rowset< soci::row > rowSet = (sql.prepare << "select b from soci_test where id=:id union all select b from soci_test where id=:id", soci::use(id, "id"));
soci::rowset< soci::row > rowSet = (sql.prepare << "select b from soci_test where id=:id", soci::use(id1));
bool containedData = false;
for (auto it = rowSet.begin(); it != rowSet.end(); ++it)
{
Expand All @@ -6802,8 +6805,8 @@ TEST_CASE_METHOD(common_tests, "BLOB", "[core][blob]")
}
SECTION("reusing bound blob")
{
int secondID = id + 1;
sql << "insert into soci_test(id, b) values(:id, :b)", soci::use(secondID), soci::use(blob);
int secondID = id2 + 1;
sql << "insert into soci_test(id, b) values(:id, :b)", soci::use(secondID), soci::use(blob2);

// Selecting the blob associated with secondID should yield the same result as selecting the one for id
soci::blob intoBlob(sql);
Expand Down

0 comments on commit 21b433d

Please sign in to comment.