Add formatter for std::exception (#3062)
Co-authored-by: fekir <federico.kircheis@gmail.com> Co-authored-by: Alexey Ochapov <alexez@alexez.com> Co-authored-by: Vladislav Shchapov <vladislav@shchapov.ru> Co-authored-by: fekir <federico.kircheis@gmail.com> Co-authored-by: Alexey Ochapov <alexez@alexez.com> Co-authored-by: Vladislav Shchapov <vladislav@shchapov.ru>
This commit is contained in:
co-authored by
fekir
Alexey Ochapov
Vladislav Shchapov
parent
75383a87f9
commit
4191477b98
+20
-1
@@ -6,11 +6,11 @@
|
||||
// For the license information refer to format.h.
|
||||
|
||||
#include "fmt/std.h"
|
||||
#include "fmt/ranges.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "fmt/ranges.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
TEST(std_test, path) {
|
||||
@@ -77,3 +77,22 @@ TEST(std_test, variant) {
|
||||
EXPECT_EQ(fmt::format("{}", v5), "variant(\"yes, this is variant\")");
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(std_test, exception) {
|
||||
std::string str("Test Exception");
|
||||
std::string escstr = fmt::format("\"{}\"", str);
|
||||
|
||||
try {
|
||||
throw std::runtime_error(str);
|
||||
} catch (const std::exception& ex) {
|
||||
EXPECT_EQ(fmt::format("{}", ex), str);
|
||||
EXPECT_EQ(fmt::format("{:?}", ex), escstr);
|
||||
}
|
||||
|
||||
try {
|
||||
throw std::runtime_error(str);
|
||||
} catch (const std::runtime_error& ex) {
|
||||
EXPECT_EQ(fmt::format("{}", ex), str);
|
||||
EXPECT_EQ(fmt::format("{:?}", ex), escstr);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user