Add initial support for weekday formatting

This commit is contained in:
Victor Zverovich
2021-05-24 07:23:56 -07:00
parent 069131dc25
commit 1cd9899cf3
6 changed files with 157 additions and 33 deletions

View File

@@ -5,7 +5,25 @@
//
// For the license information refer to format.h.
#include "fmt/core.h"
#include "gtest/gtest.h"
#include <vector>
TEST(unicode_test, is_utf8) { EXPECT_TRUE(fmt::detail::is_utf8()); }
#include "fmt/chrono.h"
#include "gmock/gmock.h"
#include "util.h" // get_locale
using testing::Contains;
TEST(unicode_test, is_utf8) { EXPECT_TRUE(fmt::detail::is_utf8()); }
TEST(unicode_test, legacy_locale) {
auto loc = get_locale("ru_RU.CP1251");
if (loc == std::locale::classic()) return;
try {
EXPECT_THAT(
(std::vector<std::string>{"День недели: пн", "День недели: Пн"}),
Contains(fmt::format(loc, "День недели: {:L}", fmt::weekday(1))));
} catch (const fmt::format_error& e) {
// Formatting can fail due to unsupported encoding.
fmt::print("Format error: {}\n", e.what());
}
}