mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2026-01-22 16:05:58 +01:00
Merge pull request #792 from RossSmyth/errors
Fix up some warnings/errors
This commit is contained in:
@@ -10,13 +10,12 @@ CC = clang
|
||||
endif
|
||||
ifeq ($(findstring clang, $(CC)), clang)
|
||||
E = -Weverything
|
||||
CFLAGS += $E -Wno-unknown-warning-option -Wno-missing-prototypes
|
||||
CFLAGS += -Wno-unused-macros -Wno-padded -Wno-missing-noreturn
|
||||
CFLAGS += $E -Wno-unknown-warning-option
|
||||
CFLAGS += -Wno-unsafe-buffer-usage
|
||||
endif
|
||||
CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror
|
||||
#CFLAGS += -Wconversion #disabled because if falsely complains about the isinf and isnan macros
|
||||
CFLAGS += -Wno-switch-enum -Wno-double-promotion
|
||||
CFLAGS += -Wno-poison-system-directories
|
||||
CFLAGS += -Wno-covered-switch-default
|
||||
CFLAGS += -Wbad-function-cast -Wcast-qual -Wold-style-definition -Wshadow -Wstrict-overflow \
|
||||
-Wstrict-prototypes -Wswitch-default -Wundef
|
||||
|
||||
@@ -72,6 +72,11 @@ static char putcharSpyBuffer[SPY_BUFFER_MAX];
|
||||
static UNITY_COUNTER_TYPE indexSpyBuffer;
|
||||
static UNITY_COUNTER_TYPE putcharSpyEnabled;
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
||||
#endif
|
||||
|
||||
void startPutcharSpy(void)
|
||||
{
|
||||
indexSpyBuffer = 0;
|
||||
@@ -133,19 +138,30 @@ void flushSpy(void)
|
||||
if (flushSpyEnabled){ flushSpyCalls++; }
|
||||
}
|
||||
|
||||
#define TEST_ASSERT_EQUAL_PRINT_NUMBERS(expected, actual) { \
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
#define TEST_ASSERT_EQUAL_PRINT_NUMBERS(expected, actual) do { \
|
||||
startPutcharSpy(); UnityPrintNumber((actual)); endPutcharSpy(); \
|
||||
TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \
|
||||
}
|
||||
} while (0)
|
||||
|
||||
#define TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS(expected, actual) { \
|
||||
#define TEST_ASSERT_EQUAL_PRINT_UNSIGNED_NUMBERS(expected, actual) do { \
|
||||
startPutcharSpy(); UnityPrintNumberUnsigned((actual)); endPutcharSpy(); \
|
||||
TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \
|
||||
}
|
||||
} while (0)
|
||||
|
||||
#define TEST_ASSERT_EQUAL_PRINT_FLOATING(expected, actual) { \
|
||||
#define TEST_ASSERT_EQUAL_PRINT_FLOATING(expected, actual) do { \
|
||||
startPutcharSpy(); UnityPrintFloat((actual)); endPutcharSpy(); \
|
||||
TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \
|
||||
}
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
|
||||
// The reason this isn't folded into the above diagnostic is to semi-isolate
|
||||
// the header contents from the user content it is included into.
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
||||
#endif
|
||||
|
||||
@@ -61,7 +61,7 @@ void testUnitySizeInitializationReminder(void)
|
||||
#ifndef UNITY_EXCLUDE_SETJMP_H
|
||||
jmp_buf AbortFrame;
|
||||
#endif
|
||||
} _Expected_Unity;
|
||||
} Expected_Unity;
|
||||
#else
|
||||
struct {
|
||||
const char* TestFile;
|
||||
@@ -81,7 +81,7 @@ void testUnitySizeInitializationReminder(void)
|
||||
#ifndef UNITY_EXCLUDE_SETJMP_H
|
||||
jmp_buf AbortFrame;
|
||||
#endif
|
||||
} _Expected_Unity;
|
||||
} Expected_Unity;
|
||||
#endif
|
||||
|
||||
/* Compare our fake structure's size to the actual structure's size. They
|
||||
@@ -89,22 +89,22 @@ void testUnitySizeInitializationReminder(void)
|
||||
*
|
||||
* This accounts for alignment, padding, and packing issues that might come
|
||||
* up between different architectures. */
|
||||
TEST_ASSERT_EQUAL_MESSAGE(sizeof(_Expected_Unity), sizeof(Unity), message);
|
||||
TEST_ASSERT_EQUAL_MESSAGE(sizeof(Expected_Unity), sizeof(Unity), message);
|
||||
}
|
||||
|
||||
void testPassShouldEndImmediatelyWithPass(void)
|
||||
UNITY_FUNCTION_ATTR(noreturn) void testPassShouldEndImmediatelyWithPass(void)
|
||||
{
|
||||
TEST_PASS();
|
||||
TEST_FAIL_MESSAGE("We should have passed already and finished this test");
|
||||
}
|
||||
|
||||
void testPassShouldEndImmediatelyWithPassAndMessage(void)
|
||||
UNITY_FUNCTION_ATTR(noreturn) void testPassShouldEndImmediatelyWithPassAndMessage(void)
|
||||
{
|
||||
TEST_PASS_MESSAGE("Woohoo! This Automatically Passes!");
|
||||
TEST_FAIL_MESSAGE("We should have passed already and finished this test");
|
||||
}
|
||||
|
||||
void testMessageShouldDisplayMessageWithoutEndingAndGoOnToPass(void)
|
||||
UNITY_FUNCTION_ATTR(noreturn) void testMessageShouldDisplayMessageWithoutEndingAndGoOnToPass(void)
|
||||
{
|
||||
TEST_MESSAGE("This is just a message");
|
||||
TEST_MESSAGE("This is another message");
|
||||
@@ -282,7 +282,7 @@ void testProtection(void)
|
||||
TEST_ASSERT_EQUAL(3, mask);
|
||||
}
|
||||
|
||||
void testIgnoredAndThenFailInTearDown(void)
|
||||
UNITY_FUNCTION_ATTR(noreturn) void testIgnoredAndThenFailInTearDown(void)
|
||||
{
|
||||
SetToOneToFailInTearDown = 1;
|
||||
TEST_IGNORE();
|
||||
|
||||
@@ -1208,6 +1208,9 @@ void testNotEqualFloatEachEqualLengthZero(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY)
|
||||
UNITY_FUNCTION_ATTR(noreturn)
|
||||
#endif
|
||||
void testFloatPrinting(void)
|
||||
{
|
||||
#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY)
|
||||
@@ -1257,6 +1260,9 @@ void testFloatPrinting(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY)
|
||||
UNITY_FUNCTION_ATTR(noreturn)
|
||||
#endif
|
||||
void testFloatPrintingRoundTiesToEven(void)
|
||||
{
|
||||
#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY)
|
||||
@@ -1368,6 +1374,9 @@ static void printFloatValue(float f)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(UNITY_TEST_ALL_FLOATS_PRINT_OK) || !defined(USING_OUTPUT_SPY)
|
||||
UNITY_FUNCTION_ATTR(noreturn)
|
||||
#endif
|
||||
void testFloatPrintingRandomSamples(void)
|
||||
{
|
||||
#if !defined(UNITY_TEST_ALL_FLOATS_PRINT_OK) || !defined(USING_OUTPUT_SPY)
|
||||
|
||||
Reference in New Issue
Block a user