Skip to content

Commit

Permalink
Add CppUTest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Hill (Wireless) committed Sep 18, 2020
1 parent 8563380 commit fad7007
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/CppUTest/UtestTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,42 @@ TEST(UtestShell, ExitLeavesQuietly)
LONGS_EQUAL(0, fixture.getFailureCount());
}

static bool cpputestHasCrashed;

static void crashMethod()
{
cpputestHasCrashed = true;
}

TEST(UtestShell, FailWillNotCrashIfNotEnabled)
{
cpputestHasCrashed = false;
UtestShell::setCrashMethod(crashMethod);

fixture.setTestFunction(_failMethod);
fixture.runAllTests();

CHECK_FALSE(cpputestHasCrashed);

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

TEST(UtestShell, FailWillCrashIfEnabled)
{
cpputestHasCrashed = false;
UtestShell::setCrashOnFail();
UtestShell::setCrashMethod(crashMethod);

fixture.setTestFunction(_failMethod);
fixture.runAllTests();

CHECK(cpputestHasCrashed);

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



static int teardownCalled = 0;
Expand Down

0 comments on commit fad7007

Please sign in to comment.