include: util: Add DIV_ROUND_CLOSEST helper
It's similar to DIV_ROUND_UP, but rounds to the nearest integer. Some basic unit tests were introduced to check that it works as intended. Signed-off-by: Kornel Dulęba <mindal@semihalf.com>
This commit is contained in:
parent
ecbaac60bd
commit
8fc913374f
3 changed files with 42 additions and 0 deletions
|
@ -151,6 +151,11 @@ ZTEST(util_cxx, test_DIV_ROUND_UP)
|
|||
run_DIV_ROUND_UP();
|
||||
}
|
||||
|
||||
ZTEST(util_cxx, test_DIV_ROUND_CLOSEST)
|
||||
{
|
||||
run_DIV_ROUND_CLOSEST();
|
||||
}
|
||||
|
||||
ZTEST_SUITE(util_cxx, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
#if __cplusplus
|
||||
|
@ -294,4 +299,9 @@ ZTEST(util_cc, test_DIV_ROUND_UP)
|
|||
run_DIV_ROUND_UP();
|
||||
}
|
||||
|
||||
ZTEST(util_cc, test_DIV_ROUND_CLOSEST)
|
||||
{
|
||||
run_DIV_ROUND_CLOSEST();
|
||||
}
|
||||
|
||||
ZTEST_SUITE(util_cc, NULL, NULL, NULL, NULL, NULL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue