diff options
| author | hathach <[email protected]> | 2013-01-13 20:00:01 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-01-13 20:00:01 +0700 |
| commit | 1deac989696fc216acb4dd1208dab8991e886c6c (patch) | |
| tree | 727021fd750cf7ef87b08aead03e3fade0948806 /tests/test/test_assertion.c | |
| parent | 463b1c029477e6c5eacae2cebcdcb8ba534ef9bb (diff) | |
add ASSERT_INT, ASSERT_INT_EQUAL and test code for it
Diffstat (limited to 'tests/test/test_assertion.c')
| -rw-r--r-- | tests/test/test_assertion.c | 41 |
1 files changed, 34 insertions, 7 deletions
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 <stdint.h> #include <stdio.h> #include <stdbool.h> #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(); } |
