summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-12-13 10:54:01 +0100
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2016-12-13 10:58:43 +0100
commit435dee2d69a47c8d46aa1aab3d2906bfc8eab74e (patch)
tree093f947dd8a9c48bee612ed290ec920701e1adcc /examples
parent98f0a738d2925c41b268388ce6defe86114f611a (diff)
add support for enum class to the asserter
The asserter now has special handling to convert the enum class to a std::string. This does not work without some template magic as enum class has no implicit conversion to int.
Diffstat (limited to 'examples')
-rw-r--r--examples/cppunittest/TestAssertTest.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/examples/cppunittest/TestAssertTest.cpp b/examples/cppunittest/TestAssertTest.cpp
index 1516117..8a19957 100644
--- a/examples/cppunittest/TestAssertTest.cpp
+++ b/examples/cppunittest/TestAssertTest.cpp
@@ -13,6 +13,12 @@
an exception.
*/
+enum class EnumClass
+{
+ VALUE1,
+ VALUE2
+};
+
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TestAssertTest,
coreSuiteName() );
@@ -137,8 +143,10 @@ TestAssertTest::testAssertEqual()
CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT_EQUAL( 1, 1 ) );
CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT_EQUAL( 1, foo() ) );
CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT_EQUAL( 12345678, 12345678 ) );
+ CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT_EQUAL( EnumClass::VALUE1, EnumClass::VALUE1 ) );
CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_EQUAL( 1, 2 ) );
+ CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_EQUAL( EnumClass::VALUE1, EnumClass::VALUE2 ) );
}