From 50ede6c8b8036feac1c96f6ccdd68e861a745b5d Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 3 Feb 2019 20:27:35 +0000 Subject: Fix test of insertIds Don't assume ids will be 1,2,3,4... they might skip some, but always increasing in value --- libmysqlpp/unittests/testmysql.cpp | 17 ++++++++--------- 1 file 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 ) -- cgit v1.2.3