[CodeGen][NewPM] Port GCNPreRALongBranchReg to NPM. (#125844)
[llvm-project.git] / libcxx / test / std / time / time.cal / time.cal.day / time.cal.day.nonmembers / ostream.pass.cpp
blobf75ff130a09c4b2844007d3387d88ea5be92da3f
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
10 // UNSUPPORTED: no-localization
11 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
13 // TODO FMT This test should not require std::to_chars(floating-point)
14 // XFAIL: availability-fp_to_chars-missing
16 // REQUIRES: locale.fr_FR.UTF-8
17 // REQUIRES: locale.ja_JP.UTF-8
19 // <chrono>
20 // class day;
22 // template<class charT, class traits>
23 // basic_ostream<charT, traits>&
24 // operator<<(basic_ostream<charT, traits>& os, const day& d);
26 #include <chrono>
27 #include <cassert>
28 #include <sstream>
30 #include "make_string.h"
31 #include "platform_support.h" // locale name macros
32 #include "test_macros.h"
34 #define SV(S) MAKE_STRING_VIEW(CharT, S)
36 template <class CharT>
37 static std::basic_string<CharT> stream_c_locale(std::chrono::day day) {
38 std::basic_stringstream<CharT> sstr;
39 sstr << day;
40 return sstr.str();
43 template <class CharT>
44 static std::basic_string<CharT> stream_fr_FR_locale(std::chrono::day day) {
45 std::basic_stringstream<CharT> sstr;
46 const std::locale locale(LOCALE_fr_FR_UTF_8);
47 sstr.imbue(locale);
48 sstr << day;
49 return sstr.str();
52 template <class CharT>
53 static std::basic_string<CharT> stream_ja_JP_locale(std::chrono::day day) {
54 std::basic_stringstream<CharT> sstr;
55 const std::locale locale(LOCALE_ja_JP_UTF_8);
56 sstr.imbue(locale);
57 sstr << day;
58 return sstr.str();
61 template <class CharT>
62 static void test() {
63 using namespace std::literals::chrono_literals;
65 assert(stream_c_locale<CharT>(0d) == SV("00 is not a valid day"));
66 assert(stream_c_locale<CharT>(1d) == SV("01"));
67 assert(stream_c_locale<CharT>(31d) == SV("31"));
68 assert(stream_c_locale<CharT>(255d) == SV("255 is not a valid day"));
70 assert(stream_fr_FR_locale<CharT>(0d) == SV("00 is not a valid day"));
71 assert(stream_fr_FR_locale<CharT>(1d) == SV("01"));
72 assert(stream_fr_FR_locale<CharT>(31d) == SV("31"));
73 assert(stream_fr_FR_locale<CharT>(255d) == SV("255 is not a valid day"));
75 assert(stream_ja_JP_locale<CharT>(0d) == SV("00 is not a valid day"));
76 assert(stream_ja_JP_locale<CharT>(1d) == SV("01"));
77 assert(stream_ja_JP_locale<CharT>(31d) == SV("31"));
78 assert(stream_ja_JP_locale<CharT>(255d) == SV("255 is not a valid day"));
81 int main(int, char**) {
82 using namespace std::literals::chrono_literals;
84 test<char>();
85 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
86 test<wchar_t>();
87 #endif
89 return 0;