* Added fallback handler for Throws that happen when no Try..Catch has been specified.

git-svn-id: http://cexception.svn.sourceforge.net/svnroot/cexception/trunk@18 50f63946-2846-0410-8d77-f904c773002e
This commit is contained in:
mvandervoord
2012-02-20 12:39:01 +00:00
parent 0571b990b6
commit 7de3228016
6 changed files with 95 additions and 26 deletions
+37
View File
@@ -1,8 +1,12 @@
#include "unity.h"
#include "CException.h"
volatile int TestingTheFallback;
void setUp(void)
{
CExceptionFrames[0].pFrame = NULL;
TestingTheFallback = 0;
}
void tearDown(void)
@@ -289,3 +293,36 @@ void test_CanHaveNestedTryBlocksInASingleFunction_ThrowOutside(void)
TEST_ASSERT_EQUAL(0x01, e);
}
}
void test_AThrowWithoutATryCatchWillUseDefaultHandlerIfSpecified(void)
{
//Let the fallback handler know we're expecting it to get called this time, so don't fail
TestingTheFallback = 1;
Throw(0xBE);
//We know the fallback was run because it decrements the counter above
TEST_ASSERT_FALSE(TestingTheFallback);
}
void test_AThrowWithoutOutsideATryCatchWillUseDefaultHandlerEvenAfterTryCatch(void)
{
CEXCEPTION_T e;
Try
{
//It's not really important that we do anything here.
}
Catch(e)
{
//The entire purpose here is just to make sure things get set back to using the default handler when done
}
//Let the fallback handler know we're expecting it to get called this time, so don't fail
TestingTheFallback = 1;
Throw(0xBE);
//We know the fallback was run because it decrements the counter above
TEST_ASSERT_FALSE(TestingTheFallback);
}