mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 05:52:44 +01:00
tests/unittests: add unit test for LIMIT() macro
This commit is contained in:
parent
8e3bbca8b5
commit
b1cb2435d8
@ -32,6 +32,18 @@ static void test_min(void)
|
||||
TEST_ASSERT(5.5 == MIN(22.1, 5.5));
|
||||
}
|
||||
|
||||
static void test_limit(void)
|
||||
{
|
||||
TEST_ASSERT_EQUAL_INT(5, LIMIT(5, -10, 10));
|
||||
TEST_ASSERT_EQUAL_INT(10, LIMIT(10, -10, 10));
|
||||
TEST_ASSERT_EQUAL_INT(10, LIMIT(22, -10, 10));
|
||||
TEST_ASSERT_EQUAL_INT(-10, LIMIT(-10, -10, 10));
|
||||
TEST_ASSERT_EQUAL_INT(-10, LIMIT(-22, -10, 10));
|
||||
|
||||
// prove it works with non-integer types
|
||||
TEST_ASSERT(10.2 == LIMIT(22.2, -10.1, 10.2));
|
||||
}
|
||||
|
||||
static void test_math_signof(void)
|
||||
{
|
||||
TEST_ASSERT_EQUAL_INT(1, SIGNOF(3));
|
||||
@ -102,6 +114,7 @@ Test *tests_core_macros_tests(void)
|
||||
EMB_UNIT_TESTFIXTURES(fixtures) {
|
||||
new_TestFixture(test_max),
|
||||
new_TestFixture(test_min),
|
||||
new_TestFixture(test_limit),
|
||||
new_TestFixture(test_math_signof),
|
||||
new_TestFixture(test_math_div_round),
|
||||
new_TestFixture(test_math_div_round_up),
|
||||
|
Loading…
Reference in New Issue
Block a user