1
0
mirror of https://github.com/ThrowTheSwitch/Unity.git synced 2026-01-26 01:41:35 +01:00

Added stricter error checks by the compiler, and adapted all impacted code.

Primarily -
* Added "static" to static functions.
* Added proper signature with "void" to functions without arguments.
* Marked unused arguments with "(void)".
* Removed entirely unused static functions.
* Added "const" to preserve const-correctness.
* Added function prototypes for external functions.
This commit is contained in:
nimrodz
2015-01-18 00:32:47 +02:00
parent af40e7901d
commit b389c71e71
20 changed files with 130 additions and 87 deletions

View File

@@ -17,10 +17,12 @@ int (*outputChar)(int) = putchar;
int verbose = 0;
void setUp(void);
void tearDown(void);
void setUp(void) { /*does nothing*/ }
void tearDown(void) { /*does nothing*/ }
void announceTestRun(unsigned int runNumber)
static void announceTestRun(unsigned int runNumber)
{
UnityPrint("Unity test run ");
UnityPrintNumber(runNumber+1);
@@ -29,7 +31,7 @@ void announceTestRun(unsigned int runNumber)
UNITY_OUTPUT_CHAR('\n');
}
int UnityMain(int argc, char* argv[], void (*runAllTests)(void))
int UnityMain(int argc, const char* argv[], void (*runAllTests)(void))
{
int result = UnityGetCommandLineOptions(argc, argv);
unsigned int r;
@@ -65,7 +67,7 @@ static int groupSelected(const char* group)
return selected(UnityFixture.GroupFilter, group);
}
static void runTestCase()
static void runTestCase(void)
{
}
@@ -132,13 +134,13 @@ void UnityIgnoreTest(const char * printableName)
static int malloc_count;
static int malloc_fail_countdown = MALLOC_DONT_FAIL;
void UnityMalloc_StartTest()
void UnityMalloc_StartTest(void)
{
malloc_count = 0;
malloc_fail_countdown = MALLOC_DONT_FAIL;
}
void UnityMalloc_EndTest()
void UnityMalloc_EndTest(void)
{
malloc_fail_countdown = MALLOC_DONT_FAIL;
if (malloc_count != 0)
@@ -274,7 +276,7 @@ enum {MAX_POINTERS=50};
static PointerPair pointer_store[MAX_POINTERS];
static int pointer_index = 0;
void UnityPointer_Init()
void UnityPointer_Init(void)
{
pointer_index = 0;
}
@@ -290,7 +292,7 @@ void UnityPointer_Set(void ** pointer, void * newValue)
pointer_index++;
}
void UnityPointer_UndoAllSets()
void UnityPointer_UndoAllSets(void)
{
while (pointer_index > 0)
{
@@ -301,12 +303,12 @@ void UnityPointer_UndoAllSets()
}
}
int UnityFailureCount()
int UnityFailureCount(void)
{
return Unity.TestFailures;
}
int UnityGetCommandLineOptions(int argc, char* argv[])
int UnityGetCommandLineOptions(int argc, const char* argv[])
{
int i;
UnityFixture.Verbose = 0;
@@ -360,7 +362,7 @@ int UnityGetCommandLineOptions(int argc, char* argv[])
return 0;
}
void UnityConcludeFixtureTest()
void UnityConcludeFixtureTest(void)
{
if (Unity.CurrentTestIgnored)
{

View File

@@ -13,19 +13,22 @@
#include "unity_fixture_malloc_overrides.h"
#include "unity_fixture_internals.h"
int UnityMain(int argc, char* argv[], void (*runAllTests)(void));
int UnityMain(int argc, const char* argv[], void (*runAllTests)(void));
#define TEST_GROUP(group)\
static const char* TEST_GROUP_##group = #group
#define TEST_SETUP(group) void TEST_##group##_SETUP(void)
#define TEST_SETUP(group) void TEST_##group##_SETUP(void);\
void TEST_##group##_SETUP(void)
#define TEST_TEAR_DOWN(group) void TEST_##group##_TEAR_DOWN(void)
#define TEST_TEAR_DOWN(group) void TEST_##group##_TEAR_DOWN(void);\
void TEST_##group##_TEAR_DOWN(void)
#define TEST(group, name) \
void TEST_##group##_##name##_(void);\
void TEST_##group##_##name##_run(void);\
void TEST_##group##_##name##_run(void)\
{\
UnityTestRunner(TEST_##group##_SETUP,\
@@ -39,6 +42,7 @@ int UnityMain(int argc, char* argv[], void (*runAllTests)(void));
#define IGNORE_TEST(group, name) \
void TEST_##group##_##name##_(void);\
void TEST_##group##_##name##_run(void);\
void TEST_##group##_##name##_run(void)\
{\
UnityIgnoreTest("IGNORE_TEST(" #group ", " #name ")");\
@@ -60,7 +64,7 @@ int UnityMain(int argc, char* argv[], void (*runAllTests)(void));
{\
TEST_##group##_GROUP_RUNNER_runAll();\
}\
void TEST_##group##_GROUP_RUNNER_runAll()
void TEST_##group##_GROUP_RUNNER_runAll(void)
//Call this from main
#define RUN_TEST_GROUP(group)\

View File

@@ -29,7 +29,7 @@ void UnityIgnoreTest(const char * printableName);
void UnityMalloc_StartTest(void);
void UnityMalloc_EndTest(void);
int UnityFailureCount(void);
int UnityGetCommandLineOptions(int argc, char* argv[]);
int UnityGetCommandLineOptions(int argc, const char* argv[]);
void UnityConcludeFixtureTest(void);
void UnityPointer_Set(void ** ptr, void * newValue);

View File

@@ -13,4 +13,9 @@
#define realloc unity_realloc
#define free unity_free
void* unity_malloc(size_t size);
void* unity_calloc(size_t num, size_t size);
void* unity_realloc(void * oldMem, size_t size);
void unity_free(void * mem);
#endif /* UNITY_FIXTURE_MALLOC_OVERRIDES_H_ */