Line | Branch | Decision | Exec | Source |
---|---|---|---|---|
1 | #include "pch.h" | |||
2 | ||||
3 | using ::testing::ElementsAre; | |||
4 | ||||
5 | 4 | TEST(logBuffer, writeSmall) { | ||
6 | 1 | LogBuffer<10> dut; | ||
7 | 1 | memset(dut.m_buffer, 0x55, sizeof(dut.m_buffer)); | ||
8 | ||||
9 | 1 | LogLineBuffer line; | ||
10 | ||||
11 | 1 | strcpy(line.buffer, "test"); | ||
12 | ||||
13 |
1/1✓ Branch 1 taken 1 time.
|
1 | dut.writeLine(&line); | |
14 | ||||
15 |
4/8✓ Branch 14 taken 1 time.
✓ Branch 17 taken 1 time.
✓ Branch 20 taken 1 time.
✗ Branch 35 not taken.
✓ Branch 36 taken 1 time.
✗ Branch 39 not taken.
✗ Branch 44 not taken.
✗ Branch 47 not taken.
|
1 | EXPECT_THAT(dut.m_buffer, ElementsAre( | |
16 | 't', 'e', 's', 't', '\0', // this part got copied in | |||
17 | 0x55, 0x55, 0x55, 0x55, 0x55 // rest of the buffer is untouched | |||
18 | 1 | )); | ||
19 | 1 | } | ||
20 | ||||
21 | 4 | TEST(logBuffer, writeOverflow) { | ||
22 | 1 | LogBuffer<10> dut; | ||
23 | 1 | memset(dut.m_buffer, 0x55, sizeof(dut.m_buffer)); | ||
24 | ||||
25 | 1 | LogLineBuffer line; | ||
26 | ||||
27 | 1 | strcpy(line.buffer, "testtesttest"); | ||
28 | ||||
29 |
1/1✓ Branch 1 taken 1 time.
|
1 | dut.writeLine(&line); | |
30 | ||||
31 |
4/8✓ Branch 14 taken 1 time.
✓ Branch 17 taken 1 time.
✓ Branch 20 taken 1 time.
✗ Branch 35 not taken.
✓ Branch 36 taken 1 time.
✗ Branch 39 not taken.
✗ Branch 44 not taken.
✗ Branch 47 not taken.
|
1 | EXPECT_THAT(dut.m_buffer, ElementsAre( | |
32 | 't', 'e', 's', 't', | |||
33 | 't', 'e', 's', 't', | |||
34 | 't', 0 | |||
35 | 1 | )); | ||
36 | 1 | } | ||
37 |