Debian Codegraph @

bindings/cxx/tests/helpers.cpp

raw symbols SCIP
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 // SPDX-FileCopyrightText: 2021-2022 Bartosz Golaszewski <[email protected]>
3
4 #include "helpers.hpp"
5
6 system_error_matcher::system_error_matcher(int expected_errno)
7 : _m_cond(::std::system_category().default_error_condition(expected_errno))
8 {
9
10 }
11
12 ::std::string system_error_matcher::describe() const
13 {
14 return "matches: errno " + ::std::to_string(this->_m_cond.value());
15 }
16
17 bool system_error_matcher::match(const ::std::system_error& error) const
18 {
19 return error.code().value() == this->_m_cond.value();
20 }
21
22 regex_matcher::regex_matcher(const ::std::string& pattern)
23 : _m_pattern(pattern),
24 _m_repr("matches: regex \"" + pattern + "\"")
25 {
26
27 }
28
29 ::std::string regex_matcher::describe() const
30 {
31 return this->_m_repr;
32 }
33
34 bool regex_matcher::match(const ::std::string& str) const
35 {
36 return ::std::regex_match(str, this->_m_pattern);
37 }