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