summaryrefslogtreecommitdiff
path: root/libpqpp/unittests
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2016-02-19 21:25:02 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2016-02-19 21:25:02 +0000
commit0bf706059f8a6df882cac3d6e7e976f4432b4271 (patch)
tree69d6641af24d31227ed616bf9c0c9ee1f27ea167 /libpqpp/unittests
parentBuild most things by default (diff)
downloadlibdbpp-postgresql-0bf706059f8a6df882cac3d6e7e976f4432b4271.tar.bz2
libdbpp-postgresql-0bf706059f8a6df882cac3d6e7e976f4432b4271.tar.xz
libdbpp-postgresql-0bf706059f8a6df882cac3d6e7e976f4432b4271.zip
Refactor to use std::string as buffer and increase test coverage
Diffstat (limited to 'libpqpp/unittests')
-rw-r--r--libpqpp/unittests/testpq.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/libpqpp/unittests/testpq.cpp b/libpqpp/unittests/testpq.cpp
index 96e5611..80757db 100644
--- a/libpqpp/unittests/testpq.cpp
+++ b/libpqpp/unittests/testpq.cpp
@@ -54,6 +54,31 @@ BOOST_AUTO_TEST_CASE( bindAndSend )
mod->bindParamT(4, testDateTime);
mod->bindParamT(5, testInterval);
mod->execute();
+ mod->bindParamI(0, (unsigned int)(testInt + 10));
+ mod->bindParamF(1, (float)(testDouble + 10));
+ mod->bindParamS(2, testString + " something");
+ mod->bindParamB(3, true);
+ mod->bindParamT(4, testDateTime);
+ mod->bindParamT(5, testInterval);
+ mod->execute();
+ mod->bindNull(0);
+ mod->bindParamI(1, (long long unsigned int)(testDouble + 10));
+ mod->bindParamI(2, (long long int)testInt);
+ mod->bindParamB(3, true);
+ mod->bindNull(4);
+ mod->bindNull(5);
+ mod->execute();
+ mod->bindNull(0);
+ mod->bindParamI(1, (long unsigned int)(testDouble + 10));
+ mod->bindParamI(2, (long int)testInt);
+ mod->bindParamB(3, true);
+ mod->bindParamS(4, "2016-01-01T12:34:56");
+ mod->bindNull(5);
+ mod->execute();
+ delete mod;
+ mod = rw->newModifyCommand("DELETE FROM test WHERE string = '?'");
+ BOOST_REQUIRE_THROW(mod->execute(false), DB::NoRowsAffected);
+ BOOST_REQUIRE_EQUAL(0, mod->execute(true));
delete mod;
delete rw;
}
@@ -103,8 +128,9 @@ BOOST_AUTO_TEST_CASE( bindAndSelectOther )
{
auto ro = DB::MockDatabase::openConnectionTo("pqmock");
- auto select = ro->newSelectCommand("SELECT * FROM test WHERE id != ?");
+ auto select = ro->newSelectCommand("SELECT * FROM test WHERE id != ? AND id != ?");
select->bindParamI(0, testInt);
+ select->bindParamI(1, testInt + 10);
select->execute();
int rows = 0;
while (select->fetch()) {