• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

openmc-dev / openmc / 13425250228

20 Feb 2025 12:37AM UTC coverage: 85.027% (+0.2%) from 84.826%
13425250228

Pull #3167

github

web-flow
Merge 2968a5e14 into bcc2a4c5f
Pull Request #3167: Streamline use of CompositeSurface with SurfaceFilter

2 of 3 new or added lines in 1 file covered. (66.67%)

2491 existing lines in 75 files now uncovered.

50632 of 59548 relevant lines covered (85.03%)

35313218.27 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.58
/src/xml_interface.cpp
1
#include "openmc/xml_interface.h"
2

3
#include <fmt/core.h>
4

5
#include "openmc/error.h"
6
#include "openmc/string_utils.h"
7
#include "openmc/vector.h"
8

9
namespace openmc {
10

11
std::string get_node_value(
16,656,157✔
12
  pugi::xml_node node, const char* name, bool lowercase, bool strip)
13
{
14
  // Search for either an attribute or child tag and get the data as a char*.
15
  const pugi::char_t* value_char;
16
  if (node.attribute(name)) {
16,656,157✔
17
    value_char = node.attribute(name).value();
16,488,283✔
18
  } else if (node.child(name)) {
167,874✔
19
    value_char = node.child_value(name);
167,874✔
20
  } else {
21
    fatal_error(fmt::format(
×
UNCOV
22
      "Node \"{}\" is not a member of the \"{}\" XML node", name, node.name()));
×
23
  }
24
  std::string value {value_char};
16,656,157✔
25

26
  // Convert to lower-case if needed
27
  if (lowercase)
16,656,157✔
28
    to_lower(value);
188,075✔
29

30
  // Strip leading/trailing whitespace if needed
31
  if (strip) {
16,656,157✔
32
    value.erase(0, value.find_first_not_of(" \t\r\n"));
215,047✔
33
    value.erase(value.find_last_not_of(" \t\r\n") + 1);
215,047✔
34
  }
35

36
  return value;
16,656,157✔
UNCOV
37
}
×
38

39
bool get_node_value_bool(pugi::xml_node node, const char* name)
9,513✔
40
{
41
  if (node.attribute(name)) {
9,513✔
42
    return node.attribute(name).as_bool();
6,657✔
43
  } else if (node.child(name)) {
2,856✔
44
    return node.child(name).text().as_bool();
2,856✔
45
  } else {
46
    fatal_error(fmt::format(
×
UNCOV
47
      "Node \"{}\" is not a member of the \"{}\" XML node", name, node.name()));
×
48
  }
49
  return false;
50
}
51

52
vector<Position> get_node_position_array(
12✔
53
  pugi::xml_node node, const char* name, bool lowercase)
54
{
55
  vector<double> coords = get_node_array<double>(node, name, lowercase);
12✔
56
  if (coords.size() % 3 != 0) {
12✔
UNCOV
57
    fatal_error(fmt::format(
×
58
      "Incorect number of coordinates in Position array ({}) for \"{}\"",
UNCOV
59
      coords.size(), name));
×
60
  }
61
  vector<Position> positions;
12✔
62
  positions.reserve(coords.size() / 3);
12✔
63
  auto it = coords.begin();
12✔
64
  for (size_t i = 0; i < coords.size(); i += 3) {
60✔
65
    positions.push_back({coords[i], coords[i + 1], coords[i + 2]});
48✔
66
  }
67
  return positions;
24✔
68
}
12✔
69

70
Position get_node_position(
718✔
71
  pugi::xml_node node, const char* name, bool lowercase)
72
{
73
  vector<double> arr = get_node_array<double>(node, name, lowercase);
718✔
74
  return Position(arr);
1,436✔
75
}
718✔
76

77
} // namespace openmc
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc