From 728dfd06eb82d063b6b7df82de94405e5b98a869 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Thu, 6 Jan 2022 14:24:07 +0100 Subject: [PATCH] Remove user(doc) visible change to zero_plus_zero_is_zero_with_action Tests via Fixture::teardown that the assertion is fulfilled --- doc/example/getting_started.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/example/getting_started.cpp b/doc/example/getting_started.cpp index 328cf8e..4cf11fe 100644 --- a/doc/example/getting_started.cpp +++ b/doc/example/getting_started.cpp @@ -149,6 +149,7 @@ BOOST_AUTO_TEST_CASE( add_several_numbers_in_sequences ) } //] } +BOOST_AUTO_TEST_SUITE_END() namespace action { @@ -174,7 +175,7 @@ public: void add( int a, int b ){ v.display(a + b); } }; -struct CatchFailureFixture +struct CatchFailureFixture: Fixture { static bool aborted; static std::string fail_msg; @@ -200,14 +201,20 @@ struct CatchFailureFixture bool CatchFailureFixture::aborted = false; std::string CatchFailureFixture::fail_msg; +struct AssertMissingAction: CatchFailureFixture{ + void teardown(){ + assert_failure("missing action"); + } +}; + +BOOST_FIXTURE_TEST_SUITE( MissingReturnActionSuite, AssertMissingAction) //[ action_test -BOOST_FIXTURE_TEST_CASE( zero_plus_zero_is_zero_with_action, CatchFailureFixture ) +BOOST_AUTO_TEST_CASE( zero_plus_zero_is_zero_with_action ) { mock_view v; calculator c( v ); MOCK_EXPECT( v.display ).once().with( 0 ); // missing returns( true ) c.add( 0, 0 ); - assert_failure("missing action"); } //] }