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

MikkelSchubert / adapterremoval / #99

15 Apr 2025 10:23PM UTC coverage: 65.404% (-0.03%) from 65.437%
#99

push

travis-ci

web-flow
replace default catch2 string rendering (#125)

Detect if strings contain unprintable characters or whitespace that
cannot easily be distinguished, and escape everything if that is the case

0 of 7 new or added lines in 1 file covered. (0.0%)

9137 of 13970 relevant lines covered (65.4%)

3157.52 hits per line

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

50.0
/tests/unit/testing.cpp
1
// SPDX-License-Identifier: GPL-3.0-or-later
2
// SPDX-FileCopyrightText: 2025 Mikkel Schubert <mikkelsch@gmail.com>
3
#include "testing.hpp"  // declarations
4
#include "strutils.hpp" // for log_escape
5
#include <cctype>       // for isprint
6

7
namespace {
8

9
std::string
10
format_exception(std::string_view name, const std::exception& value)
1✔
11
{
12
  Catch::ReusableStringStream os;
1✔
13
  os << name << "{ " << adapterremoval::log_escape(value.what()) << " }";
2✔
14
  return os.str();
2✔
15
}
1✔
16

17
} // namespace
18

19
namespace Catch {
20

21
std::string
22
Catch::StringMaker<std::invalid_argument, void>::convert(
1✔
23
  const std::invalid_argument& value)
24
{
25
  return format_exception("invalid_argument", value);
1✔
26
}
27

28
std::string
NEW
29
StringMaker<std::string>::convert(const std::string& str)
×
30
{
NEW
31
  if (getCurrentContext().getConfig()->showInvisibles()) {
×
NEW
32
    return adapterremoval::log_escape(str);
×
33
  }
34

NEW
35
  for (const auto c : str) {
×
36
    // Escape any special characters that cannot be distinguished at a glance
NEW
37
    if (!std::isprint(c) || (std::isspace(c) && (c != ' ' && c != '\n'))) {
×
NEW
38
      return adapterremoval::log_escape(str);
×
39
    }
40
  }
41

NEW
42
  return '"' + str + '"';
×
43
}
44

45
} // namespace Catch
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