summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2017-02-17 22:02:06 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2017-02-17 22:02:06 +0000
commit7d3a8e8937af7b96f581744f8217a3c9b01ed1a6 (patch)
treed901f2b15a29d20b9f86e28c3b0e8d25be91c526
parentCreate maintenance mock and client once per test, not globally (diff)
downloadgentoobrowse-api-7d3a8e8937af7b96f581744f8217a3c9b01ed1a6.tar.bz2
gentoobrowse-api-7d3a8e8937af7b96f581744f8217a3c9b01ed1a6.tar.xz
gentoobrowse-api-7d3a8e8937af7b96f581744f8217a3c9b01ed1a6.zip
Update SQL_REQUIRE_EQUAL to accept literals and include SQL context
-rw-r--r--gentoobrowse-api/unittests/mockDefs.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/gentoobrowse-api/unittests/mockDefs.h b/gentoobrowse-api/unittests/mockDefs.h
index 5bb1cd5..586079f 100644
--- a/gentoobrowse-api/unittests/mockDefs.h
+++ b/gentoobrowse-api/unittests/mockDefs.h
@@ -10,6 +10,7 @@
#include <notifications.h>
#include <mocks.h>
#include <selectcommandUtil.impl.h>
+#include <boost/test/tools/context.hpp>
class MockMailServerImpl : public Gentoo::MockMailServer {
public:
@@ -46,8 +47,13 @@ class DLL_PUBLIC TestClient : public IceTray::DryIceClient {
Gentoo::UsersPrx u;
};
-#define SQL_REQUIRE_EQUAL(sql, type, expected) \
- db->select(sql)->forEachRow<type>([&expected](const auto & n) { BOOST_REQUIRE_EQUAL(expected, n); });
+#define SQL_REQUIRE_EQUAL(sql, type, expected) BOOST_TEST_CONTEXT(sql) { sqlRequireEqual<type>(db, sql, expected); }
+template<typename T>
+void sqlRequireEqual(DB::ConnectionPtr db, const char * const sql, const T & expected) {
+ db->select(sql)->forEachRow<T>([expected](const auto & n) {
+ BOOST_REQUIRE_EQUAL(expected, n);
+ });
+}
#endif