@@ -68,8 +68,8 @@ class TestFixture : public ErrorLogger {
6868
6969 bool assert_ (const char * const filename, const unsigned int linenr, const bool condition) const ;
7070
71- template <typename T, typename U >
72- bool assertEquals (const char * const filename, const unsigned int linenr, const T& expected, const U & actual, const std::string& msg = emptyString) const {
71+ template <typename T>
72+ bool assertEquals (const char * const filename, const unsigned int linenr, const T& expected, const T & actual, const std::string& msg = emptyString) const {
7373 if (expected != actual) {
7474 std::ostringstream expectedStr;
7575 expectedStr << expected;
@@ -81,6 +81,13 @@ class TestFixture : public ErrorLogger {
8181 return expected == actual;
8282 }
8383
84+ template <typename T>
85+ bool assertEqualsEnum (const char * const filename, const unsigned int linenr, const T& expected, const T& actual, const std::string& msg = emptyString) const {
86+ if (std::is_unsigned<T>())
87+ return assertEquals (filename, linenr, static_cast <std::uint64_t >(expected), static_cast <std::uint64_t >(actual), msg);
88+ return assertEquals (filename, linenr, static_cast <std::int64_t >(expected), static_cast <std::int64_t >(actual), msg);
89+ }
90+
8491 // Helper function to be called when an assertEquals assertion fails.
8592 // Writes the appropriate failure message to errmsg and increments fails_counter
8693 void assertEqualsFailed (const char * const filename, const unsigned int linenr, const std::string& expected, const std::string& actual, const std::string& msg) const ;
@@ -271,6 +278,7 @@ class TestFixture : public ErrorLogger {
271278#define ASSERT_EQUALS_WITHOUT_LINENUMBERS ( EXPECTED, ACTUAL ) assertEqualsWithoutLineNumbers(__FILE__, __LINE__, EXPECTED, ACTUAL)
272279#define ASSERT_EQUALS_DOUBLE ( EXPECTED, ACTUAL, TOLERANCE ) assertEqualsDouble(__FILE__, __LINE__, EXPECTED, ACTUAL, TOLERANCE)
273280#define ASSERT_EQUALS_MSG ( EXPECTED, ACTUAL, MSG ) assertEquals(__FILE__, __LINE__, EXPECTED, ACTUAL, MSG)
281+ #define ASSERT_EQUALS_ENUM ( EXPECTED, ACTUAL ) if (!assertEqualsEnum(__FILE__, __LINE__, (EXPECTED), (ACTUAL))) return
274282#define ASSERT_THROW ( CMD, EXCEPTION ) do { try { CMD; assertThrowFail (__FILE__, __LINE__); } catch (const EXCEPTION&) {} catch (...) { assertThrowFail (__FILE__, __LINE__); } } while (false )
275283#define ASSERT_THROW_EQUALS ( CMD, EXCEPTION, EXPECTED ) do { try { CMD; assertThrowFail (__FILE__, __LINE__); } catch (const EXCEPTION&e) { assertEquals (__FILE__, __LINE__, EXPECTED, e.errorMessage ); } catch (...) { assertThrowFail (__FILE__, __LINE__); } } while (false )
276284#define ASSERT_THROW_EQUALS_2 ( CMD, EXCEPTION, EXPECTED ) do { try { CMD; assertThrowFail (__FILE__, __LINE__); } catch (const EXCEPTION&e) { assertEquals (__FILE__, __LINE__, EXPECTED, e.what ()); } catch (...) { assertThrowFail (__FILE__, __LINE__); } } while (false )
0 commit comments