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
+25 -14
View File
@@ -15,20 +15,23 @@ void tearDown(void)
void test_BasicTryDoesNothingIfNoThrow(void)
{
int i;
int i = 0;
CEXCEPTION_T e = 0x5a;
Try
{
i += 1;
}
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
TEST_ASSERT_EQUAL(0x5a, e);
// verify that i was incremented once
TEST_ASSERT_EQUAL(1, i);
}
void test_BasicThrowAndCatch(void)
@@ -60,7 +63,7 @@ void test_BasicThrowAndCatch_WithMiniSyntax(void)
Catch(e)
TEST_ASSERT_EQUAL(0xEF, e);
TEST_ASSERT_EQUAL(0xEF, e);
//Mini Passthrough
Try
e = 0;
@@ -117,12 +120,14 @@ void test_ThrowFromASubFunctionAndCatchInRootFunc(void)
//verify that I can pass that value to something else
TEST_ASSERT_EQUAL(0xBA, e);
//verify that ID and e have the same value
TEST_ASSERT_EQUAL(ID, e);
}
void HappyExceptionRethrower(unsigned int ID)
{
CEXCEPTION_T e;
Try
{
Throw(ID);
@@ -144,7 +149,7 @@ void test_ThrowAndCatchFromASubFunctionAndRethrowToCatchInRootFunc(void)
{
volatile unsigned int ID = 0;
CEXCEPTION_T e;
Try
{
HappyExceptionRethrower(0xBD);
@@ -162,7 +167,7 @@ void test_ThrowAndCatchFromASubFunctionAndRethrowToCatchInRootFunc(void)
void test_ThrowAndCatchFromASubFunctionAndNoRethrowToCatchInRootFunc(void)
{
CEXCEPTION_T e = 3;
Try
{
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)");
}
//verify that THIS e is still untouched, even though subfunction was touched
TEST_ASSERT_EQUAL(3, e);
}
@@ -179,7 +184,7 @@ void test_ThrowAndCatchFromASubFunctionAndNoRethrowToCatchInRootFunc(void)
void test_ThrowAnErrorThenEnterATryBlockFromWithinCatch_VerifyThisDoesntCorruptExceptionId(void)
{
CEXCEPTION_T e;
Try
{
HappyExceptionThrower(0xBF);
@@ -197,7 +202,7 @@ void test_ThrowAnErrorThenEnterATryBlockFromWithinCatch_VerifyThisDoesntCorruptE
void test_ThrowAnErrorThenEnterATryBlockFromWithinCatch_VerifyThatEachExceptionIdIndependent(void)
{
CEXCEPTION_T e1, e2;
Try
{
HappyExceptionThrower(0xBF);
@@ -224,7 +229,7 @@ void test_ThrowAnErrorThenEnterATryBlockFromWithinCatch_VerifyThatEachExceptionI
void test_CanHaveMultipleTryBlocksInASingleFunction(void)
{
CEXCEPTION_T e;
Try
{
HappyExceptionThrower(0x01);
@@ -250,7 +255,7 @@ void test_CanHaveNestedTryBlocksInASingleFunction_ThrowInside(void)
{
int i = 0;
CEXCEPTION_T e;
Try
{
Try
@@ -268,13 +273,16 @@ void test_CanHaveNestedTryBlocksInASingleFunction_ThrowInside(void)
{
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)
{
int i = 0;
CEXCEPTION_T e;
Try
{
Try
@@ -292,6 +300,9 @@ void test_CanHaveNestedTryBlocksInASingleFunction_ThrowOutside(void)
{
TEST_ASSERT_EQUAL(0x01, e);
}
// verify that i is 2
TEST_ASSERT_EQUAL(2, i);
}
void test_AThrowWithoutATryCatchWillUseDefaultHandlerIfSpecified(void)
+74 -57
View File
@@ -1,57 +1,74 @@
/* AUTOGENERATED FILE. DO NOT EDIT. */
#include "unity.h"
#include "CException.h"
extern void setUp(void);
extern void tearDown(void);
extern void test_BasicTryDoesNothingIfNoThrow(void);
extern void test_BasicThrowAndCatch(void);
extern void test_BasicThrowAndCatch_WithMiniSyntax(void);
extern void test_VerifyVolatilesSurviveThrowAndCatch(void);
extern void test_ThrowFromASubFunctionAndCatchInRootFunc(void);
extern void test_ThrowAndCatchFromASubFunctionAndRethrowToCatchInRootFunc(void);
extern void test_ThrowAndCatchFromASubFunctionAndNoRethrowToCatchInRootFunc(void);
extern void test_CanHaveMultipleTryBlocksInASingleFunction(void);
extern void test_CanHaveNestedTryBlocksInASingleFunction_ThrowInside(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_AThrowWithoutOutsideATryCatchWillUseDefaultHandlerEvenAfterTryCatch(void);
static void runTest(UnityTestFunction test)
{
if (TEST_PROTECT())
{
test();
}
tearDown();
}
int main(void)
{
Unity.TestFile = __FILE__;
UnityBegin();
// RUN_TEST calls runTest
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;
}
/* AUTOGENERATED FILE. DO NOT EDIT. */
//=======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 tearDown(void);
extern void test_BasicTryDoesNothingIfNoThrow(void);
extern void test_BasicThrowAndCatch(void);
extern void test_BasicThrowAndCatch_WithMiniSyntax(void);
extern void test_VerifyVolatilesSurviveThrowAndCatch(void);
extern void test_ThrowFromASubFunctionAndCatchInRootFunc(void);
extern void test_ThrowAndCatchFromASubFunctionAndRethrowToCatchInRootFunc(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_CanHaveNestedTryBlocksInASingleFunction_ThrowInside(void);
extern void test_CanHaveNestedTryBlocksInASingleFunction_ThrowOutside(void);
extern void test_AThrowWithoutATryCatchWillUseDefaultHandlerIfSpecified(void);
extern void test_AThrowWithoutOutsideATryCatchWillUseDefaultHandlerEvenAfterTryCatch(void);
//=======Test Reset Option=====
void resetTest()
{
tearDown();
setUp();
}
//=======MAIN=====
int main(void)
{
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());
}