GCC Code Coverage Report


Directory: ./
File: src/detID/cellID.test.cc
Date: 2025-09-01 06:19:01
Exec Total Coverage
Lines: 33 37 89.2%
Functions: 9 9 100.0%
Branches: 46 69 66.7%

Line Branch Exec Source
1 #include "na64detID/cellID.hh"
2
3 #include <gtest/gtest.h>
4
5 namespace na64dp {
6
7 // Tests ECAL's CellID type get/set
8 8 TEST(SADCCellID, decipherCheck) {
9
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 1 times.
64 for( int x = 0; x < 0x1f; ++x ) {
10
2/2
✓ Branch 0 taken 961 times.
✓ Branch 1 taken 31 times.
1984 for( int y = 0; y < 0x1f; ++y ) {
11
2/2
✓ Branch 0 taken 28830 times.
✓ Branch 1 taken 961 times.
59582 for( int i = 1; i < 0x1f; ++i ) {
12 57660 CellID cellID;
13
1/1
✓ Branch 1 taken 28830 times.
57660 cellID.set_x( x );
14
1/1
✓ Branch 1 taken 28830 times.
57660 cellID.set_y( y );
15
1/1
✓ Branch 1 taken 28830 times.
57660 cellID.set_z( i%2 );
16 // check
17
3/4
✓ Branch 1 taken 28830 times.
✓ Branch 4 taken 28830 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 28830 times.
57660 EXPECT_EQ( x, cellID.get_x() );
18
3/4
✓ Branch 1 taken 28830 times.
✓ Branch 4 taken 28830 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 28830 times.
57660 EXPECT_EQ( y, cellID.get_y() );
19
3/4
✓ Branch 1 taken 28830 times.
✓ Branch 4 taken 28830 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 28830 times.
57660 EXPECT_EQ( (i%2), cellID.get_z() );
20 }
21 }
22 }
23 2 }
24
25 8 TEST(SADCCellID, payloadStrConversions) {
26 2 char bf[32] = "";
27
2/3
✓ Branch 1 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
2 EXPECT_FALSE( CellID::from_string(bf) );
28
29 2 const int idxs[] = {0, 1, 17, CellID::idxMax-1, CellID::idxMax};
30
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
12 for( size_t ix = 0; ix < sizeof(idxs)/sizeof(*idxs); ++ix ) {
31
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 5 times.
60 for( size_t iy = 0; iy < sizeof(idxs)/sizeof(*idxs); ++iy ) {
32
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 25 times.
300 for( size_t iz = 0; iz < sizeof(idxs)/sizeof(*idxs); ++iz ) {
33
1/1
✓ Branch 1 taken 125 times.
250 CellID cid(idxs[ix], idxs[iy], idxs[iz]);
34
1/1
✓ Branch 1 taken 125 times.
250 CellID::to_string(cid.id, bf, sizeof(bf));
35
1/1
✓ Branch 1 taken 125 times.
250 CellID ctrl(CellID::from_string(bf));
36
2/3
✓ Branch 1 taken 125 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 125 times.
250 EXPECT_EQ( cid.id, ctrl.id ) << " cid={"
37 << cid.get_x() << ", " << cid.get_y()
38 << ", " << cid.get_z() << "} -> \""
39 << bf << "\" ->"
40 << " {" << ctrl.get_x() << ", " << ctrl.get_y()
41 250 << ", " << ctrl.get_z() << "}";
42 }
43 }
44 }
45 //ASSERT_EQ( CellID::from_string(":"), CellID(0,0,0).id ); // xxx? -- obscure feature
46 2 }
47
48 8 TEST(SADCCellID, payloadStrErrors) {
49 //EXPECT_THROW( CellID::from_string("1-2-3")
50 // , std::exception
51 // ) << "(absence of prefix ignored)";
52 // ^^^ TODO: I doubt that this really has to throw exception since for some
53 // kins a column suffix separator is really an optional
54
5/11
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
2 EXPECT_THROW( CellID::from_string(":a")
55 , std::exception
56 2 ) << "(non-digit passed)";
57
5/11
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
2 EXPECT_THROW( CellID::from_string(":1-a")
58 , std::exception
59 2 ) << "(non-digit passed)";
60
5/11
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 times.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
2 EXPECT_THROW( CellID::from_string(":1-2-3a")
61 , std::exception
62 2 ) << "(tail symbols ignored)";
63 2 }
64
65 }
66