diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-05-05 21:52:20 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-07-13 10:57:18 +0200 |
commit | 0ef304e8b8cc517c6a1d8ddccfcaab49172c0535 (patch) | |
tree | ac70fc0fbf66629ec268d81d5f94c5c17d90e2f7 /examples | |
parent | 059fcd2878071616cedb5116a0b2f75b5edbdbe0 (diff) |
add new assertion macros for <, <=, > and >=
Now we support the following new macros:
- CPPUNIT_ASSERT_LESS
- CPPUNIT_ASSERT_GREATER
- CPPUNIT_ASSERT_LESSEQUAL
- CPPUNIT_ASSERT_GREATEREQUAL
Diffstat (limited to 'examples')
-rw-r--r-- | examples/cppunittest/TestAssertTest.cpp | 45 | ||||
-rw-r--r-- | examples/cppunittest/TestAssertTest.h | 8 |
2 files changed, 53 insertions, 0 deletions
diff --git a/examples/cppunittest/TestAssertTest.cpp b/examples/cppunittest/TestAssertTest.cpp index 1a7a5de..1516117 100644 --- a/examples/cppunittest/TestAssertTest.cpp +++ b/examples/cppunittest/TestAssertTest.cpp @@ -141,6 +141,51 @@ TestAssertTest::testAssertEqual() CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_EQUAL( 1, 2 ) ); } + +void +TestAssertTest::testAssertLess() +{ + CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT_LESS( 2, 1 ) ); + CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT_LESS( 12345679, 12345678 ) ); + + CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_LESS( 1, 2 ) ); +} + + +void +TestAssertTest::testAssertGreater() +{ + CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT_GREATER( 1, 2 ) ); + CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT_GREATER( 12345678, 12345679 )); + + CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_GREATER( 2, 1 ) ); + CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_GREATER( 2, 2 ) ); +} + + +void +TestAssertTest::testAssertLessEqual() +{ + CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT_LESSEQUAL( 2, 1 ) ); + CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT_LESSEQUAL( 12345679, 12345678 )); + CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT_LESSEQUAL( 2, 2 ) ); + + CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_LESSEQUAL( 1, 2 ) ); +} + +void +TestAssertTest::testAssertGreaterEqual() +{ + CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT_GREATEREQUAL( 1, 2 ) ); + CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT_GREATEREQUAL( 12345678, 12345679 )); + CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT_GREATEREQUAL( 12345678, 12345678 )); + CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT_GREATEREQUAL( 2, 2 ) ); + + CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_GREATEREQUAL( 2, 1 ) ); +} + + + void TestAssertTest::testAssertMessageTrue() { diff --git a/examples/cppunittest/TestAssertTest.h b/examples/cppunittest/TestAssertTest.h index a672d38..01d303e 100644 --- a/examples/cppunittest/TestAssertTest.h +++ b/examples/cppunittest/TestAssertTest.h @@ -13,6 +13,10 @@ class TestAssertTest : public CPPUNIT_NS::TestFixture CPPUNIT_TEST( testAssertAssertionPass ); CPPUNIT_TEST( testAssert ); CPPUNIT_TEST( testAssertEqual ); + CPPUNIT_TEST( testAssertLess ); + CPPUNIT_TEST( testAssertGreater ); + CPPUNIT_TEST( testAssertLessEqual ); + CPPUNIT_TEST( testAssertGreaterEqual ); CPPUNIT_TEST( testAssertMessageTrue ); CPPUNIT_TEST( testAssertMessageFalse ); CPPUNIT_TEST( testAssertDoubleEquals ); @@ -39,6 +43,10 @@ public: void testAssert(); void testAssertEqual(); + void testAssertLess(); + void testAssertGreater(); + void testAssertLessEqual(); + void testAssertGreaterEqual(); void testAssertMessageTrue(); void testAssertMessageFalse(); |