Merge pull request #2 from dmorrill10/master

Resolved compiler warnings from tests. (Thanks Dustin!)
This commit is contained in:
Mark VanderVoord
2013-08-28 04:45:28 -07:00
2 changed files with 99 additions and 71 deletions
+13 -2
View File
@@ -15,7 +15,7 @@ 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
@@ -24,11 +24,14 @@ void test_BasicTryDoesNothingIfNoThrow(void)
} }
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)
@@ -117,6 +120,8 @@ 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)
@@ -268,6 +273,9 @@ 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)
@@ -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)
+47 -30
View File
@@ -1,10 +1,31 @@
/* 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) \
{ \
Unity.CurrentTestName = #TestFunc; \
Unity.CurrentTestLineNumber = TestLineNum; \
Unity.NumberOfTests++; \
if (TEST_PROTECT()) \
{ \
setUp(); \
TestFunc(); \
} \
if (TEST_PROTECT() && !TEST_IS_IGNORED) \
{ \
tearDown(); \
} \
UnityConcludeTest(); \
}
//=======Automagically Detected Files To Include=====
#include "unity.h"
#include <setjmp.h>
#include <stdio.h>
//=======External Functions This Runner Calls=====
extern void setUp(void); extern void setUp(void);
extern void tearDown(void); extern void tearDown(void);
extern void test_BasicTryDoesNothingIfNoThrow(void); extern void test_BasicTryDoesNothingIfNoThrow(void);
extern void test_BasicThrowAndCatch(void); extern void test_BasicThrowAndCatch(void);
extern void test_BasicThrowAndCatch_WithMiniSyntax(void); extern void test_BasicThrowAndCatch_WithMiniSyntax(void);
@@ -12,46 +33,42 @@ extern void test_VerifyVolatilesSurviveThrowAndCatch(void);
extern void test_ThrowFromASubFunctionAndCatchInRootFunc(void); extern void test_ThrowFromASubFunctionAndCatchInRootFunc(void);
extern void test_ThrowAndCatchFromASubFunctionAndRethrowToCatchInRootFunc(void); extern void test_ThrowAndCatchFromASubFunctionAndRethrowToCatchInRootFunc(void);
extern void test_ThrowAndCatchFromASubFunctionAndNoRethrowToCatchInRootFunc(void); extern void test_ThrowAndCatchFromASubFunctionAndNoRethrowToCatchInRootFunc(void);
extern void test_ThrowAnErrorThenEnterATryBlockFromWithinCatch_VerifyThisDoesntCorruptExceptionId(void);
extern void test_ThrowAnErrorThenEnterATryBlockFromWithinCatch_VerifyThatEachExceptionIdIndependent(void);
extern void test_CanHaveMultipleTryBlocksInASingleFunction(void); extern void test_CanHaveMultipleTryBlocksInASingleFunction(void);
extern void test_CanHaveNestedTryBlocksInASingleFunction_ThrowInside(void); extern void test_CanHaveNestedTryBlocksInASingleFunction_ThrowInside(void);
extern void test_CanHaveNestedTryBlocksInASingleFunction_ThrowOutside(void); extern void test_CanHaveNestedTryBlocksInASingleFunction_ThrowOutside(void);
extern void test_ThrowAnErrorThenEnterATryBlockFromWithinCatch_VerifyThisDoesntCorruptExceptionId(void);
extern void test_ThrowAnErrorThenEnterATryBlockFromWithinCatch_VerifyThatEachExceptionIdIndependent(void);
extern void test_AThrowWithoutATryCatchWillUseDefaultHandlerIfSpecified(void); extern void test_AThrowWithoutATryCatchWillUseDefaultHandlerIfSpecified(void);
extern void test_AThrowWithoutOutsideATryCatchWillUseDefaultHandlerEvenAfterTryCatch(void); extern void test_AThrowWithoutOutsideATryCatchWillUseDefaultHandlerEvenAfterTryCatch(void);
static void runTest(UnityTestFunction test)
//=======Test Reset Option=====
void resetTest()
{ {
if (TEST_PROTECT())
{
test();
}
tearDown(); tearDown();
setUp();
} }
//=======MAIN=====
int main(void) int main(void)
{ {
Unity.TestFile = __FILE__; Unity.TestFile = "test/TestException.c";
UnityBegin(); 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);
// RUN_TEST calls runTest return (UnityEnd());
RUN_TEST(test_BasicTryDoesNothingIfNoThrow, 15);
RUN_TEST(test_BasicThrowAndCatch, 33);
RUN_TEST(test_BasicThrowAndCatch_WithMiniSyntax, 52);
RUN_TEST(test_VerifyVolatilesSurviveThrowAndCatch, 72);
RUN_TEST(test_ThrowFromASubFunctionAndCatchInRootFunc, 101);
RUN_TEST(test_ThrowAndCatchFromASubFunctionAndRethrowToCatchInRootFunc, 142);
RUN_TEST(test_ThrowAndCatchFromASubFunctionAndNoRethrowToCatchInRootFunc, 161);
RUN_TEST(test_ThrowAnErrorThenEnterATryBlockFromWithinCatch_VerifyThisDoesntCorruptExceptionId, 178);
RUN_TEST(test_ThrowAnErrorThenEnterATryBlockFromWithinCatch_VerifyThatEachExceptionIdIndependent, 196);
RUN_TEST(test_CanHaveMultipleTryBlocksInASingleFunction, 223);
RUN_TEST(test_CanHaveNestedTryBlocksInASingleFunction_ThrowInside, 248);
RUN_TEST(test_CanHaveNestedTryBlocksInASingleFunction_ThrowOutside, 272);
RUN_TEST(test_AThrowWithoutATryCatchWillUseDefaultHandlerIfSpecified, 296);
RUN_TEST(test_AThrowWithoutOutsideATryCatchWillUseDefaultHandlerEvenAfterTryCatch, 308);
UnityEnd();
return 0;
} }