utils: improve assert_equal macro
make it a macro so we get line numbers etc
This commit is contained in:
@ -502,21 +502,6 @@ Mu::canonicalize_filename(const std::string& path, const std::string& relative_t
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
Mu::assert_equal(const std::string& s1, const std::string& s2)
|
||||
{
|
||||
g_assert_cmpstr(s1.c_str(), ==, s2.c_str());
|
||||
}
|
||||
|
||||
void
|
||||
Mu::assert_equal(const Mu::StringVec& v1, const Mu::StringVec& v2)
|
||||
{
|
||||
g_assert_cmpuint(v1.size(), ==, v2.size());
|
||||
|
||||
for (auto i = 0U; i != v1.size(); ++i)
|
||||
assert_equal(v1[i], v2[i]);
|
||||
}
|
||||
|
||||
void
|
||||
Mu::allow_warnings()
|
||||
{
|
||||
|
||||
@ -313,14 +313,23 @@ private:
|
||||
* @param s1 string1
|
||||
* @param s2 string2
|
||||
*/
|
||||
void assert_equal(const std::string& s1, const std::string& s2);
|
||||
#define assert_equal(s1__,s2__) do { \
|
||||
std::string s1s__(s1__), s2s__(s2__); \
|
||||
g_assert_cmpstr(s1s__.c_str(), ==, s2s__.c_str()); \
|
||||
} while(0)
|
||||
|
||||
|
||||
/**
|
||||
* For unit tests, assert that to containers are the same.
|
||||
*
|
||||
* @param c1 container1
|
||||
* @param c2 container2
|
||||
*/
|
||||
void assert_equal(const StringVec& v1, const StringVec& v2);
|
||||
#define assert_equal_svec(svec1__,svec2__) do { \
|
||||
g_assert_cmpuint((svec1__).size(), ==, (svec2__).size()); \
|
||||
for (auto i = 0U; i != (svec1__).size(); ++i) \
|
||||
g_assert_cmpstr((svec1__)[i].c_str(), ==, (svec2__)[i].c_str()); \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* For unit-tests, allow warnings in the current function.
|
||||
|
||||
Reference in New Issue
Block a user