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
commit25a8f2a606dfbb1c4960f2ef1a14e64667e691d7 (patch)
tree889c020a1681e1c9088c3af45d95ea29c9061f90 /libpqpp/unittests/testpq.cpp
parentRefactor to use std::string as buffer and increase test coverage (diff)
downloadlibdbpp-postgresql-25a8f2a606dfbb1c4960f2ef1a14e64667e691d7.tar.bz2
libdbpp-postgresql-25a8f2a606dfbb1c4960f2ef1a14e64667e691d7.tar.xz
libdbpp-postgresql-25a8f2a606dfbb1c4960f2ef1a14e64667e691d7.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 )