mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-06-20 05:50:29 +08:00
Merge pull request #95 from trianglee/master
Make Unity's compilation flags stricter
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,2 +1,7 @@
|
|||||||
build/
|
build/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
examples/example_1/test1.out
|
||||||
|
examples/example_1/test2.out
|
||||||
|
examples/example_2/all_tests.out
|
||||||
|
examples/example_3/test1.out
|
||||||
|
examples/example_3/test2.out
|
||||||
|
@ -21,7 +21,26 @@ endif
|
|||||||
|
|
||||||
UNITY_ROOT=../..
|
UNITY_ROOT=../..
|
||||||
C_COMPILER=gcc
|
C_COMPILER=gcc
|
||||||
|
|
||||||
CFLAGS=-std=c99
|
CFLAGS=-std=c99
|
||||||
|
CFLAGS += -Wall
|
||||||
|
CFLAGS += -Wextra
|
||||||
|
CFLAGS += -Werror
|
||||||
|
CFLAGS += -Wpointer-arith
|
||||||
|
CFLAGS += -Wcast-align
|
||||||
|
CFLAGS += -Wwrite-strings
|
||||||
|
CFLAGS += -Wswitch-default
|
||||||
|
CFLAGS += -Wunreachable-code
|
||||||
|
CFLAGS += -Winit-self
|
||||||
|
CFLAGS += -Wlogical-op
|
||||||
|
CFLAGS += -Wmissing-field-initializers
|
||||||
|
CFLAGS += -Wno-unknown-pragmas
|
||||||
|
CFLAGS += -Wjump-misses-init
|
||||||
|
CFLAGS += -Wstrict-prototypes
|
||||||
|
CFLAGS += -Wundef
|
||||||
|
CFLAGS += -Wunsafe-loop-optimizations
|
||||||
|
CFLAGS += -Wold-style-definition
|
||||||
|
|
||||||
TARGET_BASE1=test1
|
TARGET_BASE1=test1
|
||||||
TARGET_BASE2=test2
|
TARGET_BASE2=test2
|
||||||
TARGET1 = $(TARGET_BASE1)$(TARGET_EXTENSION)
|
TARGET1 = $(TARGET_BASE1)$(TARGET_EXTENSION)
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction)
|
char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction)
|
||||||
{
|
{
|
||||||
|
(void)Poor;
|
||||||
|
(void)LittleFunction;
|
||||||
//Since There Are No Tests Yet, This Function Could Be Empty For All We Know.
|
//Since There Are No Tests Yet, This Function Could Be Empty For All We Know.
|
||||||
// Which isn't terribly useful... but at least we put in a TEST_IGNORE so we won't forget
|
// Which isn't terribly useful... but at least we put in a TEST_IGNORE so we won't forget
|
||||||
return (char*)0;
|
return (char*)0;
|
||||||
|
@ -12,18 +12,6 @@ extern void test_IgnoredTest(void);
|
|||||||
extern void test_AnotherIgnoredTest(void);
|
extern void test_AnotherIgnoredTest(void);
|
||||||
extern void test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented(void);
|
extern void test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented(void);
|
||||||
|
|
||||||
static void runTest(UnityTestFunction test)
|
|
||||||
{
|
|
||||||
if (TEST_PROTECT())
|
|
||||||
{
|
|
||||||
setUp();
|
|
||||||
test();
|
|
||||||
}
|
|
||||||
if (TEST_PROTECT() && !TEST_IS_IGNORED)
|
|
||||||
{
|
|
||||||
tearDown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void resetTest(void);
|
void resetTest(void);
|
||||||
void resetTest(void)
|
void resetTest(void)
|
||||||
{
|
{
|
||||||
@ -36,7 +24,6 @@ int main(void)
|
|||||||
{
|
{
|
||||||
UnityBegin("test/TestProductionCode2.c");
|
UnityBegin("test/TestProductionCode2.c");
|
||||||
|
|
||||||
// RUN_TEST calls runTest
|
|
||||||
RUN_TEST(test_IgnoredTest, 13);
|
RUN_TEST(test_IgnoredTest, 13);
|
||||||
RUN_TEST(test_AnotherIgnoredTest, 18);
|
RUN_TEST(test_AnotherIgnoredTest, 18);
|
||||||
RUN_TEST(test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented, 23);
|
RUN_TEST(test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented, 23);
|
||||||
|
@ -14,18 +14,6 @@ extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounter
|
|||||||
extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain(void);
|
extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain(void);
|
||||||
extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed(void);
|
extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed(void);
|
||||||
|
|
||||||
static void runTest(UnityTestFunction test)
|
|
||||||
{
|
|
||||||
if (TEST_PROTECT())
|
|
||||||
{
|
|
||||||
setUp();
|
|
||||||
test();
|
|
||||||
}
|
|
||||||
if (TEST_PROTECT() && !TEST_IS_IGNORED)
|
|
||||||
{
|
|
||||||
tearDown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void resetTest(void);
|
void resetTest(void);
|
||||||
void resetTest(void)
|
void resetTest(void)
|
||||||
{
|
{
|
||||||
@ -38,7 +26,6 @@ int main(void)
|
|||||||
{
|
{
|
||||||
UnityBegin("test/TestProductionCode.c");
|
UnityBegin("test/TestProductionCode.c");
|
||||||
|
|
||||||
// RUN_TEST calls runTest
|
|
||||||
RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode, 20);
|
RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode, 20);
|
||||||
RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken, 30);
|
RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken, 30);
|
||||||
RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue, 41);
|
RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue, 41);
|
||||||
|
@ -21,6 +21,28 @@ endif
|
|||||||
|
|
||||||
UNITY_ROOT=../..
|
UNITY_ROOT=../..
|
||||||
C_COMPILER=gcc
|
C_COMPILER=gcc
|
||||||
|
|
||||||
|
CFLAGS = -std=c99
|
||||||
|
CFLAGS += -Wall
|
||||||
|
CFLAGS += -Wextra
|
||||||
|
CFLAGS += -Werror
|
||||||
|
CFLAGS += -Wpointer-arith
|
||||||
|
CFLAGS += -Wcast-align
|
||||||
|
CFLAGS += -Wwrite-strings
|
||||||
|
CFLAGS += -Wswitch-default
|
||||||
|
CFLAGS += -Wunreachable-code
|
||||||
|
CFLAGS += -Winit-self
|
||||||
|
CFLAGS += -Wlogical-op
|
||||||
|
CFLAGS += -Wmissing-field-initializers
|
||||||
|
CFLAGS += -Wno-unknown-pragmas
|
||||||
|
CFLAGS += -Wjump-misses-init
|
||||||
|
CFLAGS += -Wstrict-prototypes
|
||||||
|
CFLAGS += -Wundef
|
||||||
|
CFLAGS += -Wunsafe-loop-optimizations
|
||||||
|
CFLAGS += -Wold-style-definition
|
||||||
|
CFLAGS += -Wmissing-prototypes
|
||||||
|
CFLAGS += -Wmissing-declarations
|
||||||
|
|
||||||
TARGET_BASE1=all_tests
|
TARGET_BASE1=all_tests
|
||||||
TARGET1 = $(TARGET_BASE1)$(TARGET_EXTENSION)
|
TARGET1 = $(TARGET_BASE1)$(TARGET_EXTENSION)
|
||||||
SRC_FILES1=\
|
SRC_FILES1=\
|
||||||
@ -41,7 +63,7 @@ all: clean default
|
|||||||
default:
|
default:
|
||||||
# ruby auto/generate_test_runner.rb test/TestProductionCode.c test/test_runners/TestProductionCode_Runner.c
|
# ruby auto/generate_test_runner.rb test/TestProductionCode.c test/test_runners/TestProductionCode_Runner.c
|
||||||
# ruby auto/generate_test_runner.rb test/TestProductionCode2.c test/test_runners/TestProductionCode2_Runner.c
|
# ruby auto/generate_test_runner.rb test/TestProductionCode2.c test/test_runners/TestProductionCode2_Runner.c
|
||||||
$(C_COMPILER) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES1) -o $(TARGET1)
|
$(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES1) -o $(TARGET1)
|
||||||
./$(TARGET1)
|
./$(TARGET1)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction)
|
char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction)
|
||||||
{
|
{
|
||||||
|
(void)Poor;
|
||||||
|
(void)LittleFunction;
|
||||||
//Since There Are No Tests Yet, This Function Could Be Empty For All We Know.
|
//Since There Are No Tests Yet, This Function Could Be Empty For All We Know.
|
||||||
// Which isn't terribly useful... but at least we put in a TEST_IGNORE so we won't forget
|
// Which isn't terribly useful... but at least we put in a TEST_IGNORE so we won't forget
|
||||||
return (char*)0;
|
return (char*)0;
|
||||||
|
@ -21,7 +21,26 @@ endif
|
|||||||
|
|
||||||
UNITY_ROOT=../..
|
UNITY_ROOT=../..
|
||||||
C_COMPILER=gcc
|
C_COMPILER=gcc
|
||||||
|
|
||||||
CFLAGS=-std=c99
|
CFLAGS=-std=c99
|
||||||
|
CFLAGS += -Wall
|
||||||
|
CFLAGS += -Wextra
|
||||||
|
CFLAGS += -Werror
|
||||||
|
CFLAGS += -Wpointer-arith
|
||||||
|
CFLAGS += -Wcast-align
|
||||||
|
CFLAGS += -Wwrite-strings
|
||||||
|
CFLAGS += -Wswitch-default
|
||||||
|
CFLAGS += -Wunreachable-code
|
||||||
|
CFLAGS += -Winit-self
|
||||||
|
CFLAGS += -Wlogical-op
|
||||||
|
CFLAGS += -Wmissing-field-initializers
|
||||||
|
CFLAGS += -Wno-unknown-pragmas
|
||||||
|
CFLAGS += -Wjump-misses-init
|
||||||
|
CFLAGS += -Wstrict-prototypes
|
||||||
|
CFLAGS += -Wundef
|
||||||
|
CFLAGS += -Wunsafe-loop-optimizations
|
||||||
|
CFLAGS += -Wold-style-definition
|
||||||
|
|
||||||
TARGET_BASE1=test1
|
TARGET_BASE1=test1
|
||||||
TARGET_BASE2=test2
|
TARGET_BASE2=test2
|
||||||
TARGET1 = $(TARGET_BASE1)$(TARGET_EXTENSION)
|
TARGET1 = $(TARGET_BASE1)$(TARGET_EXTENSION)
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction)
|
char* ThisFunctionHasNotBeenTested(int Poor, char* LittleFunction)
|
||||||
{
|
{
|
||||||
|
(void)Poor;
|
||||||
|
(void)LittleFunction;
|
||||||
//Since There Are No Tests Yet, This Function Could Be Empty For All We Know.
|
//Since There Are No Tests Yet, This Function Could Be Empty For All We Know.
|
||||||
// Which isn't terribly useful... but at least we put in a TEST_IGNORE so we won't forget
|
// Which isn't terribly useful... but at least we put in a TEST_IGNORE so we won't forget
|
||||||
return (char*)0;
|
return (char*)0;
|
||||||
|
@ -12,18 +12,6 @@ extern void test_IgnoredTest(void);
|
|||||||
extern void test_AnotherIgnoredTest(void);
|
extern void test_AnotherIgnoredTest(void);
|
||||||
extern void test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented(void);
|
extern void test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented(void);
|
||||||
|
|
||||||
static void runTest(UnityTestFunction test)
|
|
||||||
{
|
|
||||||
if (TEST_PROTECT())
|
|
||||||
{
|
|
||||||
setUp();
|
|
||||||
test();
|
|
||||||
}
|
|
||||||
if (TEST_PROTECT() && !TEST_IS_IGNORED)
|
|
||||||
{
|
|
||||||
tearDown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void resetTest(void);
|
void resetTest(void);
|
||||||
void resetTest(void)
|
void resetTest(void)
|
||||||
{
|
{
|
||||||
@ -36,7 +24,6 @@ int main(void)
|
|||||||
{
|
{
|
||||||
UnityBegin("test/TestProductionCode2.c");
|
UnityBegin("test/TestProductionCode2.c");
|
||||||
|
|
||||||
// RUN_TEST calls runTest
|
|
||||||
RUN_TEST(test_IgnoredTest, 13);
|
RUN_TEST(test_IgnoredTest, 13);
|
||||||
RUN_TEST(test_AnotherIgnoredTest, 18);
|
RUN_TEST(test_AnotherIgnoredTest, 18);
|
||||||
RUN_TEST(test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented, 23);
|
RUN_TEST(test_ThisFunctionHasNotBeenTested_NeedsToBeImplemented, 23);
|
||||||
|
@ -14,18 +14,6 @@ extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounter
|
|||||||
extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain(void);
|
extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain(void);
|
||||||
extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed(void);
|
extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed(void);
|
||||||
|
|
||||||
static void runTest(UnityTestFunction test)
|
|
||||||
{
|
|
||||||
if (TEST_PROTECT())
|
|
||||||
{
|
|
||||||
setUp();
|
|
||||||
test();
|
|
||||||
}
|
|
||||||
if (TEST_PROTECT() && !TEST_IS_IGNORED)
|
|
||||||
{
|
|
||||||
tearDown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void resetTest(void);
|
void resetTest(void);
|
||||||
void resetTest(void)
|
void resetTest(void)
|
||||||
{
|
{
|
||||||
@ -38,7 +26,6 @@ int main(void)
|
|||||||
{
|
{
|
||||||
UnityBegin("test/TestProductionCode.c");
|
UnityBegin("test/TestProductionCode.c");
|
||||||
|
|
||||||
// RUN_TEST calls runTest
|
|
||||||
RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode, 20);
|
RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode, 20);
|
||||||
RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken, 30);
|
RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken, 30);
|
||||||
RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue, 41);
|
RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue, 41);
|
||||||
|
@ -17,10 +17,12 @@ int (*outputChar)(int) = putchar;
|
|||||||
|
|
||||||
int verbose = 0;
|
int verbose = 0;
|
||||||
|
|
||||||
|
void setUp(void);
|
||||||
|
void tearDown(void);
|
||||||
void setUp(void) { /*does nothing*/ }
|
void setUp(void) { /*does nothing*/ }
|
||||||
void tearDown(void) { /*does nothing*/ }
|
void tearDown(void) { /*does nothing*/ }
|
||||||
|
|
||||||
void announceTestRun(unsigned int runNumber)
|
static void announceTestRun(unsigned int runNumber)
|
||||||
{
|
{
|
||||||
UnityPrint("Unity test run ");
|
UnityPrint("Unity test run ");
|
||||||
UnityPrintNumber(runNumber+1);
|
UnityPrintNumber(runNumber+1);
|
||||||
@ -29,7 +31,7 @@ void announceTestRun(unsigned int runNumber)
|
|||||||
UNITY_OUTPUT_CHAR('\n');
|
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);
|
int result = UnityGetCommandLineOptions(argc, argv);
|
||||||
unsigned int r;
|
unsigned int r;
|
||||||
@ -65,7 +67,7 @@ static int groupSelected(const char* group)
|
|||||||
return selected(UnityFixture.GroupFilter, 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_count;
|
||||||
static int malloc_fail_countdown = MALLOC_DONT_FAIL;
|
static int malloc_fail_countdown = MALLOC_DONT_FAIL;
|
||||||
|
|
||||||
void UnityMalloc_StartTest()
|
void UnityMalloc_StartTest(void)
|
||||||
{
|
{
|
||||||
malloc_count = 0;
|
malloc_count = 0;
|
||||||
malloc_fail_countdown = MALLOC_DONT_FAIL;
|
malloc_fail_countdown = MALLOC_DONT_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnityMalloc_EndTest()
|
void UnityMalloc_EndTest(void)
|
||||||
{
|
{
|
||||||
malloc_fail_countdown = MALLOC_DONT_FAIL;
|
malloc_fail_countdown = MALLOC_DONT_FAIL;
|
||||||
if (malloc_count != 0)
|
if (malloc_count != 0)
|
||||||
@ -274,7 +276,7 @@ enum {MAX_POINTERS=50};
|
|||||||
static PointerPair pointer_store[MAX_POINTERS];
|
static PointerPair pointer_store[MAX_POINTERS];
|
||||||
static int pointer_index = 0;
|
static int pointer_index = 0;
|
||||||
|
|
||||||
void UnityPointer_Init()
|
void UnityPointer_Init(void)
|
||||||
{
|
{
|
||||||
pointer_index = 0;
|
pointer_index = 0;
|
||||||
}
|
}
|
||||||
@ -290,7 +292,7 @@ void UnityPointer_Set(void ** pointer, void * newValue)
|
|||||||
pointer_index++;
|
pointer_index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnityPointer_UndoAllSets()
|
void UnityPointer_UndoAllSets(void)
|
||||||
{
|
{
|
||||||
while (pointer_index > 0)
|
while (pointer_index > 0)
|
||||||
{
|
{
|
||||||
@ -301,12 +303,12 @@ void UnityPointer_UndoAllSets()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int UnityFailureCount()
|
int UnityFailureCount(void)
|
||||||
{
|
{
|
||||||
return Unity.TestFailures;
|
return Unity.TestFailures;
|
||||||
}
|
}
|
||||||
|
|
||||||
int UnityGetCommandLineOptions(int argc, char* argv[])
|
int UnityGetCommandLineOptions(int argc, const char* argv[])
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
UnityFixture.Verbose = 0;
|
UnityFixture.Verbose = 0;
|
||||||
@ -360,7 +362,7 @@ int UnityGetCommandLineOptions(int argc, char* argv[])
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnityConcludeFixtureTest()
|
void UnityConcludeFixtureTest(void)
|
||||||
{
|
{
|
||||||
if (Unity.CurrentTestIgnored)
|
if (Unity.CurrentTestIgnored)
|
||||||
{
|
{
|
||||||
|
@ -13,19 +13,22 @@
|
|||||||
#include "unity_fixture_malloc_overrides.h"
|
#include "unity_fixture_malloc_overrides.h"
|
||||||
#include "unity_fixture_internals.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)\
|
#define TEST_GROUP(group)\
|
||||||
static const char* TEST_GROUP_##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) \
|
#define TEST(group, name) \
|
||||||
void TEST_##group##_##name##_(void);\
|
void TEST_##group##_##name##_(void);\
|
||||||
|
void TEST_##group##_##name##_run(void);\
|
||||||
void TEST_##group##_##name##_run(void)\
|
void TEST_##group##_##name##_run(void)\
|
||||||
{\
|
{\
|
||||||
UnityTestRunner(TEST_##group##_SETUP,\
|
UnityTestRunner(TEST_##group##_SETUP,\
|
||||||
@ -39,6 +42,7 @@ int UnityMain(int argc, char* argv[], void (*runAllTests)(void));
|
|||||||
|
|
||||||
#define IGNORE_TEST(group, name) \
|
#define IGNORE_TEST(group, name) \
|
||||||
void TEST_##group##_##name##_(void);\
|
void TEST_##group##_##name##_(void);\
|
||||||
|
void TEST_##group##_##name##_run(void);\
|
||||||
void TEST_##group##_##name##_run(void)\
|
void TEST_##group##_##name##_run(void)\
|
||||||
{\
|
{\
|
||||||
UnityIgnoreTest("IGNORE_TEST(" #group ", " #name ")");\
|
UnityIgnoreTest("IGNORE_TEST(" #group ", " #name ")");\
|
||||||
@ -60,7 +64,7 @@ int UnityMain(int argc, char* argv[], void (*runAllTests)(void));
|
|||||||
{\
|
{\
|
||||||
TEST_##group##_GROUP_RUNNER_runAll();\
|
TEST_##group##_GROUP_RUNNER_runAll();\
|
||||||
}\
|
}\
|
||||||
void TEST_##group##_GROUP_RUNNER_runAll()
|
void TEST_##group##_GROUP_RUNNER_runAll(void)
|
||||||
|
|
||||||
//Call this from main
|
//Call this from main
|
||||||
#define RUN_TEST_GROUP(group)\
|
#define RUN_TEST_GROUP(group)\
|
||||||
|
@ -29,7 +29,7 @@ void UnityIgnoreTest(const char * printableName);
|
|||||||
void UnityMalloc_StartTest(void);
|
void UnityMalloc_StartTest(void);
|
||||||
void UnityMalloc_EndTest(void);
|
void UnityMalloc_EndTest(void);
|
||||||
int UnityFailureCount(void);
|
int UnityFailureCount(void);
|
||||||
int UnityGetCommandLineOptions(int argc, char* argv[]);
|
int UnityGetCommandLineOptions(int argc, const char* argv[]);
|
||||||
void UnityConcludeFixtureTest(void);
|
void UnityConcludeFixtureTest(void);
|
||||||
|
|
||||||
void UnityPointer_Set(void ** ptr, void * newValue);
|
void UnityPointer_Set(void ** ptr, void * newValue);
|
||||||
|
@ -13,4 +13,9 @@
|
|||||||
#define realloc unity_realloc
|
#define realloc unity_realloc
|
||||||
#define free unity_free
|
#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_ */
|
#endif /* UNITY_FIXTURE_MALLOC_OVERRIDES_H_ */
|
||||||
|
@ -7,14 +7,14 @@
|
|||||||
|
|
||||||
#include "unity_fixture.h"
|
#include "unity_fixture.h"
|
||||||
|
|
||||||
static void runAllTests()
|
static void runAllTests(void)
|
||||||
{
|
{
|
||||||
RUN_TEST_GROUP(UnityFixture);
|
RUN_TEST_GROUP(UnityFixture);
|
||||||
RUN_TEST_GROUP(UnityCommandOptions);
|
RUN_TEST_GROUP(UnityCommandOptions);
|
||||||
RUN_TEST_GROUP(LeakDetection)
|
RUN_TEST_GROUP(LeakDetection)
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, const char* argv[])
|
||||||
{
|
{
|
||||||
return UnityMain(argc, argv, runAllTests);
|
return UnityMain(argc, argv, runAllTests);
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ TEST_TEAR_DOWN(UnityCommandOptions)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char* noOptions[] = {
|
static const char* noOptions[] = {
|
||||||
"testrunner.exe"
|
"testrunner.exe"
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -171,7 +171,7 @@ TEST(UnityCommandOptions, DefaultOptions)
|
|||||||
TEST_ASSERT_EQUAL(1, UnityFixture.RepeatCount);
|
TEST_ASSERT_EQUAL(1, UnityFixture.RepeatCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char* verbose[] = {
|
static const char* verbose[] = {
|
||||||
"testrunner.exe",
|
"testrunner.exe",
|
||||||
"-v"
|
"-v"
|
||||||
};
|
};
|
||||||
@ -182,7 +182,7 @@ TEST(UnityCommandOptions, OptionVerbose)
|
|||||||
TEST_ASSERT_EQUAL(1, UnityFixture.Verbose);
|
TEST_ASSERT_EQUAL(1, UnityFixture.Verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char* group[] = {
|
static const char* group[] = {
|
||||||
"testrunner.exe",
|
"testrunner.exe",
|
||||||
"-g", "groupname"
|
"-g", "groupname"
|
||||||
};
|
};
|
||||||
@ -193,7 +193,7 @@ TEST(UnityCommandOptions, OptionSelectTestByGroup)
|
|||||||
STRCMP_EQUAL("groupname", UnityFixture.GroupFilter);
|
STRCMP_EQUAL("groupname", UnityFixture.GroupFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char* name[] = {
|
static const char* name[] = {
|
||||||
"testrunner.exe",
|
"testrunner.exe",
|
||||||
"-n", "testname"
|
"-n", "testname"
|
||||||
};
|
};
|
||||||
@ -204,7 +204,7 @@ TEST(UnityCommandOptions, OptionSelectTestByName)
|
|||||||
STRCMP_EQUAL("testname", UnityFixture.NameFilter);
|
STRCMP_EQUAL("testname", UnityFixture.NameFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char* repeat[] = {
|
static const char* repeat[] = {
|
||||||
"testrunner.exe",
|
"testrunner.exe",
|
||||||
"-r", "99"
|
"-r", "99"
|
||||||
};
|
};
|
||||||
@ -221,7 +221,7 @@ TEST(UnityCommandOptions, OptionSelectRepeatTestsSpecificCount)
|
|||||||
TEST_ASSERT_EQUAL(99, UnityFixture.RepeatCount);
|
TEST_ASSERT_EQUAL(99, UnityFixture.RepeatCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char* multiple[] = {
|
static const char* multiple[] = {
|
||||||
"testrunner.exe",
|
"testrunner.exe",
|
||||||
"-v",
|
"-v",
|
||||||
"-g", "groupname",
|
"-g", "groupname",
|
||||||
@ -238,7 +238,7 @@ TEST(UnityCommandOptions, MultipleOptions)
|
|||||||
TEST_ASSERT_EQUAL(98, UnityFixture.RepeatCount);
|
TEST_ASSERT_EQUAL(98, UnityFixture.RepeatCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char* dashRNotLast[] = {
|
static const char* dashRNotLast[] = {
|
||||||
"testrunner.exe",
|
"testrunner.exe",
|
||||||
"-v",
|
"-v",
|
||||||
"-g", "gggg",
|
"-g", "gggg",
|
||||||
@ -255,7 +255,7 @@ TEST(UnityCommandOptions, MultipleOptionsDashRNotLastAndNoValueSpecified)
|
|||||||
TEST_ASSERT_EQUAL(2, UnityFixture.RepeatCount);
|
TEST_ASSERT_EQUAL(2, UnityFixture.RepeatCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char* unknownCommand[] = {
|
static const char* unknownCommand[] = {
|
||||||
"testrunner.exe",
|
"testrunner.exe",
|
||||||
"-v",
|
"-v",
|
||||||
"-g", "groupname",
|
"-g", "groupname",
|
||||||
|
@ -25,7 +25,7 @@ void UnityOutputCharSpy_Create(int s)
|
|||||||
memset(buffer, 0, size);
|
memset(buffer, 0, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnityOutputCharSpy_Destroy()
|
void UnityOutputCharSpy_Destroy(void)
|
||||||
{
|
{
|
||||||
size = 0;
|
size = 0;
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@ -45,7 +45,7 @@ int UnityOutputCharSpy_OutputChar(int c)
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * UnityOutputCharSpy_Get()
|
const char * UnityOutputCharSpy_Get(void)
|
||||||
{
|
{
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,9 @@
|
|||||||
#define D_unity_output_Spy_H
|
#define D_unity_output_Spy_H
|
||||||
|
|
||||||
void UnityOutputCharSpy_Create(int s);
|
void UnityOutputCharSpy_Create(int s);
|
||||||
void UnityOutputCharSpy_Destroy();
|
void UnityOutputCharSpy_Destroy(void);
|
||||||
int UnityOutputCharSpy_OutputChar(int c);
|
int UnityOutputCharSpy_OutputChar(int c);
|
||||||
const char * UnityOutputCharSpy_Get();
|
const char * UnityOutputCharSpy_Get(void);
|
||||||
void UnityOutputCharSpy_Enable(int enable);
|
void UnityOutputCharSpy_Enable(int enable);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
12
src/unity.c
12
src/unity.c
@ -271,7 +271,7 @@ void UnityPrintOk(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------
|
//-----------------------------------------------
|
||||||
void UnityTestResultsBegin(const char* file, const UNITY_LINE_TYPE line)
|
static void UnityTestResultsBegin(const char* file, const UNITY_LINE_TYPE line)
|
||||||
{
|
{
|
||||||
UnityPrint(file);
|
UnityPrint(file);
|
||||||
UNITY_OUTPUT_CHAR(':');
|
UNITY_OUTPUT_CHAR(':');
|
||||||
@ -282,7 +282,7 @@ void UnityTestResultsBegin(const char* file, const UNITY_LINE_TYPE line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------
|
//-----------------------------------------------
|
||||||
void UnityTestResultsFailBegin(const UNITY_LINE_TYPE line)
|
static void UnityTestResultsFailBegin(const UNITY_LINE_TYPE line)
|
||||||
{
|
{
|
||||||
UnityTestResultsBegin(Unity.TestFile, line);
|
UnityTestResultsBegin(Unity.TestFile, line);
|
||||||
UnityPrint(UnityStrFail);
|
UnityPrint(UnityStrFail);
|
||||||
@ -312,7 +312,7 @@ void UnityConcludeTest(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------
|
//-----------------------------------------------
|
||||||
void UnityAddMsgIfSpecified(const char* msg)
|
static void UnityAddMsgIfSpecified(const char* msg)
|
||||||
{
|
{
|
||||||
if (msg)
|
if (msg)
|
||||||
{
|
{
|
||||||
@ -322,7 +322,7 @@ void UnityAddMsgIfSpecified(const char* msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------
|
//-----------------------------------------------
|
||||||
void UnityPrintExpectedAndActualStrings(const char* expected, const char* actual)
|
static void UnityPrintExpectedAndActualStrings(const char* expected, const char* actual)
|
||||||
{
|
{
|
||||||
UnityPrint(UnityStrExpected);
|
UnityPrint(UnityStrExpected);
|
||||||
if (expected != NULL)
|
if (expected != NULL)
|
||||||
@ -352,7 +352,7 @@ void UnityPrintExpectedAndActualStrings(const char* expected, const char* actual
|
|||||||
// Assertion & Control Helpers
|
// Assertion & Control Helpers
|
||||||
//-----------------------------------------------
|
//-----------------------------------------------
|
||||||
|
|
||||||
int UnityCheckArraysForNull(UNITY_PTR_ATTRIBUTE const void* expected, UNITY_PTR_ATTRIBUTE const void* actual, const UNITY_LINE_TYPE lineNumber, const char* msg)
|
static int UnityCheckArraysForNull(UNITY_PTR_ATTRIBUTE const void* expected, UNITY_PTR_ATTRIBUTE const void* actual, const UNITY_LINE_TYPE lineNumber, const char* msg)
|
||||||
{
|
{
|
||||||
//return true if they are both NULL
|
//return true if they are both NULL
|
||||||
if ((expected == NULL) && (actual == NULL))
|
if ((expected == NULL) && (actual == NULL))
|
||||||
@ -1102,6 +1102,8 @@ void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line)
|
|||||||
|
|
||||||
//-----------------------------------------------
|
//-----------------------------------------------
|
||||||
#if defined(UNITY_WEAK_ATTRIBUTE)
|
#if defined(UNITY_WEAK_ATTRIBUTE)
|
||||||
|
void setUp(void);
|
||||||
|
void tearDown(void);
|
||||||
UNITY_WEAK_ATTRIBUTE void setUp(void) { }
|
UNITY_WEAK_ATTRIBUTE void setUp(void) { }
|
||||||
UNITY_WEAK_ATTRIBUTE void tearDown(void) { }
|
UNITY_WEAK_ATTRIBUTE void tearDown(void) { }
|
||||||
#elif defined(UNITY_WEAK_PRAGMA)
|
#elif defined(UNITY_WEAK_PRAGMA)
|
||||||
|
@ -10,6 +10,22 @@ compiler:
|
|||||||
- '-Wno-address'
|
- '-Wno-address'
|
||||||
- '-std=c99'
|
- '-std=c99'
|
||||||
- '-pedantic'
|
- '-pedantic'
|
||||||
|
- '-Wextra'
|
||||||
|
- '-Werror'
|
||||||
|
- '-Wpointer-arith'
|
||||||
|
- '-Wcast-align'
|
||||||
|
- '-Wwrite-strings'
|
||||||
|
- '-Wswitch-default'
|
||||||
|
- '-Wunreachable-code'
|
||||||
|
- '-Winit-self'
|
||||||
|
- '-Wlogical-op'
|
||||||
|
- '-Wmissing-field-initializers'
|
||||||
|
- '-Wno-unknown-pragmas'
|
||||||
|
- '-Wjump-misses-init'
|
||||||
|
- '-Wstrict-prototypes'
|
||||||
|
- '-Wundef'
|
||||||
|
- '-Wunsafe-loop-optimizations'
|
||||||
|
- '-Wold-style-definition'
|
||||||
includes:
|
includes:
|
||||||
prefix: '-I'
|
prefix: '-I'
|
||||||
items:
|
items:
|
||||||
|
Reference in New Issue
Block a user