unit_tests/tests/test_kline_bytes_aggregator.cpp
| Line | Branch | Decision | Exec | Source |
|---|---|---|---|---|
| 1 | #include "gtest/gtest.h" | |||
| 2 | #include "kline.h" | |||
| 3 | ||||
| 4 | static int sourceTotal = 11; | |||
| 5 | ||||
| 6 | 4 | TEST(kline, source) { | ||
| 7 | 13 | ByteSource source = [] (uint8_t * buffer, int maxSize) { | ||
| 8 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 11 times.
|
2/2✓ Decision 'true' taken 1 time.
✓ Decision 'false' taken 11 times.
|
12 | if (sourceTotal == 0) |
| 9 | 1 | return (size_t)0; | ||
| 10 | 11 | buffer[0] = sourceTotal; | ||
| 11 | 11 | sourceTotal--; | ||
| 12 | 11 | return (size_t)1; | ||
| 13 | }; | |||
| 14 | ||||
| 15 | 1 | uint8_t b[16]; | ||
| 16 | ||||
| 17 | // there is a bit of pointer logic there so test coverage it is! | |||
| 18 | 1 | int actual = readWhileGives(source, b, sizeof(b)); | ||
| 19 | 1 | ASSERT_EQ(actual, 11); | ||
| 20 | 1 | ASSERT_EQ(b[0], 11); | ||
| 21 | 1 | ASSERT_EQ(b[7], 4); | ||
| 22 | } | |||
| 23 |