8 const uint32_t fifoSize
= 256;
14 for(int i
=0;i
<fifoSize
/2;i
++) {
16 TEST_ASSERT_EQUAL(i
, f
.pop());
18 for(int i
=0;i
<fifoSize
-1;i
++) {
23 void test_fifo_pop_wrap(void)
26 for(int i
=0;i
<fifoSize
-1;i
++) {
27 TEST_ASSERT_EQUAL(i
, f
.pop());
31 void test_fifo_popBytes_wrap(void)
34 uint8_t buf
[fifoSize
] = {0};
35 f
.popBytes(buf
, fifoSize
-1);
36 for(int i
=0;i
<fifoSize
-1;i
++) {
37 TEST_ASSERT_EQUAL(i
, buf
[i
]);
41 void test_fifo_ensure()
44 // Push 25 9-byte packets with a 1 byte length header
45 for (int i
= 0; i
< 25; i
++)
47 f
.push(9); // 9 bytes;
48 for(int x
= 0 ; x
<9 ; x
++)
51 TEST_ASSERT_EQUAL(250, f
.size());
53 // Ensure we can push a 99 byte packet with a prefix (i.e. 100 bytes)
55 TEST_ASSERT_EQUAL(150, f
.size()); // make sure that we've popped the right amount to fit our jumbo packet
56 TEST_ASSERT_EQUAL(9, f
.pop()); // check that we have a header len
57 for (int x
= 0; x
< 9; x
++)
58 TEST_ASSERT_EQUAL(10, f
.pop()); // and that all the bytes in the head packet are what we expect
61 // Unity setup/teardown
65 int main(int argc
, char **argv
)
68 RUN_TEST(test_fifo_pop_wrap
);
69 RUN_TEST(test_fifo_popBytes_wrap
);
70 RUN_TEST(test_fifo_ensure
);