1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

unittest/core-macros: add negtive cases for DIV_ROUND and DIV_ROUND_UP

This commit is contained in:
Karl Fessel 2022-11-09 17:46:49 +01:00
parent e402e3f57a
commit 228d8e72c0

View File

@ -27,7 +27,17 @@ static void test_math_div_round(void)
TEST_ASSERT_EQUAL_INT(3, DIV_ROUND(a, 7));
TEST_ASSERT_EQUAL_INT(3, DIV_ROUND(21, 7));
TEST_ASSERT_EQUAL_INT(3, DIV_ROUND(22, 7));
TEST_ASSERT_EQUAL_INT(3, DIV_ROUND(-20, -7));
TEST_ASSERT_EQUAL_INT(3, DIV_ROUND(-21, -7));
TEST_ASSERT_EQUAL_INT(3, DIV_ROUND(-22, -7));
TEST_ASSERT_EQUAL_INT(-3, DIV_ROUND(20, -7));
TEST_ASSERT_EQUAL_INT(-3, DIV_ROUND(21, -7));
TEST_ASSERT_EQUAL_INT(-3, DIV_ROUND(22, -7));
TEST_ASSERT_EQUAL_INT(-3, DIV_ROUND(-20, 7));
TEST_ASSERT_EQUAL_INT(-3, DIV_ROUND(-21, 7));
TEST_ASSERT_EQUAL_INT(-3, DIV_ROUND(-22, 7));
TEST_ASSERT_EQUAL_INT(0, DIV_ROUND(1, UINT32_MAX));
}
static void test_math_div_round_up(void)
@ -35,6 +45,15 @@ static void test_math_div_round_up(void)
TEST_ASSERT_EQUAL_INT(3, DIV_ROUND_UP(20, 7));
TEST_ASSERT_EQUAL_INT(3, DIV_ROUND_UP(21, 7));
TEST_ASSERT_EQUAL_INT(4, DIV_ROUND_UP(22, 7));
TEST_ASSERT_EQUAL_INT(3, DIV_ROUND_UP(-20, -7));
TEST_ASSERT_EQUAL_INT(3, DIV_ROUND_UP(-21, -7));
TEST_ASSERT_EQUAL_INT(4, DIV_ROUND_UP(-22, -7));
TEST_ASSERT_EQUAL_INT(-2, DIV_ROUND_UP(20, -7));
TEST_ASSERT_EQUAL_INT(-3, DIV_ROUND_UP(21, -7));
TEST_ASSERT_EQUAL_INT(-3, DIV_ROUND_UP(22, -7));
TEST_ASSERT_EQUAL_INT(-2, DIV_ROUND_UP(-20, 7));
TEST_ASSERT_EQUAL_INT(-3, DIV_ROUND_UP(-21, 7));
TEST_ASSERT_EQUAL_INT(-3, DIV_ROUND_UP(-22, 7));
TEST_ASSERT_EQUAL_INT(1, DIV_ROUND_UP(1, UINT32_MAX));
TEST_ASSERT_EQUAL_INT(1536, MATH_ALIGN(1514, 64));