summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2019-02-03 20:27:35 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2019-02-03 20:27:35 +0000
commit50ede6c8b8036feac1c96f6ccdd68e861a745b5d (patch)
treefc94ef33df0d1aba529fc217a0ee29a4a35167cd
parentRemove p2 reference from mock names (diff)
downloadlibdbpp-mysql-50ede6c8b8036feac1c96f6ccdd68e861a745b5d.tar.bz2
libdbpp-mysql-50ede6c8b8036feac1c96f6ccdd68e861a745b5d.tar.xz
libdbpp-mysql-50ede6c8b8036feac1c96f6ccdd68e861a745b5d.zip
Fix test of insertIds
Don't assume ids will be 1,2,3,4... they might skip some, but always increasing in value
-rw-r--r--libmysqlpp/unittests/testmysql.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/libmysqlpp/unittests/testmysql.cpp b/libmysqlpp/unittests/testmysql.cpp
index 4691a28..04e7212 100644
--- a/libmysqlpp/unittests/testmysql.cpp
+++ b/libmysqlpp/unittests/testmysql.cpp
@@ -131,15 +131,14 @@ BOOST_AUTO_TEST_CASE( insertId )
{
auto ro = DB::MockDatabase::openConnectionTo("mysqlmock");
auto ins = ro->modify("INSERT INTO inserts(num) VALUES(?)");
- ins->bindParamI(0, 4);
- ins->execute();
- BOOST_REQUIRE_EQUAL(1, ro->insertId());
- ins->bindParamI(0, 40);
- ins->execute();
- BOOST_REQUIRE_EQUAL(2, ro->insertId());
- ins->bindParamI(0, -4);
- ins->execute();
- BOOST_REQUIRE_EQUAL(3, ro->insertId());
+ int prevId = 0;
+ for (int n : { 4, 40, -4 }) {
+ ins->bindParamI(0, n);
+ ins->execute();
+ auto id = ro->insertId();
+ BOOST_REQUIRE_GT(id, prevId);
+ prevId = id;
+ }
}
BOOST_AUTO_TEST_CASE( errors )