AP_HAL: added peekiovec test

fixes #18285
This commit is contained in:
Andrew Tridgell 2021-09-29 19:04:34 +10:00 committed by Peter Barker
parent d7f037e548
commit aa05629ef6
1 changed files with 20 additions and 0 deletions

View File

@ -102,4 +102,24 @@ TEST(ObjectBufferTest, SetSize)
EXPECT_TRUE(x.is_empty());
}
TEST(ObjectBufferTest, PeekTest)
{
ByteBuffer bb(128);
uint8_t seven[7] {1,2,3,4,5,6,7};
for (uint8_t i=0; i<100; i++) {
bb.write(seven, 7);
ByteBuffer::IoVec vec[2];
uint8_t nvec = bb.peekiovec(vec, 7);
uint32_t got = 0;
if (nvec > 0) {
got += vec[0].len;
}
if (nvec > 1) {
got += vec[1].len;
}
EXPECT_EQ(got, 7U);
bb.advance(7);
}
}
AP_GTEST_MAIN()