12 for(int i
=0;i
<FIFO_SIZE
/2;i
++) {
14 TEST_ASSERT_EQUAL(i
, f
.pop());
16 for(int i
=0;i
<FIFO_SIZE
-1;i
++) {
21 void test_fifo_pop_wrap(void)
24 for(int i
=0;i
<FIFO_SIZE
-1;i
++) {
25 TEST_ASSERT_EQUAL(i
, f
.pop());
29 void test_fifo_popBytes_wrap(void)
32 uint8_t buf
[FIFO_SIZE
] = {0};
33 f
.popBytes(buf
, FIFO_SIZE
-1);
34 for(int i
=0;i
<FIFO_SIZE
-1;i
++) {
35 TEST_ASSERT_EQUAL(i
, buf
[i
]);
39 void test_fifo_ensure()
42 // Push 25 9-byte packets with a 1 byte length header
43 for (int i
= 0; i
< 25; i
++)
45 f
.push(9); // 9 bytes;
46 for(int x
= 0 ; x
<9 ; x
++)
49 TEST_ASSERT_EQUAL(250, f
.size());
51 // Ensure we can push a 99 byte packet with a prefix (i.e. 100 bytes)
53 TEST_ASSERT_EQUAL(150, f
.size()); // make sure that we've popped the right amount to fit our jumbo packet
54 TEST_ASSERT_EQUAL(9, f
.pop()); // check that we have a header len
55 for (int x
= 0; x
< 9; x
++)
56 TEST_ASSERT_EQUAL(10, f
.pop()); // and that all the bytes in the head packet are what we expect
59 int main(int argc
, char **argv
)
62 RUN_TEST(test_fifo_pop_wrap
);
63 RUN_TEST(test_fifo_popBytes_wrap
);
64 RUN_TEST(test_fifo_ensure
);