GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 23 / 0 / 23
Functions: 100.0% 4 / 0 / 4
Branches: 71.4% 10 / 0 / 14

src/G4OCCTMaterialMap.cc
Line Branch Exec Source
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 // Copyright (C) 2026 G4OCCT Contributors
3
4 /// @file G4OCCTMaterialMap.cc
5 /// @brief Implementation of G4OCCTMaterialMap.
6
7 #include "G4OCCT/G4OCCTMaterialMap.hh"
8
9 #include <G4Exception.hh>
10 #include <G4Material.hh>
11
12 57 void G4OCCTMaterialMap::Add(const G4String& stepName, G4Material* material) {
13
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 1 time.
57 if (!material) {
14
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 G4Exception("G4OCCTMaterialMap::Add", "G4OCCT_MatMap000", FatalException,
15
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 ("Null G4Material* provided for STEP material name: \"" + stepName +
16 "\". G4OCCTMaterialMap::Add() requires a non-null material pointer.")
17 1 .c_str());
18 1 return; // unreachable; silences compiler warnings
19 }
20 56 fMap[stepName] = material;
21 57 }
22
23 38 G4Material* G4OCCTMaterialMap::Resolve(const G4String& stepName) const {
24 38 auto it = fMap.find(stepName);
25
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 1 time.
38 if (it == fMap.end()) {
26
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 G4Exception("G4OCCTMaterialMap::Resolve", "G4OCCT_MatMap001", FatalException,
27
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 ("Unresolved STEP material name: \"" + stepName +
28 "\". Register it with G4OCCTMaterialMap::Add() before importing.")
29 1 .c_str());
30 1 return nullptr; // unreachable; silences compiler warnings
31 }
32 37 return it->second;
33 38 }
34
35 13 bool G4OCCTMaterialMap::Contains(const G4String& stepName) const {
36 13 return fMap.count(stepName) > 0;
37 }
38
39 2 void G4OCCTMaterialMap::Merge(const G4OCCTMaterialMap& other) {
40
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
7 for (const auto& [name, mat] : other.fMap) {
41 5 Add(name, mat);
42 }
43 2 }
44