Change example_1 to compile with std=c89

This commit is contained in:
Andrzej Bieniek
2015-09-09 21:13:33 +01:00
parent 61dd3f181b
commit 83f7d5237b
7 changed files with 36 additions and 36 deletions

View File

@ -2,14 +2,14 @@
#include "ProductionCode.h"
#include "unity.h"
//sometimes you may want to get at local data in a module.
//for example: If you plan to pass by reference, this could be useful
//however, it should often be avoided
/* sometimes you may want to get at local data in a module.
* for example: If you plan to pass by reference, this could be useful
* however, it should often be avoided */
extern int Counter;
void setUp(void)
{
//This is run before EACH TEST
/* This is run before EACH TEST */
Counter = 0x5a5a;
}
@ -19,7 +19,7 @@ void tearDown(void)
void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode(void)
{
//All of these should pass
/* All of these should pass */
TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(78));
TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(1));
TEST_ASSERT_EQUAL(0, FindFunction_WhichIsBroken(33));
@ -29,34 +29,34 @@ void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWork
void test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken(void)
{
// You should see this line fail in your test summary
/* You should see this line fail in your test summary */
TEST_ASSERT_EQUAL(1, FindFunction_WhichIsBroken(34));
// Notice the rest of these didn't get a chance to run because the line above failed.
// Unit tests abort each test function on the first sign of trouble.
// Then NEXT test function runs as normal.
/* Notice the rest of these didn't get a chance to run because the line above failed.
* Unit tests abort each test function on the first sign of trouble.
* Then NEXT test function runs as normal. */
TEST_ASSERT_EQUAL(8, FindFunction_WhichIsBroken(8888));
}
void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue(void)
{
//This should be true because setUp set this up for us before this test
/* This should be true because setUp set this up for us before this test */
TEST_ASSERT_EQUAL_HEX(0x5a5a, FunctionWhichReturnsLocalVariable());
//This should be true because we can still change our answer
/* This should be true because we can still change our answer */
Counter = 0x1234;
TEST_ASSERT_EQUAL_HEX(0x1234, FunctionWhichReturnsLocalVariable());
}
void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain(void)
{
//This should be true again because setup was rerun before this test (and after we changed it to 0x1234)
/* This should be true again because setup was rerun before this test (and after we changed it to 0x1234) */
TEST_ASSERT_EQUAL_HEX(0x5a5a, FunctionWhichReturnsLocalVariable());
}
void test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed(void)
{
//Sometimes you get the test wrong. When that happens, you get a failure too... and a quick look should tell
// you what actually happened...which in this case was a failure to setup the initial condition.
/* Sometimes you get the test wrong. When that happens, you get a failure too... and a quick look should tell
* you what actually happened...which in this case was a failure to setup the initial condition. */
TEST_ASSERT_EQUAL_HEX(0x1234, FunctionWhichReturnsLocalVariable());
}