1
0
mirror of https://github.com/ThrowTheSwitch/Unity.git synced 2026-01-24 17:01:35 +01:00

- Added ability to tack on details to a Unity failure message.

This commit is contained in:
Mark VanderVoord
2015-12-10 13:06:41 -05:00
parent 9aeaee26c9
commit dfbf21c2a3
3 changed files with 84 additions and 0 deletions

View File

@@ -71,6 +71,7 @@ void testUnitySizeInitializationReminder(void)
"still correct.";
/* Define a structure with all the same fields as `struct _Unity`. */
#ifdef UNITY_EXCLUDE_DETAILS
struct {
const char* TestFile;
const char* CurrentTestName;
@@ -82,6 +83,21 @@ void testUnitySizeInitializationReminder(void)
UNITY_COUNTER_TYPE CurrentTestIgnored;
jmp_buf AbortFrame;
} _Expected_Unity;
#else
struct {
const char* TestFile;
const char* CurrentTestName;
const char* CurrentDetails1;
const char* CurrentDetails2;
UNITY_LINE_TYPE CurrentTestLineNumber;
UNITY_COUNTER_TYPE NumberOfTests;
UNITY_COUNTER_TYPE TestFailures;
UNITY_COUNTER_TYPE TestIgnores;
UNITY_COUNTER_TYPE CurrentTestFailed;
UNITY_COUNTER_TYPE CurrentTestIgnored;
jmp_buf AbortFrame;
} _Expected_Unity;
#endif
/* Compare our fake structure's size to the actual structure's size. They
* should be the same.
@@ -3484,3 +3500,43 @@ void testNotEqualDoubleArraysInf(void)
VERIFY_FAILS_END
#endif
}
void testThatDetailsCanBeHandleOneDetail(void)
{
#ifdef UNITY_EXCLUDE_DETAILS
TEST_IGNORE();
#else
UNITY_SET_DETAIL("Detail1");
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_INT_MESSAGE(5, 6, "Should Fail And Say Detail1");
VERIFY_FAILS_END
#endif
}
void testThatDetailsCanBeHandleTwoDetails(void)
{
#ifdef UNITY_EXCLUDE_DETAILS
TEST_IGNORE();
#else
UNITY_SET_DETAILS("Detail1","Detail2");
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_HEX8_MESSAGE(7, 8, "Should Fail And Say Detail1 and Detail2");
VERIFY_FAILS_END
#endif
}
void testThatDetailsCanBeHandleSingleDetailClearingTwoDetails(void)
{
#ifdef UNITY_EXCLUDE_DETAILS
TEST_IGNORE();
#else
UNITY_SET_DETAILS("Detail1","Detail2");
UNITY_SET_DETAIL("DetailNew");
EXPECT_ABORT_BEGIN
TEST_ASSERT_EQUAL_STRING_MESSAGE("MEH", "GUH", "Should Fail And Say DetailNew");
VERIFY_FAILS_END
#endif
}