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

openmc-dev / openmc / 19102841639

05 Nov 2025 01:01PM UTC coverage: 82.019% (-3.1%) from 85.155%
19102841639

Pull #3252

github

web-flow
Merge 3c71decac into bd76fc056
Pull Request #3252: Adding vtkhdf option to write vtk data

16722 of 23233 branches covered (71.98%)

Branch coverage included in aggregate %.

61 of 66 new or added lines in 1 file covered. (92.42%)

3177 existing lines in 103 files now uncovered.

54247 of 63294 relevant lines covered (85.71%)

42990146.99 hits per line

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

59.26
/src/string_utils.cpp
1
#include "openmc/string_utils.h"
2

3
#include <algorithm> // for equal
4
#include <cctype>    // for tolower, isspace
5

6
namespace openmc {
7

8
std::string& strtrim(std::string& s)
8,758✔
9
{
10
  const char* t = " \t\n\r\f\v";
8,758✔
11
  s.erase(s.find_last_not_of(t) + 1);
8,758✔
12
  s.erase(0, s.find_first_not_of(t));
8,758✔
13
  return s;
8,758✔
14
}
15

16
char* strtrim(char* c_str)
×
17
{
18
  std::string std_str;
×
19
  std_str.assign(c_str);
×
20
  strtrim(std_str);
×
21
  int length = std_str.copy(c_str, std_str.size());
×
22
  c_str[length] = '\0';
×
23
  return c_str;
×
UNCOV
24
}
×
25

26
std::string to_element(const std::string& name)
3,072✔
27
{
28
  int pos = name.find_first_of("0123456789");
3,072✔
29
  return name.substr(0, pos);
3,072✔
30
}
31

32
void to_lower(std::string& str)
252,607✔
33
{
34
  for (int i = 0; i < str.size(); i++)
1,992,857✔
35
    str[i] = std::tolower(str[i]);
1,740,250✔
36
}
252,607✔
37

38
int word_count(const std::string& str)
×
39
{
40
  std::stringstream stream(str);
×
41
  std::string dum;
×
42
  int count = 0;
×
43
  while (stream >> dum) {
×
44
    count++;
×
45
  }
46
  return count;
×
UNCOV
47
}
×
48

49
vector<std::string> split(const std::string& in)
7,704✔
50
{
51
  vector<std::string> out;
7,704✔
52

53
  for (int i = 0; i < in.size();) {
1,086,224✔
54
    // Increment i until we find a non-whitespace character.
55
    if (std::isspace(in[i])) {
1,078,520✔
56
      i++;
145,990✔
57

58
    } else {
59
      // Find the next whitespace character at j.
60
      int j = i + 1;
932,530✔
61
      while (j < in.size() && std::isspace(in[j]) == 0) {
1,022,140✔
62
        j++;
89,610✔
63
      }
64

65
      // Push-back everything between i and j.
66
      out.push_back(in.substr(i, j - i));
932,530✔
67
      i = j + 1; // j is whitespace so leapfrog to j+1
932,530✔
68
    }
69
  }
70

71
  return out;
7,704✔
72
}
×
73

74
bool ends_with(const std::string& value, const std::string& ending)
6,025,527✔
75
{
76
  if (ending.size() > value.size())
6,025,527✔
77
    return false;
10,967✔
78
  return std::equal(ending.rbegin(), ending.rend(), value.rbegin());
6,014,560✔
79
}
80

81
bool starts_with(const std::string& value, const std::string& beginning)
7,357,212✔
82
{
83
  if (beginning.size() > value.size())
7,357,212!
84
    return false;
×
85
  return std::equal(beginning.begin(), beginning.end(), value.begin());
7,357,212✔
86
}
87

88
} // 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

© 2025 Coveralls, Inc