Skip to content

Commit

Permalink
tests/unittests: add test for ABS() macro
Browse files Browse the repository at this point in the history
  • Loading branch information
Enoch247 committed Feb 8, 2024
1 parent b1cb243 commit fa7a577
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/unittests/tests-core/tests-core-macros.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ static void test_min(void)
TEST_ASSERT(5.5 == MIN(22.1, 5.5));
}

static void test_abs(void)
{
TEST_ASSERT_EQUAL_INT(22, ABS(22));
TEST_ASSERT_EQUAL_INT(22, ABS(-22));

// prove it works with non-integer types
TEST_ASSERT(300.7 == ABS(-300.7));
}

static void test_limit(void)
{
TEST_ASSERT_EQUAL_INT(5, LIMIT(5, -10, 10));
Expand Down Expand Up @@ -114,6 +123,7 @@ Test *tests_core_macros_tests(void)
EMB_UNIT_TESTFIXTURES(fixtures) {
new_TestFixture(test_max),
new_TestFixture(test_min),
new_TestFixture(test_abs),
new_TestFixture(test_limit),
new_TestFixture(test_math_signof),
new_TestFixture(test_math_div_round),
Expand Down

0 comments on commit fa7a577

Please sign in to comment.