Use kAudioObjectPropertyElementMaster on macOS for compatibility
[openal-soft.git] / fmt-11.0.2 / test / unicode-test.cc
blob07b7eb3535ee9e4283c61550bf1cc8392e607750
1 // Formatting library for C++ - Unicode tests
2 //
3 // Copyright (c) 2012 - present, Victor Zverovich
4 // All rights reserved.
5 //
6 // For the license information refer to format.h.
8 #include <iomanip>
9 #include <locale>
10 #include <vector>
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();
25 try {
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());
30 return;
33 #if !FMT_GCC_VERSION || FMT_GCC_VERSION >= 500
34 auto&& os = std::ostringstream();
35 os.imbue(loc);
36 auto tm = std::tm();
37 tm.tm_wday = 1;
38 os << std::put_time(&tm, "%a");
39 auto wd = os.str();
40 if (wd == "??") {
41 EXPECT_EQ(s, "Дзень тыдня: ??");
42 fmt::print("std::locale gives ?? as a weekday.\n");
43 return;
45 #endif
46 EXPECT_THAT((std::vector<std::string>{"Дзень тыдня: пн", "Дзень тыдня: Пан"}),
47 Contains(s));