mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-06-25 01:59:21 +08:00
Fixture C99 compliance on tricky macros for Spy & match core Unity version
Add CFLAGS in Fixture Makefile to catch C99 rules with '-pedantic'
This commit is contained in:
@ -1,4 +1,8 @@
|
||||
CC = gcc
|
||||
CFLAGS += -Werror
|
||||
CFLAGS += -std=c99
|
||||
CFLAGS += -pedantic
|
||||
CFLAGS += -Wundef
|
||||
DEFINES = -D UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar
|
||||
SRC = ../src/unity_fixture.c \
|
||||
../../../src/unity.c \
|
||||
@ -11,5 +15,5 @@ INC_DIR = -I../src -I../../../src/
|
||||
TARGET = fixture_tests.exe
|
||||
|
||||
all:
|
||||
@ $(CC) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET)
|
||||
@ ./$(TARGET)
|
||||
$(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET)
|
||||
./$(TARGET)
|
||||
|
@ -309,14 +309,17 @@ TEST_TEAR_DOWN(LeakDetection)
|
||||
}
|
||||
|
||||
// This tricky set of defines lets us see if we are using the Spy, returns 1 if true, else 0
|
||||
#define USING_OUTPUT_SPY(a) EXPAND_AND_USE_2ND(ASSIGN_VALUE(a), 0)
|
||||
#define USING_SPY_AS(a) EXPAND_AND_USE_2ND(ASSIGN_VALUE(a), 0)
|
||||
#define ASSIGN_VALUE(a) VAL_FUNC_##a
|
||||
#define VAL_FUNC_UnityOutputCharSpy_OutputChar() 0, 1
|
||||
#define EXPAND_AND_USE_2ND(a, b) SECOND_PARAM(a, b)
|
||||
#define EXPAND_AND_USE_2ND(a, b) SECOND_PARAM(a, b, throwaway)
|
||||
#define SECOND_PARAM(a, b, ...) b
|
||||
#if USING_SPY_AS(UNITY_OUTPUT_CHAR())
|
||||
#define USING_OUTPUT_SPY
|
||||
#endif
|
||||
TEST(LeakDetection, DetectsLeak)
|
||||
{
|
||||
#if USING_OUTPUT_SPY(UNITY_OUTPUT_CHAR()) == 0
|
||||
#ifndef USING_OUTPUT_SPY
|
||||
TEST_IGNORE_MESSAGE("Build with '-D UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar' to enable tests");
|
||||
#else
|
||||
void* m = malloc(10);
|
||||
@ -333,7 +336,7 @@ TEST(LeakDetection, DetectsLeak)
|
||||
|
||||
TEST(LeakDetection, BufferOverrunFoundDuringFree)
|
||||
{
|
||||
#if USING_OUTPUT_SPY(UNITY_OUTPUT_CHAR()) == 0
|
||||
#ifndef USING_OUTPUT_SPY
|
||||
UNITY_PRINT_EOL();
|
||||
TEST_IGNORE();
|
||||
#else
|
||||
@ -352,7 +355,7 @@ TEST(LeakDetection, BufferOverrunFoundDuringFree)
|
||||
|
||||
TEST(LeakDetection, BufferOverrunFoundDuringRealloc)
|
||||
{
|
||||
#if USING_OUTPUT_SPY(UNITY_OUTPUT_CHAR()) == 0
|
||||
#ifndef USING_OUTPUT_SPY
|
||||
UNITY_PRINT_EOL();
|
||||
TEST_IGNORE();
|
||||
#else
|
||||
|
Reference in New Issue
Block a user