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

MikkelSchubert / adapterremoval / #75

24 Mar 2025 09:26PM UTC coverage: 27.778% (+0.7%) from 27.088%
#75

push

travis-ci

web-flow
rework debug serialization (#97)

- Patch catch2 to disable the built-in stringification of objects with
  begin()/end() functions, to prevent complex objects from being mangled
- Specify custom fallbackStringifier function, that uses a StringStream.
  This ensures that support for stringification is present when tests are
  written, rather than objects being emitted as "{?}"
- Replace existing StringMaker implementations with operator<< functions
- Add tests for these functions

91 of 103 new or added lines in 8 files covered. (88.35%)

11 existing lines in 3 files now uncovered.

2687 of 9673 relevant lines covered (27.78%)

4228.2 hits per line

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

54.05
/src/errors.cpp
1
// SPDX-License-Identifier: GPL-3.0-or-later
2
// SPDX-FileCopyrightText: 2024 Mikkel Schubert <mikkelsch@gmail.com>
3
#include "errors.hpp"   // declarations
4
#include "strutils.hpp" // for log_escape
5
#include <array>        // for array
6
#include <cerrno>       // for errno
7
#include <cstdio>       // for sys_errlist, sys_nerr
8
#include <cstring>      // for strerror_r
9
#include <exception>    // for exception
10
#include <ostream>      // for ostream
11
#include <string>       // for string
12
#include <string_view>  // for string_view
13

14
namespace adapterremoval {
15

16
// The function signature of strerror_r depends on the libc used. Rather than
17
// attempting to match defines, simply select the appropriate wrapper based on
18
// the signature of the function
19
using glibc_strerror_r = char* (*)(int, char*, size_t);
20
using posix_strerror_r = int (*)(int, char*, size_t);
21
//! Recommended buffer size according to `strerror` man page
22
using strerror_buf = std::array<char, 1024>;
23

24
namespace {
25

26
[[maybe_unused]] std::string
UNCOV
27
strerror_r_wrapper(glibc_strerror_r f, int error_number)
×
28
{
29
  strerror_buf buf{};
×
30
  return f(error_number, buf.data(), buf.size());
×
31
}
32

33
[[maybe_unused]] std::string
34
strerror_r_wrapper(posix_strerror_r f, int error_number)
35
{
36
  strerror_buf buf{};
37
  if (f(error_number, buf.data(), buf.size())) {
38
    return "unknown error " + std::to_string(error_number);
39
  }
40

41
  return buf.data();
42
}
43

44
std::ostream&
45
format_exception(std::ostream& os,
3✔
46
                 std::string_view name,
47
                 const std::exception& value)
48
{
49
  return os << name << "{" << log_escape(value.what()) << "}";
15✔
50
}
51

52
} // namespace
53

54
std::string
55
format_io_error(const std::string& message, const int error_number)
×
56
{
57
  if (error_number) {
×
58
    std::ostringstream stream;
×
59
    stream << message << " ('" << strerror_r_wrapper(::strerror_r, error_number)
×
60
           << "')";
×
61

62
    return stream.str();
×
63
  } else {
×
64
    return message;
×
65
  }
66
}
67

68
assert_failed::assert_failed(const std::string& what)
42✔
69
  : std::logic_error(what)
42✔
70
{
71
}
42✔
72

73
io_error::io_error(const std::string& message, int error_number)
1✔
74
  : std::ios_base::failure(
75
      message,
76
      std::error_code(error_number, std::generic_category()))
2✔
77
{
78
}
1✔
79

NEW
80
gzip_error::gzip_error(const std::string& message)
×
NEW
81
  : io_error(message)
×
82
{
83
}
84

85
parsing_error::parsing_error(const std::string& message)
62✔
86
  : std::runtime_error(message)
62✔
87
{
88
}
62✔
89

90
fastq_error::fastq_error(const std::string& message)
51✔
91
  : parsing_error(message)
51✔
92
{
93
}
51✔
94

95
std::ostream&
96
operator<<(std::ostream& os, const assert_failed& value)
1✔
97
{
98
  return format_exception(os, "assert_failed", value);
2✔
99
}
100

101
std::ostream&
NEW
102
operator<<(std::ostream& os, const io_error& value)
×
103
{
NEW
104
  return format_exception(os, "io_error", value);
×
105
}
106

107
std::ostream&
NEW
108
operator<<(std::ostream& os, const gzip_error& value)
×
109
{
NEW
110
  return format_exception(os, "gzip_error", value);
×
111
}
112

113
std::ostream&
114
operator<<(std::ostream& os, const parsing_error& value)
1✔
115
{
116
  return format_exception(os, "parsing_error", value);
2✔
117
}
118

119
std::ostream&
120
operator<<(std::ostream& os, const fastq_error& value)
1✔
121
{
122
  return format_exception(os, "fastq_error", value);
2✔
123
}
124

125
} // namespace adapterremoval
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