| 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-filesystem, no-localization, no-tzdb |
| 11 |
|
| 12 |
// XFAIL: libcpp-has-no-experimental-tzdb |
| 13 |
// XFAIL: availability-tzdb-missing |
| 14 |
|
| 15 |
// <chrono> |
| 16 |
|
| 17 |
// template<> struct zoned_traits<const time_zone*>; |
| 18 |
|
| 19 |
// static const time_zone* locate_zone(string_view name); |
| 20 |
|
| 21 |
#include <chrono> |
| 22 |
#include <cassert> |
| 23 |
#include <concepts> |
| 24 |
#include <string_view> |
| 25 |
|
| 26 |
#include "assert_macros.h" |
| 27 |
|
| 28 |
static void test(std::string_view name) { |
| 29 |
std::same_as<const std::chrono::time_zone*> decltype(auto) tz = |
| 30 |
std::chrono::zoned_traits<const std::chrono::time_zone*>::locate_zone(name); |
| 31 |
|
| 32 |
const std::chrono::time_zone* expected = std::chrono::locate_zone(name); |
| 33 |
assert(tz == expected); |
| 34 |
} |
| 35 |
|
| 36 |
int main(int, char**) { |
| 37 |
test("UTC"); |
| 38 |
test("Europe/Berlin"); |
| 39 |
test("Asia/Hong_Kong"); |
| 40 |
|
| 41 |
TEST_THROWS_TYPE(std::runtime_error, |
| 42 |
TEST_IGNORE_NODISCARD std::chrono::zoned_traits<const std::chrono::time_zone*>::locate_zone( |
| 43 |
"there_is_no_time_zone_with_this_name")); |
| 44 |
|
| 45 |
return 0; |
| 46 |
} |