1 // Formatting library for C++ - Unicode tests
3 // Copyright (c) 2012 - present, Victor Zverovich
4 // All rights reserved.
6 // For the license information refer to format.h.
12 #include "fmt/chrono.h"
13 #include "gmock/gmock.h"
14 #include "util.h" // get_locale
16 using testing::Contains
;
18 TEST(unicode_test
, use_utf8
) { EXPECT_TRUE(fmt::detail::use_utf8()); }
20 TEST(unicode_test
, legacy_locale
) {
21 auto loc
= get_locale("be_BY.CP1251", "Belarusian_Belarus.1251");
22 if (loc
== std::locale::classic()) return;
24 auto s
= std::string();
26 s
= fmt::format(loc
, "Дзень тыдня: {:L}", fmt::weekday(1));
27 } catch (const fmt::format_error
& e
) {
28 // Formatting can fail due to an unsupported encoding.
29 fmt::print("Format error: {}\n", e
.what());
33 #if !FMT_GCC_VERSION || FMT_GCC_VERSION >= 500
34 auto&& os
= std::ostringstream();
38 os
<< std::put_time(&tm
, "%a");
41 EXPECT_EQ(s
, "Дзень тыдня: ??");
42 fmt::print("std::locale gives ?? as a weekday.\n");
46 EXPECT_THAT((std::vector
<std::string
>{"Дзень тыдня: пн", "Дзень тыдня: Пан"}),