mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2026-01-23 00:15: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
|
endif
|
||||||
ifeq ($(findstring clang, $(CC)), clang)
|
ifeq ($(findstring clang, $(CC)), clang)
|
||||||
E = -Weverything
|
E = -Weverything
|
||||||
CFLAGS += $E -Wno-unknown-warning-option -Wno-missing-prototypes
|
CFLAGS += $E -Wno-unknown-warning-option
|
||||||
CFLAGS += -Wno-unused-macros -Wno-padded -Wno-missing-noreturn
|
CFLAGS += -Wno-unsafe-buffer-usage
|
||||||
endif
|
endif
|
||||||
CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror
|
CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror
|
||||||
#CFLAGS += -Wconversion #disabled because if falsely complains about the isinf and isnan macros
|
#CFLAGS += -Wconversion #disabled because if falsely complains about the isinf and isnan macros
|
||||||
CFLAGS += -Wno-switch-enum -Wno-double-promotion
|
CFLAGS += -Wno-switch-enum -Wno-double-promotion
|
||||||
CFLAGS += -Wno-poison-system-directories
|
|
||||||
CFLAGS += -Wno-covered-switch-default
|
CFLAGS += -Wno-covered-switch-default
|
||||||
CFLAGS += -Wbad-function-cast -Wcast-qual -Wold-style-definition -Wshadow -Wstrict-overflow \
|
CFLAGS += -Wbad-function-cast -Wcast-qual -Wold-style-definition -Wshadow -Wstrict-overflow \
|
||||||
-Wstrict-prototypes -Wswitch-default -Wundef
|
-Wstrict-prototypes -Wswitch-default -Wundef
|
||||||
|
|||||||
@@ -72,6 +72,11 @@ static char putcharSpyBuffer[SPY_BUFFER_MAX];
|
|||||||
static UNITY_COUNTER_TYPE indexSpyBuffer;
|
static UNITY_COUNTER_TYPE indexSpyBuffer;
|
||||||
static UNITY_COUNTER_TYPE putcharSpyEnabled;
|
static UNITY_COUNTER_TYPE putcharSpyEnabled;
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
||||||
|
#endif
|
||||||
|
|
||||||
void startPutcharSpy(void)
|
void startPutcharSpy(void)
|
||||||
{
|
{
|
||||||
indexSpyBuffer = 0;
|
indexSpyBuffer = 0;
|
||||||
@@ -133,19 +138,30 @@ void flushSpy(void)
|
|||||||
if (flushSpyEnabled){ flushSpyCalls++; }
|
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(); \
|
startPutcharSpy(); UnityPrintNumber((actual)); endPutcharSpy(); \
|
||||||
TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \
|
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(); \
|
startPutcharSpy(); UnityPrintNumberUnsigned((actual)); endPutcharSpy(); \
|
||||||
TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \
|
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(); \
|
startPutcharSpy(); UnityPrintFloat((actual)); endPutcharSpy(); \
|
||||||
TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \
|
TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \
|
||||||
}
|
} while (0)
|
||||||
|
|
||||||
#endif
|
#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
|
#ifndef UNITY_EXCLUDE_SETJMP_H
|
||||||
jmp_buf AbortFrame;
|
jmp_buf AbortFrame;
|
||||||
#endif
|
#endif
|
||||||
} _Expected_Unity;
|
} Expected_Unity;
|
||||||
#else
|
#else
|
||||||
struct {
|
struct {
|
||||||
const char* TestFile;
|
const char* TestFile;
|
||||||
@@ -81,7 +81,7 @@ void testUnitySizeInitializationReminder(void)
|
|||||||
#ifndef UNITY_EXCLUDE_SETJMP_H
|
#ifndef UNITY_EXCLUDE_SETJMP_H
|
||||||
jmp_buf AbortFrame;
|
jmp_buf AbortFrame;
|
||||||
#endif
|
#endif
|
||||||
} _Expected_Unity;
|
} Expected_Unity;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Compare our fake structure's size to the actual structure's size. They
|
/* 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
|
* This accounts for alignment, padding, and packing issues that might come
|
||||||
* up between different architectures. */
|
* 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_PASS();
|
||||||
TEST_FAIL_MESSAGE("We should have passed already and finished this test");
|
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_PASS_MESSAGE("Woohoo! This Automatically Passes!");
|
||||||
TEST_FAIL_MESSAGE("We should have passed already and finished this test");
|
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 just a message");
|
||||||
TEST_MESSAGE("This is another message");
|
TEST_MESSAGE("This is another message");
|
||||||
@@ -282,7 +282,7 @@ void testProtection(void)
|
|||||||
TEST_ASSERT_EQUAL(3, mask);
|
TEST_ASSERT_EQUAL(3, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void testIgnoredAndThenFailInTearDown(void)
|
UNITY_FUNCTION_ATTR(noreturn) void testIgnoredAndThenFailInTearDown(void)
|
||||||
{
|
{
|
||||||
SetToOneToFailInTearDown = 1;
|
SetToOneToFailInTearDown = 1;
|
||||||
TEST_IGNORE();
|
TEST_IGNORE();
|
||||||
|
|||||||
@@ -1208,6 +1208,9 @@ void testNotEqualFloatEachEqualLengthZero(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY)
|
||||||
|
UNITY_FUNCTION_ATTR(noreturn)
|
||||||
|
#endif
|
||||||
void testFloatPrinting(void)
|
void testFloatPrinting(void)
|
||||||
{
|
{
|
||||||
#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY)
|
#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY)
|
||||||
@@ -1257,6 +1260,9 @@ void testFloatPrinting(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY)
|
||||||
|
UNITY_FUNCTION_ATTR(noreturn)
|
||||||
|
#endif
|
||||||
void testFloatPrintingRoundTiesToEven(void)
|
void testFloatPrintingRoundTiesToEven(void)
|
||||||
{
|
{
|
||||||
#if defined(UNITY_EXCLUDE_FLOAT_PRINT) || defined(UNITY_INCLUDE_DOUBLE) || !defined(USING_OUTPUT_SPY)
|
#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
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(UNITY_TEST_ALL_FLOATS_PRINT_OK) || !defined(USING_OUTPUT_SPY)
|
||||||
|
UNITY_FUNCTION_ATTR(noreturn)
|
||||||
|
#endif
|
||||||
void testFloatPrintingRandomSamples(void)
|
void testFloatPrintingRandomSamples(void)
|
||||||
{
|
{
|
||||||
#if !defined(UNITY_TEST_ALL_FLOATS_PRINT_OK) || !defined(USING_OUTPUT_SPY)
|
#if !defined(UNITY_TEST_ALL_FLOATS_PRINT_OK) || !defined(USING_OUTPUT_SPY)
|
||||||
|
|||||||
Reference in New Issue
Block a user