From 435dee2d69a47c8d46aa1aab3d2906bfc8eab74e Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Tue, 13 Dec 2016 10:54:01 +0100 Subject: 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. --- examples/cppunittest/TestAssertTest.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'examples/cppunittest/TestAssertTest.cpp') 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 ) ); } -- cgit v1.2.1