summaryrefslogtreecommitdiff
path: root/libpqpp/unittests/testpq.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2016-02-25 22:24:53 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2016-02-25 22:24:53 +0000
commita6be6d86457a0b5dc982a0d4c7128a510313506d (patch)
tree1296ebbdfcd3f326013d2730e91be0c279cec0de /libpqpp/unittests/testpq.cpp
parentRefactor to use std::string as buffer and increase test coverage (diff)
downloadlibdbpp-postgresql-a6be6d86457a0b5dc982a0d4c7128a510313506d.tar.bz2
libdbpp-postgresql-a6be6d86457a0b5dc982a0d4c7128a510313506d.tar.xz
libdbpp-postgresql-a6be6d86457a0b5dc982a0d4c7128a510313506d.zip
Reuse prepared statements
Diffstat (limited to 'libpqpp/unittests/testpq.cpp')
-rw-r--r--libpqpp/unittests/testpq.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/libpqpp/unittests/testpq.cpp b/libpqpp/unittests/testpq.cpp
index 80757db..3d8c804 100644
--- a/libpqpp/unittests/testpq.cpp
+++ b/libpqpp/unittests/testpq.cpp
@@ -262,6 +262,22 @@ BOOST_AUTO_TEST_CASE( reconnectInTx )
delete rok;
}
+BOOST_AUTO_TEST_CASE( statementReuse )
+{
+ auto ro = DB::MockDatabase::openConnectionTo("pqmock");
+ auto pqconn = dynamic_cast<PQ::Connection *>(ro);
+ BOOST_REQUIRE_EQUAL(pqconn->preparedStatements.size(), 0);
+ for (int y = 0; y < 4; y += 1) {
+ auto m1 = ro->modify("INSERT INTO test(id) VALUES(?)");
+ for (int x = 0; x < 4; x += 1) {
+ m1->bindParamI(0, x);
+ m1->execute();
+ }
+ }
+ BOOST_REQUIRE_EQUAL(pqconn->preparedStatements.size(), 1);
+ delete ro;
+}
+
BOOST_AUTO_TEST_SUITE_END();
BOOST_AUTO_TEST_CASE( connfail )