Move formatter<std::error_code> from fmt/os.h to fmt/std.h (#3125)

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
This commit is contained in:
Vladislav Shchapov
2022-10-02 05:46:09 +05:00
committed by GitHub
parent ad91cab374
commit 662adf4f33
4 changed files with 32 additions and 30 deletions

View File

@ -10,6 +10,7 @@
#include <string>
#include <vector>
#include "fmt/os.h" // fmt::system_category
#include "fmt/ranges.h"
#include "gtest-extra.h" // StartsWith
@ -83,6 +84,18 @@ TEST(std_test, variant) {
#endif
}
TEST(std_test, error_code) {
EXPECT_EQ("generic:42",
fmt::format(FMT_STRING("{0}"),
std::error_code(42, std::generic_category())));
EXPECT_EQ("system:42",
fmt::format(FMT_STRING("{0}"),
std::error_code(42, fmt::system_category())));
EXPECT_EQ("system:-42",
fmt::format(FMT_STRING("{0}"),
std::error_code(-42, fmt::system_category())));
}
template <typename Catch> void exception_test() {
try {
throw std::runtime_error("Test Exception");