GCC Code Coverage Report


Directory: ./
File: firmware/libfirmware/util/test/test_arrays.cpp
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 100.0% 20 0 20
Functions: 100.0% 6 0 6
Branches: 51.0% 26 0 51
Decisions: -% 0 - 0

Line Branch Decision Exec Source
1 #include <rusefi/arrays.h>
2
3 #include <gtest/gtest.h>
4 #include <gmock/gmock.h>
5
6 using testing::ElementsAre;
7
8 4 TEST(Util_Arrays, CopyArray) {
9 1 int arr[2];
10
11 // Copy from an initializer list
12 1 copyArray(arr, { 10, 20 });
13
5/10
✓ Branch 6 taken 1 time.
✓ Branch 9 taken 1 time.
✓ Branch 12 taken 1 time.
✗ Branch 19 not taken.
✓ Branch 20 taken 1 time.
✗ Branch 23 not taken.
✗ Branch 28 not taken.
✗ Branch 31 not taken.
✓ Branch 38 taken 1 time.
✗ Branch 39 not taken.
1 ASSERT_THAT(arr, ElementsAre(10, 20));
14
15 // Copy from another array
16 1 int arr2[] = { 30, 40 };
17 1 copyArray(arr, arr2);
18
5/10
✓ Branch 6 taken 1 time.
✓ Branch 9 taken 1 time.
✓ Branch 12 taken 1 time.
✗ Branch 19 not taken.
✓ Branch 20 taken 1 time.
✗ Branch 23 not taken.
✗ Branch 28 not taken.
✗ Branch 31 not taken.
✓ Branch 38 taken 1 time.
✗ Branch 39 not taken.
1 ASSERT_THAT(arr, ElementsAre(30, 40));
19
20 // Copy to a scaled channel
21 1 scaled_channel<int, 10, 1> arr3[2];
22
1/1
✓ Branch 2 taken 1 time.
1 copyArray(arr3, { 100, 200 });
23
5/10
✓ Branch 6 taken 1 time.
✓ Branch 9 taken 1 time.
✓ Branch 12 taken 1 time.
✗ Branch 19 not taken.
✓ Branch 20 taken 1 time.
✗ Branch 23 not taken.
✗ Branch 28 not taken.
✗ Branch 31 not taken.
✓ Branch 38 taken 1 time.
✗ Branch 39 not taken.
1 ASSERT_THAT(arr3, ElementsAre(100, 200));
24 }
25
26 4 TEST(Util_Arrays, CopyArrayPartial) {
27 1 int arr[4];
28 1 copyArray(arr, { 1, 2, 3, 4 });
29
5/10
✓ Branch 8 taken 1 time.
✓ Branch 11 taken 1 time.
✓ Branch 14 taken 1 time.
✗ Branch 23 not taken.
✓ Branch 24 taken 1 time.
✗ Branch 27 not taken.
✗ Branch 32 not taken.
✗ Branch 35 not taken.
✓ Branch 42 taken 1 time.
✗ Branch 43 not taken.
1 ASSERT_THAT(arr, ElementsAre(1, 2, 3, 4));
30
31 // Copy a smaller array over the beginning of arr
32 1 copyArrayPartial(arr, { 100, 200 });
33
5/10
✓ Branch 8 taken 1 time.
✓ Branch 11 taken 1 time.
✓ Branch 14 taken 1 time.
✗ Branch 23 not taken.
✓ Branch 24 taken 1 time.
✗ Branch 27 not taken.
✗ Branch 32 not taken.
✗ Branch 35 not taken.
✓ Branch 42 taken 1 time.
✗ Branch 43 not taken.
1 ASSERT_THAT(arr, ElementsAre(100, 200, 3, 4));
34 }
35
36 TEST(Util_Arrays, Size) {
37 int arr1[2];
38 uint8_t arr2[17];
39 scaled_channel<uint16_t, 3, 1> arr3[21];
40
41 ASSERT_EQ(2u, efi::size(arr1));
42 ASSERT_EQ(17u, efi::size(arr2));
43 ASSERT_EQ(21u, efi::size(arr3));
44 }
45