mirror of
https://github.com/throwtheswitch/cexception.git
synced 2026-08-26 04:59:58 +00:00
Merge pull request #2 from dmorrill10/master
Resolved compiler warnings from tests. (Thanks Dustin!)
This commit is contained in:
+25
-14
@@ -15,20 +15,23 @@ void tearDown(void)
|
|||||||
|
|
||||||
void test_BasicTryDoesNothingIfNoThrow(void)
|
void test_BasicTryDoesNothingIfNoThrow(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i = 0;
|
||||||
CEXCEPTION_T e = 0x5a;
|
CEXCEPTION_T e = 0x5a;
|
||||||
|
|
||||||
Try
|
Try
|
||||||
{
|
{
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
Catch(e)
|
Catch(e)
|
||||||
{
|
{
|
||||||
TEST_FAIL_MESSAGE("Should Not Enter Catch If Not Thrown")
|
TEST_FAIL_MESSAGE("Should Not Enter Catch If Not Thrown");
|
||||||
}
|
}
|
||||||
|
|
||||||
//verify that e was untouched
|
//verify that e was untouched
|
||||||
TEST_ASSERT_EQUAL(0x5a, e);
|
TEST_ASSERT_EQUAL(0x5a, e);
|
||||||
|
|
||||||
|
// verify that i was incremented once
|
||||||
|
TEST_ASSERT_EQUAL(1, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_BasicThrowAndCatch(void)
|
void test_BasicThrowAndCatch(void)
|
||||||
@@ -60,7 +63,7 @@ void test_BasicThrowAndCatch_WithMiniSyntax(void)
|
|||||||
Catch(e)
|
Catch(e)
|
||||||
TEST_ASSERT_EQUAL(0xEF, e);
|
TEST_ASSERT_EQUAL(0xEF, e);
|
||||||
TEST_ASSERT_EQUAL(0xEF, e);
|
TEST_ASSERT_EQUAL(0xEF, e);
|
||||||
|
|
||||||
//Mini Passthrough
|
//Mini Passthrough
|
||||||
Try
|
Try
|
||||||
e = 0;
|
e = 0;
|
||||||
@@ -117,12 +120,14 @@ void test_ThrowFromASubFunctionAndCatchInRootFunc(void)
|
|||||||
|
|
||||||
//verify that I can pass that value to something else
|
//verify that I can pass that value to something else
|
||||||
TEST_ASSERT_EQUAL(0xBA, e);
|
TEST_ASSERT_EQUAL(0xBA, e);
|
||||||
|
//verify that ID and e have the same value
|
||||||
|
TEST_ASSERT_EQUAL(ID, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HappyExceptionRethrower(unsigned int ID)
|
void HappyExceptionRethrower(unsigned int ID)
|
||||||
{
|
{
|
||||||
CEXCEPTION_T e;
|
CEXCEPTION_T e;
|
||||||
|
|
||||||
Try
|
Try
|
||||||
{
|
{
|
||||||
Throw(ID);
|
Throw(ID);
|
||||||
@@ -144,7 +149,7 @@ void test_ThrowAndCatchFromASubFunctionAndRethrowToCatchInRootFunc(void)
|
|||||||
{
|
{
|
||||||
volatile unsigned int ID = 0;
|
volatile unsigned int ID = 0;
|
||||||
CEXCEPTION_T e;
|
CEXCEPTION_T e;
|
||||||
|
|
||||||
Try
|
Try
|
||||||
{
|
{
|
||||||
HappyExceptionRethrower(0xBD);
|
HappyExceptionRethrower(0xBD);
|
||||||
@@ -162,7 +167,7 @@ void test_ThrowAndCatchFromASubFunctionAndRethrowToCatchInRootFunc(void)
|
|||||||
void test_ThrowAndCatchFromASubFunctionAndNoRethrowToCatchInRootFunc(void)
|
void test_ThrowAndCatchFromASubFunctionAndNoRethrowToCatchInRootFunc(void)
|
||||||
{
|
{
|
||||||
CEXCEPTION_T e = 3;
|
CEXCEPTION_T e = 3;
|
||||||
|
|
||||||
Try
|
Try
|
||||||
{
|
{
|
||||||
HappyExceptionRethrower(0xBF);
|
HappyExceptionRethrower(0xBF);
|
||||||
@@ -171,7 +176,7 @@ void test_ThrowAndCatchFromASubFunctionAndNoRethrowToCatchInRootFunc(void)
|
|||||||
{
|
{
|
||||||
TEST_FAIL_MESSAGE("Should Not Have Re-thrown Error (it should have already been caught)");
|
TEST_FAIL_MESSAGE("Should Not Have Re-thrown Error (it should have already been caught)");
|
||||||
}
|
}
|
||||||
|
|
||||||
//verify that THIS e is still untouched, even though subfunction was touched
|
//verify that THIS e is still untouched, even though subfunction was touched
|
||||||
TEST_ASSERT_EQUAL(3, e);
|
TEST_ASSERT_EQUAL(3, e);
|
||||||
}
|
}
|
||||||
@@ -179,7 +184,7 @@ void test_ThrowAndCatchFromASubFunctionAndNoRethrowToCatchInRootFunc(void)
|
|||||||
void test_ThrowAnErrorThenEnterATryBlockFromWithinCatch_VerifyThisDoesntCorruptExceptionId(void)
|
void test_ThrowAnErrorThenEnterATryBlockFromWithinCatch_VerifyThisDoesntCorruptExceptionId(void)
|
||||||
{
|
{
|
||||||
CEXCEPTION_T e;
|
CEXCEPTION_T e;
|
||||||
|
|
||||||
Try
|
Try
|
||||||
{
|
{
|
||||||
HappyExceptionThrower(0xBF);
|
HappyExceptionThrower(0xBF);
|
||||||
@@ -197,7 +202,7 @@ void test_ThrowAnErrorThenEnterATryBlockFromWithinCatch_VerifyThisDoesntCorruptE
|
|||||||
void test_ThrowAnErrorThenEnterATryBlockFromWithinCatch_VerifyThatEachExceptionIdIndependent(void)
|
void test_ThrowAnErrorThenEnterATryBlockFromWithinCatch_VerifyThatEachExceptionIdIndependent(void)
|
||||||
{
|
{
|
||||||
CEXCEPTION_T e1, e2;
|
CEXCEPTION_T e1, e2;
|
||||||
|
|
||||||
Try
|
Try
|
||||||
{
|
{
|
||||||
HappyExceptionThrower(0xBF);
|
HappyExceptionThrower(0xBF);
|
||||||
@@ -224,7 +229,7 @@ void test_ThrowAnErrorThenEnterATryBlockFromWithinCatch_VerifyThatEachExceptionI
|
|||||||
void test_CanHaveMultipleTryBlocksInASingleFunction(void)
|
void test_CanHaveMultipleTryBlocksInASingleFunction(void)
|
||||||
{
|
{
|
||||||
CEXCEPTION_T e;
|
CEXCEPTION_T e;
|
||||||
|
|
||||||
Try
|
Try
|
||||||
{
|
{
|
||||||
HappyExceptionThrower(0x01);
|
HappyExceptionThrower(0x01);
|
||||||
@@ -250,7 +255,7 @@ void test_CanHaveNestedTryBlocksInASingleFunction_ThrowInside(void)
|
|||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
CEXCEPTION_T e;
|
CEXCEPTION_T e;
|
||||||
|
|
||||||
Try
|
Try
|
||||||
{
|
{
|
||||||
Try
|
Try
|
||||||
@@ -268,13 +273,16 @@ void test_CanHaveNestedTryBlocksInASingleFunction_ThrowInside(void)
|
|||||||
{
|
{
|
||||||
TEST_FAIL_MESSAGE("Should Have Been Caught By Inside Catch");
|
TEST_FAIL_MESSAGE("Should Have Been Caught By Inside Catch");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// verify that i is still zero
|
||||||
|
TEST_ASSERT_EQUAL(0, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_CanHaveNestedTryBlocksInASingleFunction_ThrowOutside(void)
|
void test_CanHaveNestedTryBlocksInASingleFunction_ThrowOutside(void)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
CEXCEPTION_T e;
|
CEXCEPTION_T e;
|
||||||
|
|
||||||
Try
|
Try
|
||||||
{
|
{
|
||||||
Try
|
Try
|
||||||
@@ -292,6 +300,9 @@ void test_CanHaveNestedTryBlocksInASingleFunction_ThrowOutside(void)
|
|||||||
{
|
{
|
||||||
TEST_ASSERT_EQUAL(0x01, e);
|
TEST_ASSERT_EQUAL(0x01, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// verify that i is 2
|
||||||
|
TEST_ASSERT_EQUAL(2, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_AThrowWithoutATryCatchWillUseDefaultHandlerIfSpecified(void)
|
void test_AThrowWithoutATryCatchWillUseDefaultHandlerIfSpecified(void)
|
||||||
|
|||||||
+74
-57
@@ -1,57 +1,74 @@
|
|||||||
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
/* AUTOGENERATED FILE. DO NOT EDIT. */
|
||||||
#include "unity.h"
|
|
||||||
#include "CException.h"
|
//=======Test Runner Used To Run Each Test Below=====
|
||||||
|
#define RUN_TEST(TestFunc, TestLineNum) \
|
||||||
extern void setUp(void);
|
{ \
|
||||||
extern void tearDown(void);
|
Unity.CurrentTestName = #TestFunc; \
|
||||||
|
Unity.CurrentTestLineNumber = TestLineNum; \
|
||||||
extern void test_BasicTryDoesNothingIfNoThrow(void);
|
Unity.NumberOfTests++; \
|
||||||
extern void test_BasicThrowAndCatch(void);
|
if (TEST_PROTECT()) \
|
||||||
extern void test_BasicThrowAndCatch_WithMiniSyntax(void);
|
{ \
|
||||||
extern void test_VerifyVolatilesSurviveThrowAndCatch(void);
|
setUp(); \
|
||||||
extern void test_ThrowFromASubFunctionAndCatchInRootFunc(void);
|
TestFunc(); \
|
||||||
extern void test_ThrowAndCatchFromASubFunctionAndRethrowToCatchInRootFunc(void);
|
} \
|
||||||
extern void test_ThrowAndCatchFromASubFunctionAndNoRethrowToCatchInRootFunc(void);
|
if (TEST_PROTECT() && !TEST_IS_IGNORED) \
|
||||||
extern void test_CanHaveMultipleTryBlocksInASingleFunction(void);
|
{ \
|
||||||
extern void test_CanHaveNestedTryBlocksInASingleFunction_ThrowInside(void);
|
tearDown(); \
|
||||||
extern void test_CanHaveNestedTryBlocksInASingleFunction_ThrowOutside(void);
|
} \
|
||||||
extern void test_ThrowAnErrorThenEnterATryBlockFromWithinCatch_VerifyThisDoesntCorruptExceptionId(void);
|
UnityConcludeTest(); \
|
||||||
extern void test_ThrowAnErrorThenEnterATryBlockFromWithinCatch_VerifyThatEachExceptionIdIndependent(void);
|
}
|
||||||
extern void test_AThrowWithoutATryCatchWillUseDefaultHandlerIfSpecified(void);
|
|
||||||
extern void test_AThrowWithoutOutsideATryCatchWillUseDefaultHandlerEvenAfterTryCatch(void);
|
//=======Automagically Detected Files To Include=====
|
||||||
|
#include "unity.h"
|
||||||
static void runTest(UnityTestFunction test)
|
#include <setjmp.h>
|
||||||
{
|
#include <stdio.h>
|
||||||
if (TEST_PROTECT())
|
|
||||||
{
|
//=======External Functions This Runner Calls=====
|
||||||
test();
|
extern void setUp(void);
|
||||||
}
|
extern void tearDown(void);
|
||||||
tearDown();
|
extern void test_BasicTryDoesNothingIfNoThrow(void);
|
||||||
}
|
extern void test_BasicThrowAndCatch(void);
|
||||||
|
extern void test_BasicThrowAndCatch_WithMiniSyntax(void);
|
||||||
|
extern void test_VerifyVolatilesSurviveThrowAndCatch(void);
|
||||||
int main(void)
|
extern void test_ThrowFromASubFunctionAndCatchInRootFunc(void);
|
||||||
{
|
extern void test_ThrowAndCatchFromASubFunctionAndRethrowToCatchInRootFunc(void);
|
||||||
Unity.TestFile = __FILE__;
|
extern void test_ThrowAndCatchFromASubFunctionAndNoRethrowToCatchInRootFunc(void);
|
||||||
UnityBegin();
|
extern void test_ThrowAnErrorThenEnterATryBlockFromWithinCatch_VerifyThisDoesntCorruptExceptionId(void);
|
||||||
|
extern void test_ThrowAnErrorThenEnterATryBlockFromWithinCatch_VerifyThatEachExceptionIdIndependent(void);
|
||||||
// RUN_TEST calls runTest
|
extern void test_CanHaveMultipleTryBlocksInASingleFunction(void);
|
||||||
RUN_TEST(test_BasicTryDoesNothingIfNoThrow, 15);
|
extern void test_CanHaveNestedTryBlocksInASingleFunction_ThrowInside(void);
|
||||||
RUN_TEST(test_BasicThrowAndCatch, 33);
|
extern void test_CanHaveNestedTryBlocksInASingleFunction_ThrowOutside(void);
|
||||||
RUN_TEST(test_BasicThrowAndCatch_WithMiniSyntax, 52);
|
extern void test_AThrowWithoutATryCatchWillUseDefaultHandlerIfSpecified(void);
|
||||||
RUN_TEST(test_VerifyVolatilesSurviveThrowAndCatch, 72);
|
extern void test_AThrowWithoutOutsideATryCatchWillUseDefaultHandlerEvenAfterTryCatch(void);
|
||||||
RUN_TEST(test_ThrowFromASubFunctionAndCatchInRootFunc, 101);
|
|
||||||
RUN_TEST(test_ThrowAndCatchFromASubFunctionAndRethrowToCatchInRootFunc, 142);
|
|
||||||
RUN_TEST(test_ThrowAndCatchFromASubFunctionAndNoRethrowToCatchInRootFunc, 161);
|
//=======Test Reset Option=====
|
||||||
RUN_TEST(test_ThrowAnErrorThenEnterATryBlockFromWithinCatch_VerifyThisDoesntCorruptExceptionId, 178);
|
void resetTest()
|
||||||
RUN_TEST(test_ThrowAnErrorThenEnterATryBlockFromWithinCatch_VerifyThatEachExceptionIdIndependent, 196);
|
{
|
||||||
RUN_TEST(test_CanHaveMultipleTryBlocksInASingleFunction, 223);
|
tearDown();
|
||||||
RUN_TEST(test_CanHaveNestedTryBlocksInASingleFunction_ThrowInside, 248);
|
setUp();
|
||||||
RUN_TEST(test_CanHaveNestedTryBlocksInASingleFunction_ThrowOutside, 272);
|
}
|
||||||
RUN_TEST(test_AThrowWithoutATryCatchWillUseDefaultHandlerIfSpecified, 296);
|
|
||||||
RUN_TEST(test_AThrowWithoutOutsideATryCatchWillUseDefaultHandlerEvenAfterTryCatch, 308);
|
|
||||||
|
//=======MAIN=====
|
||||||
UnityEnd();
|
int main(void)
|
||||||
|
{
|
||||||
return 0;
|
Unity.TestFile = "test/TestException.c";
|
||||||
}
|
UnityBegin();
|
||||||
|
RUN_TEST(test_BasicTryDoesNothingIfNoThrow, 16);
|
||||||
|
RUN_TEST(test_BasicThrowAndCatch, 37);
|
||||||
|
RUN_TEST(test_BasicThrowAndCatch_WithMiniSyntax, 56);
|
||||||
|
RUN_TEST(test_VerifyVolatilesSurviveThrowAndCatch, 76);
|
||||||
|
RUN_TEST(test_ThrowFromASubFunctionAndCatchInRootFunc, 105);
|
||||||
|
RUN_TEST(test_ThrowAndCatchFromASubFunctionAndRethrowToCatchInRootFunc, 148);
|
||||||
|
RUN_TEST(test_ThrowAndCatchFromASubFunctionAndNoRethrowToCatchInRootFunc, 167);
|
||||||
|
RUN_TEST(test_ThrowAnErrorThenEnterATryBlockFromWithinCatch_VerifyThisDoesntCorruptExceptionId, 184);
|
||||||
|
RUN_TEST(test_ThrowAnErrorThenEnterATryBlockFromWithinCatch_VerifyThatEachExceptionIdIndependent, 202);
|
||||||
|
RUN_TEST(test_CanHaveMultipleTryBlocksInASingleFunction, 229);
|
||||||
|
RUN_TEST(test_CanHaveNestedTryBlocksInASingleFunction_ThrowInside, 254);
|
||||||
|
RUN_TEST(test_CanHaveNestedTryBlocksInASingleFunction_ThrowOutside, 281);
|
||||||
|
RUN_TEST(test_AThrowWithoutATryCatchWillUseDefaultHandlerIfSpecified, 308);
|
||||||
|
RUN_TEST(test_AThrowWithoutOutsideATryCatchWillUseDefaultHandlerEvenAfterTryCatch, 319);
|
||||||
|
|
||||||
|
return (UnityEnd());
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user