GCC Code Coverage Report


Directory: ./
File: firmware/libfirmware/util/test/test_cyclic_buffer.cpp
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 100.0% 7 0 7
Functions: 100.0% 3 0 3
Branches: 41.2% 7 0 17
Decisions: -% 0 - 0

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 TEST(util, cyclicBuffer) {
14 cyclic_buffer<int> sb;
15
16 {
17 sb.add(10);
18
19 ASSERT_EQ(10, sb.sum(3));
20
21 sb.add(2);
22 ASSERT_EQ(12, sb.sum(2));
23 }
24 {
25 sb.clear();
26
27 sb.add(1);
28 sb.add(2);
29 sb.add(3);
30 sb.add(4);
31
32 ASSERT_EQ(4, sb.maxValue(3));
33 ASSERT_EQ(4, sb.maxValue(113));
34 ASSERT_EQ( 2, sb.minValue(3)) << "minValue(3)";
35 ASSERT_EQ(1, sb.minValue(113));
36 }
37 }
38