]> git.proxmox.com Git - ceph.git/blame - ceph/src/seastar/fmt/test/locale-test.cc
update download target update for octopus release
[ceph.git] / ceph / src / seastar / fmt / test / locale-test.cc
CommitLineData
eafe8130
TL
1// Formatting library for C++ - locale tests
2//
3// Copyright (c) 2012 - present, Victor Zverovich
4// All rights reserved.
5//
6// For the license information refer to format.h.
7
8#include "fmt/locale.h"
9#include "gmock.h"
10
11template <typename Char>
12struct numpunct : std::numpunct<Char> {
13 protected:
14 Char do_thousands_sep() const FMT_OVERRIDE { return '~'; }
15};
16
17TEST(LocaleTest, Format) {
18 std::locale loc(std::locale(), new numpunct<char>());
19 EXPECT_EQ("1,234,567", fmt::format(std::locale(), "{:n}", 1234567));
20 EXPECT_EQ("1~234~567", fmt::format(loc, "{:n}", 1234567));
21 fmt::format_arg_store<fmt::format_context, int> as{1234567};
22 EXPECT_EQ("1~234~567", fmt::vformat(loc, "{:n}", fmt::format_args(as)));
23 std::string s;
24 fmt::format_to(std::back_inserter(s), loc, "{:n}", 1234567);
25 EXPECT_EQ("1~234~567", s);
26}
27
28TEST(LocaleTest, WFormat) {
29 std::locale loc(std::locale(), new numpunct<wchar_t>());
30 EXPECT_EQ(L"1,234,567", fmt::format(std::locale(), L"{:n}", 1234567));
31 EXPECT_EQ(L"1~234~567", fmt::format(loc, L"{:n}", 1234567));
32 fmt::format_arg_store<fmt::wformat_context, int> as{1234567};
33 EXPECT_EQ(L"1~234~567", fmt::vformat(loc, L"{:n}", fmt::wformat_args(as)));
34}