Skip to content

Commit

Permalink
Split setCrashOnFail into set/reset
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Hill (Wireless) committed Sep 17, 2020
1 parent 68215f4 commit 8563380
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
3 changes: 2 additions & 1 deletion include/CppUTest/Utest.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ class UtestShell

static const TestTerminator &getCurrentTestTerminator();

static void setCrashOnFail(bool crashOnFail = true);
static void setCrashOnFail();
static void resetFailBehaviour();

public:
UtestShell(const char* groupName, const char* testName, const char* fileName, size_t lineNumber);
Expand Down
15 changes: 8 additions & 7 deletions src/CppUTest/Utest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ extern "C" {

}

/************************************************************************** */
/* Define the two possible TestTerminators that can be selected at run time */
/******************************** */

static const NormalTestTerminator normalTestTerminator;
static const CrashingTestTerminator crashingTestTerminator;
Expand Down Expand Up @@ -588,12 +587,14 @@ const TestTerminator &UtestShell::getCurrentTestTerminator()
return *currentTestTerminator_;
}

void UtestShell::setCrashOnFail(bool crashOnFail)
void UtestShell::setCrashOnFail()
{
if (crashOnFail)
currentTestTerminator_ = &crashingTestTerminator;
else
currentTestTerminator_ = &normalTestTerminator;
currentTestTerminator_ = &crashingTestTerminator;
}

void UtestShell::resetFailBehaviour()
{
currentTestTerminator_ = &normalTestTerminator;
}

ExecFunctionTestShell::~ExecFunctionTestShell()
Expand Down
2 changes: 1 addition & 1 deletion tests/CppUTestExt/MockSupportTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ TEST(MockSupportTestWithFixture, shouldCrashOnFailureWithCppUTestSetting)

CHECK(cpputestHasCrashed);

UtestShell::setCrashOnFail(false);
UtestShell::resetFailBehaviour();
UtestShell::resetCrashMethod();
}

Expand Down

0 comments on commit 8563380

Please sign in to comment.