From 15514e7993b151704859a09ed8a6b93ad7a259e5 Mon Sep 17 00:00:00 2001 From: mkarlesky Date: Thu, 8 Oct 2009 16:10:43 +0000 Subject: [PATCH] added missing 'message' params in _MESSAGE macros; added TEST_ASSERT_NOT_EQUAL git-svn-id: http://unity.svn.sourceforge.net/svnroot/unity/trunk@43 e7d17a6e-8845-0410-bbbc-c8efb4fdad7e --- src/unity.h | 9 ++++++--- test/testunity.c | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/unity.h b/src/unity.h index a067947..33cf37e 100644 --- a/src/unity.h +++ b/src/unity.h @@ -190,13 +190,13 @@ void UnityIgnore(const char* message, const long line); #define TEST_ASSERT_MESSAGE(condition, message) if (condition) {} else {TEST_FAIL(message);} #define TEST_ASSERT(condition) TEST_ASSERT_MESSAGE(condition, NULL) -#define TEST_ASSERT_TRUE_MESSAGE(condition) TEST_ASSERT_MESSAGE(condition, message) +#define TEST_ASSERT_TRUE_MESSAGE(condition, message) TEST_ASSERT_MESSAGE(condition, message) #define TEST_ASSERT_TRUE(condition) TEST_ASSERT(condition) -#define TEST_ASSERT_UNLESS_MESSAGE(condition) TEST_ASSERT_MESSAGE(!(condition), message) +#define TEST_ASSERT_UNLESS_MESSAGE(condition, message) TEST_ASSERT_MESSAGE(!(condition), message) #define TEST_ASSERT_UNLESS(condition) TEST_ASSERT(!(condition)) -#define TEST_ASSERT_FALSE_MESSAGE(condition) TEST_ASSERT_MESSAGE(!(condition), message) +#define TEST_ASSERT_FALSE_MESSAGE(condition, message) TEST_ASSERT_MESSAGE(!(condition), message) #define TEST_ASSERT_FALSE(condition) TEST_ASSERT(!(condition)) #define TEST_ASSERT_NULL(pointer) TEST_ASSERT_MESSAGE(pointer == NULL, #pointer " was not null.") @@ -217,6 +217,9 @@ void UnityIgnore(const char* message, const long line); #define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) TEST_ASSERT_EQUAL_INT_MESSAGE((expected), (actual), (message)) #define TEST_ASSERT_EQUAL(expected, actual) TEST_ASSERT_EQUAL_INT(expected, actual) +#define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) TEST_ASSERT_FALSE_MESSAGE(((expected) == (actual)), (message)) +#define TEST_ASSERT_NOT_EQUAL(expected, actual) TEST_ASSERT_FALSE((expected) == (actual)) + #define TEST_ASSERT_INT_WITHIN_MESSAGE(delta, expected, actual, message) \ Unity.TestFile=__FILE__; \ UnityAssertNumbersWithin((long)(delta), (long)(expected), (long)(actual), NULL, (unsigned short)__LINE__); \ diff --git a/test/testunity.c b/test/testunity.c index f5fae46..00579f5 100644 --- a/test/testunity.c +++ b/test/testunity.c @@ -104,6 +104,21 @@ void testNotUnless(void) TEST_ASSERT_EQUAL_INT(0U, Unity.TestFailures); } +void testNotNotEqual(void) +{ + int failed; + + EXPECT_ABORT_BEGIN + TEST_ASSERT_NOT_EQUAL(10, 10); + EXPECT_ABORT_END + + failed = Unity.CurrentTestFailed; + Unity.CurrentTestFailed = 0; + + TEST_ASSERT_EQUAL_INT(1U, failed); + TEST_ASSERT_EQUAL_INT(0U, Unity.TestFailures); +} + void testFail(void) { int failed; @@ -290,6 +305,17 @@ void testEqualUints(void) TEST_ASSERT_EQUAL_UINT(60872u, 60872u); } +void testNotEqual(void) +{ + TEST_ASSERT_NOT_EQUAL(0, 1); + TEST_ASSERT_NOT_EQUAL(1, 0); + TEST_ASSERT_NOT_EQUAL(100, 101); + TEST_ASSERT_NOT_EQUAL(0, -1); + TEST_ASSERT_NOT_EQUAL(65535, -65535); + TEST_ASSERT_NOT_EQUAL(75, 900); + TEST_ASSERT_NOT_EQUAL(-100, -101); +} + void testEqualHex8s(void) { _UU8 v0, v1; -- GitLab