From 433ee635755457f0cc428826b3967034095224cd Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Wed, 24 Feb 2016 16:00:55 -0500 Subject: [PATCH] Added ability to finish test immediately with a pass condition by using TEST_PASS --- src/unity.h | 4 ++++ test/tests/testunity.c | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/unity.h b/src/unity.h index 9f80495..d9f41de 100644 --- a/src/unity.h +++ b/src/unity.h @@ -68,6 +68,10 @@ void tearDown(void); #define TEST_IGNORE() UNITY_TEST_IGNORE(__LINE__, NULL) #define TEST_ONLY() +//It is not necessary for you to call PASS. A PASS condition is assumed if nothing fails. +//This method allows you to abort a test immediately with a PASS state, ignoring the remainder of the test. +#define TEST_PASS() longjmp(Unity.AbortFrame, 1) + //------------------------------------------------------- // Test Asserts (simple) //------------------------------------------------------- diff --git a/test/tests/testunity.c b/test/tests/testunity.c index c7d9af8..13d7d14 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -110,6 +110,12 @@ void testUnitySizeInitializationReminder(void) TEST_ASSERT_EQUAL_MESSAGE(sizeof(_Expected_Unity), sizeof(Unity), message); } +void testPassShouldEndImmediatelyWithPass(void) +{ + TEST_PASS(); + TEST_FAIL_MESSAGE("We should have passed already and finished this test"); +} + void testTrue(void) { TEST_ASSERT(1);