GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 22 / 0 / 22
Functions: 100.0% 3 / 0 / 3
Branches: 41.2% 7 / 0 / 17
Decisions: -% 0 / - / 0

firmware/libfirmware/util/test/test_cyclic_buffer.cpp
Line Branch Decision Exec Source
1 #include <gtest/gtest.h>
2
3 #include "cyclic_buffer.h"
4 #include "rusefi/true_false.h"
5
6 4 TEST(util, cyclicBufferContains) {
7
1/1
✓ Branch 2 taken 1 time.
1 cyclic_buffer<int> sb;
8 1 sb.add(10);
9
3/8
✓ Branch 5 taken 1 time.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 time.
✗ Branch 14 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✓ Branch 29 taken 1 time.
✗ Branch 30 not taken.
1 ASSERT_EQ(TRUE, sb.contains(10));
10
3/8
✓ Branch 5 taken 1 time.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 time.
✗ Branch 14 not taken.
✗ Branch 19 not taken.
✗ Branch 22 not taken.
✓ Branch 29 taken 1 time.
✗ Branch 30 not taken.
1 ASSERT_EQ(FALSE, sb.contains(11));
11 }
12
13 4 TEST(util, cyclicBuffer) {
14 1 cyclic_buffer<int> sb;
15
16 {
17 1 sb.add(10);
18
19 1 ASSERT_EQ(10, sb.sum(3));
20
21 1 sb.add(2);
22 1 ASSERT_EQ(12, sb.sum(2));
23 }
24 {
25 1 sb.clear();
26
27 1 sb.add(1);
28 1 sb.add(2);
29 1 sb.add(3);
30 1 sb.add(4);
31
32 1 ASSERT_EQ(4, sb.maxValue(3));
33 1 ASSERT_EQ(4, sb.maxValue(113));
34 1 ASSERT_EQ( 2, sb.minValue(3)) << "minValue(3)";
35 1 ASSERT_EQ(1, sb.minValue(113));
36 }
37 }
38