From eb9fbfb790eabac6835c21bd885ca238abfb3228 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Thu, 16 Mar 2023 16:40:05 +0100 Subject: [PATCH] tests/unittests: add test for bf_clear_all() --- tests/unittests/tests-bitfield/tests-bitfield.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/unittests/tests-bitfield/tests-bitfield.c b/tests/unittests/tests-bitfield/tests-bitfield.c index d67625f0b4..b29d30df1f 100644 --- a/tests/unittests/tests-bitfield/tests-bitfield.c +++ b/tests/unittests/tests-bitfield/tests-bitfield.c @@ -299,6 +299,16 @@ static void test_bf_set_all(void) TEST_ASSERT_EQUAL_INT(0, field[4]); } +static void test_bf_clear_all(void) +{ + uint8_t field[5]; + + memset(field, 0xFF, sizeof(field)); + bf_clear_all(field, 5); + TEST_ASSERT_EQUAL_INT(0x7, field[0]); + TEST_ASSERT_EQUAL_INT(0xFF, field[1]); +} + static void test_bf_popcnt(void) { uint8_t field[5]; @@ -334,6 +344,7 @@ Test *tests_bitfield_tests(void) { new_TestFixture(test_bf_find_first_set), new_TestFixture(test_bf_find_first_unset), new_TestFixture(test_bf_set_all), + new_TestFixture(test_bf_clear_all), new_TestFixture(test_bf_popcnt), };