diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-02-17 22:02:06 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2017-02-17 22:02:06 +0000 |
commit | acf2d5bb30fe49fe5669b03359fbfebf4a0d5495 (patch) | |
tree | d901f2b15a29d20b9f86e28c3b0e8d25be91c526 | |
parent | Create maintenance mock and client once per test, not globally (diff) | |
download | gentoobrowse-api-acf2d5bb30fe49fe5669b03359fbfebf4a0d5495.tar.bz2 gentoobrowse-api-acf2d5bb30fe49fe5669b03359fbfebf4a0d5495.tar.xz gentoobrowse-api-acf2d5bb30fe49fe5669b03359fbfebf4a0d5495.zip |
Update SQL_REQUIRE_EQUAL to accept literals and include SQL context
-rw-r--r-- | gentoobrowse-api/unittests/mockDefs.h | 10 |
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 |