aboutsummaryrefslogtreecommitdiff
path: root/test/ostream-test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/ostream-test.cc')
-rw-r--r--test/ostream-test.cc19
1 files changed, 18 insertions, 1 deletions
diff --git a/test/ostream-test.cc b/test/ostream-test.cc
index b2d15466..98ee0757 100644
--- a/test/ostream-test.cc
+++ b/test/ostream-test.cc
@@ -17,7 +17,7 @@ struct test {};
// included after fmt/format.h.
namespace fmt {
template <> struct formatter<test> : formatter<int> {
- auto format(const test&, format_context& ctx) -> decltype(ctx.out()) {
+ auto format(const test&, format_context& ctx) const -> decltype(ctx.out()) {
return formatter<int>::format(42, ctx);
}
};
@@ -289,3 +289,20 @@ TEST(ostream_test, closed_ofstream) {
std::ofstream ofs;
fmt::print(ofs, "discard");
}
+
+struct unlocalized {};
+
+auto operator<<(std::ostream& os, unlocalized)
+ -> std::ostream& {
+ return os << 12345;
+}
+
+namespace fmt {
+template <> struct formatter<unlocalized> : ostream_formatter {};
+} // namespace fmt
+
+TEST(ostream_test, unlocalized) {
+ auto loc = get_locale("en_US.UTF-8");
+ std::locale::global(loc);
+ EXPECT_EQ(fmt::format(loc, "{}", unlocalized()), "12345");
+}