From 1deac989696fc216acb4dd1208dab8991e886c6c Mon Sep 17 00:00:00 2001 From: hathach Date: Sun, 13 Jan 2013 20:00:01 +0700 Subject: add ASSERT_INT, ASSERT_INT_EQUAL and test code for it --- tests/test/test_assertion.c | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) (limited to 'tests/test') diff --git a/tests/test/test_assertion.c b/tests/test/test_assertion.c index cbbc24375..781db9cb1 100644 --- a/tests/test/test_assertion.c +++ b/tests/test/test_assertion.c @@ -35,6 +35,7 @@ * This file is part of the tiny usb stack. */ +#include #include #include #include "unity.h" @@ -48,15 +49,41 @@ void tearDown(void) { } -void test_assert_true(void) +//--------------------------------------------------------------------+ +// Logical +//--------------------------------------------------------------------+ +void test_assert_logical_true(void) { - ASSERT(true, (void)0 ); - ASSERT_TRUE(true, (void)0 ); - ASSERT_TRUE(false, (void)0 ); + ASSERT (true , (void)0 ); + ASSERT_TRUE (true , (void)0 ); + + ASSERT_TRUE (false , (void)0 ); + TEST_FAIL(); +} + +void test_assert_logical_false(void) +{ + ASSERT_FALSE(false , (void)0 ); + ASSERT_FALSE(true , (void)0 ); + + TEST_FAIL(); } -void test_assert_false(void) +//--------------------------------------------------------------------+ +// Integer +//--------------------------------------------------------------------+ +void test_assert_int_eqal(void) { - ASSERT_FALSE(false, (void)0 ); - ASSERT_FALSE(true, (void)0 ); + ASSERT_INT (1, 1, (void) 0); + ASSERT_INT_EQUAL (1, 1, (void) 0); + + uint32_t x = 0; + uint32_t y = 0; + ASSERT_INT (x++, y++, (void) 0); // test side effect + TEST_ASSERT_EQUAL(1, x); + TEST_ASSERT_EQUAL(1, y); + + ASSERT_INT(0, 1, (void) 0); + + TEST_FAIL(); } -- cgit v1.3.1