mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-25 01:05:21 +03:00
Add bitarray functions for setting and clearing all the array
- bitArraySetAll() and bitArrayClrAll() set and clear the whole array, with the size (in bytes) specified by the caller (to make them work like bitArrayFindFirstSet()) - macros BITARRAY_SET_ALL() and BITARRAY_CLR_ALL() call those two new functions using sizeof(array) as its size
This commit is contained in:
parent
9af8bd1236
commit
fe4c215886
3 changed files with 33 additions and 0 deletions
|
@ -67,3 +67,19 @@ TEST(BitArrayTest, TestFind)
|
|||
EXPECT_EQ(bitArrayFindFirstSet(p, 0, sizeof(p)), -1);
|
||||
EXPECT_EQ(bitArrayFindFirstSet(p, 64, sizeof(p)), -1);
|
||||
}
|
||||
|
||||
TEST(BitArrayTest, TestSetClrAll)
|
||||
{
|
||||
const int bits = 32 * 4;
|
||||
|
||||
BITARRAY_DECLARE(p, bits);
|
||||
BITARRAY_CLR_ALL(p);
|
||||
|
||||
EXPECT_EQ(-1, BITARRAY_FIND_FIRST_SET(p, 0));
|
||||
|
||||
BITARRAY_SET_ALL(p);
|
||||
|
||||
for (int ii = 0; ii < bits; ii++) {
|
||||
EXPECT_EQ(ii, BITARRAY_FIND_FIRST_SET(p, ii));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue