From 8e0ca0589fb76def40b5a212a91bbbd074bd1f48 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 8 Oct 2023 08:45:37 -0700 Subject: [PATCH] Use a more sensible locale in tests --- test/chrono-test.cc | 17 ++++++++--------- test/util.cc | 3 +-- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/test/chrono-test.cc b/test/chrono-test.cc index c218a873dae1..077606887095 100644 --- a/test/chrono-test.cc +++ b/test/chrono-test.cc @@ -743,21 +743,20 @@ TEST(chrono_test, unsigned_duration) { } TEST(chrono_test, weekday) { - auto loc = get_locale("ru_RU.UTF-8"); + auto loc = get_locale("es_ES.UTF-8"); std::locale::global(loc); - auto mon = fmt::weekday(1); + auto sat = fmt::weekday(6); auto tm = std::tm(); - tm.tm_wday = static_cast(mon.c_encoding()); + tm.tm_wday = static_cast(sat.c_encoding()); - EXPECT_EQ(fmt::format("{}", mon), "Mon"); - EXPECT_EQ(fmt::format("{:%a}", tm), "Mon"); + EXPECT_EQ(fmt::format("{}", sat), "Sat"); + EXPECT_EQ(fmt::format("{:%a}", tm), "Sat"); if (loc != std::locale::classic()) { - EXPECT_THAT((std::vector{"пн", "Пн", "пнд", "Пнд"}), - Contains(fmt::format(loc, "{:L}", mon))); - EXPECT_THAT((std::vector{"пн", "Пн", "пнд", "Пнд"}), - Contains(fmt::format(loc, "{:%a}", tm))); + auto saturdays = std::vector{"sáb", "sá."}; + EXPECT_THAT(saturdays, Contains(fmt::format(loc, "{:L}", sat))); + EXPECT_THAT(saturdays, Contains(fmt::format(loc, "{:%a}", tm))); } } diff --git a/test/util.cc b/test/util.cc index f4cb74ca0a8c..4ff34a91d705 100644 --- a/test/util.cc +++ b/test/util.cc @@ -37,9 +37,8 @@ std::locale do_get_locale(const char* name) { std::locale get_locale(const char* name, const char* alt_name) { auto loc = do_get_locale(name); - if (loc == std::locale::classic() && alt_name) { + if (loc == std::locale::classic() && alt_name) loc = do_get_locale(alt_name); - } if (loc == std::locale::classic()) fmt::print(stderr, "{} locale is missing.\n", name); return loc;