mirror of
https://github.com/fmtlib/fmt.git
synced 2025-11-24 11:20:11 +01:00
Make error_code formatter debug-enabled
This commit is contained in:
@@ -513,6 +513,8 @@ template <> struct formatter<std::error_code> {
|
||||
bool debug_ = false;
|
||||
|
||||
public:
|
||||
FMT_CONSTEXPR void set_debug_format(bool set = true) { debug_ = set; }
|
||||
|
||||
FMT_CONSTEXPR auto parse(parse_context<>& ctx) -> const char* {
|
||||
auto it = ctx.begin(), end = ctx.end();
|
||||
if (it == end) return it;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "fmt/os.h" // fmt::system_category
|
||||
#include "fmt/ranges.h"
|
||||
#include "gtest-extra.h" // StartsWith
|
||||
|
||||
#ifdef __cpp_lib_filesystem
|
||||
@@ -335,6 +336,10 @@ TEST(std_test, error_code) {
|
||||
EXPECT_EQ(fmt::format("{:s}", ec), ec.message());
|
||||
EXPECT_EQ(fmt::format("{:?}", std::error_code(42, generic)),
|
||||
"\"generic:42\"");
|
||||
EXPECT_EQ(fmt::format("{}",
|
||||
std::map<std::error_code, int>{
|
||||
{std::error_code(42, generic), 0}}),
|
||||
"{\"generic:42\": 0}");
|
||||
}
|
||||
|
||||
template <typename Catch> void exception_test() {
|
||||
|
||||
Reference in New Issue
Block a user