tests: update test helpers and users
Move test-mu-common to mu-test-utils. Use mu_test_init as a wrapper for g_test_init. Update users.
This commit is contained in:
@ -454,74 +454,6 @@ private:
|
||||
constexpr ET& operator|=(ET& e1, ET e2) { return e1 = e1 | e2; } \
|
||||
static_assert(1==1) // require a semicolon
|
||||
|
||||
/**
|
||||
* For unit tests, assert two std::string's are equal.
|
||||
*
|
||||
* @param s1 string1
|
||||
* @param s2 string2
|
||||
*/
|
||||
#define assert_equal(s1__,s2__) do { \
|
||||
std::string s1s__(s1__), s2s__(s2__); \
|
||||
g_assert_cmpstr(s1s__.c_str(), ==, s2s__.c_str()); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define assert_equal_seq(seq1__, seq2__) do { \
|
||||
g_assert_cmpuint(seq1__.size(), ==, seq2__.size()); \
|
||||
size_t n__{}; \
|
||||
for (auto&& item__: seq1__) { \
|
||||
g_assert_true(item__ == seq2__.at(n__)); \
|
||||
++n__; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define assert_equal_seq_str(seq1__, seq2__) do { \
|
||||
g_assert_cmpuint(seq1__.size(), ==, seq2__.size()); \
|
||||
size_t n__{}; \
|
||||
for (auto&& item__: seq1__) { \
|
||||
assert_equal(item__, seq2__.at(n__)); \
|
||||
++n__; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* For unit-tests, allow warnings in the current function.
|
||||
*
|
||||
*/
|
||||
void allow_warnings();
|
||||
|
||||
|
||||
/**
|
||||
* For unit-tests, a RAII tempdir.
|
||||
*
|
||||
*/
|
||||
struct TempDir {
|
||||
/**
|
||||
* Construct a temporary directory
|
||||
*/
|
||||
TempDir(bool autodelete=true);
|
||||
|
||||
/**
|
||||
* DTOR; removes the temporary directory
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
~TempDir();
|
||||
|
||||
/**
|
||||
* Path to the temporary directory
|
||||
*
|
||||
* @return the path.
|
||||
*
|
||||
*
|
||||
*/
|
||||
const std::string& path() {return path_; }
|
||||
private:
|
||||
std::string path_;
|
||||
const bool autodelete_;
|
||||
};
|
||||
|
||||
} // namespace Mu
|
||||
|
||||
#endif /* __MU_UTILS_HH__ */
|
||||
|
||||
Reference in New Issue
Block a user