xref: /llvm-project/libcxx/test/std/time/time.zone/time.zone.db/time.zone.db.remote/reload_tzdb.pass.cpp (revision a4422a51941bfcffc870d1e2fff682e5387f89c2)
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 // Note there is no Standard way to change the remote database used.
18 // That is tested in
19 //   test/libcxx/time/time.zone/time.zone.db/time.zone.db.remote/reload_tzdb.pass.cpp
20 
21 // const tzdb& reload_tzdb();
22 
23 #include <cassert>
24 #include <chrono>
25 #include <iterator>
26 
27 #include "test_macros.h"
28 
main(int,const char **)29 int main(int, const char**) {
30   const std::chrono::tzdb_list& list = std::chrono::get_tzdb_list();
31   std::string version                = list.front().version;
32   assert(!version.empty());
33 
34   assert(std::distance(list.begin(), list.end()) == 1);
35   assert(std::distance(list.cbegin(), list.cend()) == 1);
36   assert(std::chrono::remote_version() == version);
37 
38   std::chrono::reload_tzdb();
39 
40   assert(std::distance(list.begin(), list.end()) == 1);
41   assert(std::distance(list.cbegin(), list.cend()) == 1);
42   assert(std::chrono::remote_version() == version);
43 
44   return 0;
45 }
46