mirror of
https://github.com/fmtlib/fmt.git
synced 2025-10-28 12:41:42 +01:00
Improve locale support
This commit is contained in:
@@ -89,6 +89,7 @@ add_fmt_test(core-test)
|
||||
add_fmt_test(gtest-extra-test)
|
||||
add_fmt_test(format-test mock-allocator.h)
|
||||
add_fmt_test(format-impl-test)
|
||||
add_fmt_test(locale-test)
|
||||
add_fmt_test(ostream-test)
|
||||
add_fmt_test(printf-test)
|
||||
add_fmt_test(time-test)
|
||||
|
||||
@@ -603,17 +603,6 @@ TEST(StringViewTest, Ctor) {
|
||||
EXPECT_EQ(4u, string_view(std::string("defg")).size());
|
||||
}
|
||||
|
||||
// GCC 4.6 doesn't have std::is_copy_*.
|
||||
#if FMT_GCC_VERSION && FMT_GCC_VERSION >= 407
|
||||
TEST(WriterTest, NotCopyConstructible) {
|
||||
EXPECT_FALSE(std::is_copy_constructible<fmt::writer>::value);
|
||||
}
|
||||
|
||||
TEST(WriterTest, NotCopyAssignable) {
|
||||
EXPECT_FALSE(std::is_copy_assignable<fmt::writer>::value);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(WriterTest, Data) {
|
||||
memory_buffer buf;
|
||||
fmt::writer w(buf);
|
||||
@@ -1947,7 +1936,7 @@ class mock_arg_formatter:
|
||||
typedef buffer_range range;
|
||||
|
||||
mock_arg_formatter(fmt::format_context &ctx, fmt::format_specs *s = FMT_NULL)
|
||||
: base(fmt::internal::get_container(ctx.out()), s) {
|
||||
: base(fmt::internal::get_container(ctx.out()), s, ctx.locale()) {
|
||||
EXPECT_CALL(*this, call(42));
|
||||
}
|
||||
|
||||
|
||||
21
test/locale-test.cc
Normal file
21
test/locale-test.cc
Normal file
@@ -0,0 +1,21 @@
|
||||
// Formatting library for C++ - core tests
|
||||
//
|
||||
// Copyright (c) 2012 - present, Victor Zverovich
|
||||
// All rights reserved.
|
||||
//
|
||||
// For the license information refer to format.h.
|
||||
|
||||
#include "fmt/locale.h"
|
||||
#include "gmock.h"
|
||||
|
||||
struct numpunct : std::numpunct<char> {
|
||||
protected:
|
||||
char do_thousands_sep() const FMT_OVERRIDE { return '~'; }
|
||||
};
|
||||
|
||||
TEST(LocaleTest, Format) {
|
||||
std::locale loc;
|
||||
EXPECT_EQ("1~234~567",
|
||||
fmt::format(std::locale(loc, new numpunct()), "{:n}", 1234567));
|
||||
EXPECT_EQ("1,234,567", fmt::format(loc, "{:n}", 1234567));
|
||||
}
|
||||
Reference in New Issue
Block a user