| 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 |
//===----------------------------------------------------------------------===// |
| 8 |
|
| 9 |
// UNSUPPORTED: c++03, c++11, c++14, c++17 |
| 10 |
// UNSUPPORTED: no-localization |
| 11 |
|
| 12 |
// TODO FMT This test should not require std::to_chars(floating-point) |
| 13 |
// XFAIL: availability-fp_to_chars-missing |
| 14 |
|
| 15 |
// XFAIL: libcpp-has-no-experimental-tzdb |
| 16 |
|
| 17 |
// <chrono> |
| 18 |
|
| 19 |
// template<class charT, class traits> |
| 20 |
// basic_ostream<charT, traits>& |
| 21 |
// operator<<(basic_ostream<charT, traits>& os, const local_info& r); |
| 22 |
|
| 23 |
// [time.zone.info.local] |
| 24 |
// 3 Effects: Streams out the local_info object r in an unspecified format. |
| 25 |
// 4 Returns: os. |
| 26 |
// |
| 27 |
// There is a private libc++ test that validates the exact output. |
| 28 |
|
| 29 |
#include <cassert> |
| 30 |
#include <chrono> |
| 31 |
#include <memory> |
| 32 |
#include <sstream> |
| 33 |
|
| 34 |
#include "test_macros.h" |
| 35 |
|
| 36 |
template <class CharT> |
| 37 |
static void test() { |
| 38 |
using namespace std::literals::chrono_literals; |
| 39 |
std::chrono::sys_info s{std::chrono::sys_seconds{0s}, std::chrono::sys_seconds{0s}, 0h, 0min, ""}; |
| 40 |
std::chrono::local_info l{0, s, s}; |
| 41 |
std::basic_ostringstream<CharT> os; |
| 42 |
std::basic_ostream<CharT>& result = std::chrono::operator<<(os, l); |
| 43 |
assert(std::addressof(result) == std::addressof(os)); |
| 44 |
} |
| 45 |
|
| 46 |
int main(int, const char**) { |
| 47 |
test<char>(); |
| 48 |
#ifndef TEST_HAS_NO_WIDE_CHARACTERS |
| 49 |
test<wchar_t>(); |
| 50 |
#endif |
| 51 |
|
| 52 |
return 0; |
| 53 |
} |