Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 22 additions & 6 deletions test/tests/self_assessment_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
14 changes: 7 additions & 7 deletions test/tests/test_unity_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -81,30 +81,30 @@ 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
* should be the same.
*
* 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");
Expand Down Expand Up @@ -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();
Expand Down
9 changes: 9 additions & 0 deletions test/tests/test_unity_floats.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down