From 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 20:24:20 +0200 Subject: Adding upstream version 14.2.21. Signed-off-by: Daniel Baumann --- src/seastar/fmt/test/locale-test.cc | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/seastar/fmt/test/locale-test.cc (limited to 'src/seastar/fmt/test/locale-test.cc') diff --git a/src/seastar/fmt/test/locale-test.cc b/src/seastar/fmt/test/locale-test.cc new file mode 100644 index 00000000..83b0f316 --- /dev/null +++ b/src/seastar/fmt/test/locale-test.cc @@ -0,0 +1,34 @@ +// Formatting library for C++ - locale 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" + +template +struct numpunct : std::numpunct { + protected: + Char do_thousands_sep() const FMT_OVERRIDE { return '~'; } +}; + +TEST(LocaleTest, Format) { + std::locale loc(std::locale(), new numpunct()); + EXPECT_EQ("1,234,567", fmt::format(std::locale(), "{:n}", 1234567)); + EXPECT_EQ("1~234~567", fmt::format(loc, "{:n}", 1234567)); + fmt::format_arg_store as{1234567}; + EXPECT_EQ("1~234~567", fmt::vformat(loc, "{:n}", fmt::format_args(as))); + std::string s; + fmt::format_to(std::back_inserter(s), loc, "{:n}", 1234567); + EXPECT_EQ("1~234~567", s); +} + +TEST(LocaleTest, WFormat) { + std::locale loc(std::locale(), new numpunct()); + EXPECT_EQ(L"1,234,567", fmt::format(std::locale(), L"{:n}", 1234567)); + EXPECT_EQ(L"1~234~567", fmt::format(loc, L"{:n}", 1234567)); + fmt::format_arg_store as{1234567}; + EXPECT_EQ(L"1~234~567", fmt::vformat(loc, L"{:n}", fmt::wformat_args(as))); +} -- cgit v1.2.3