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