| 1 |
// { dg-options "-g -O0 -std=gnu++2a" } |
| 2 |
// { dg-do run { target c++2a } } |
| 3 |
// { dg-additional-options "-DTEST_ZONED_TIME" { target tzdb } } |
| 4 |
|
| 5 |
// Copyright The GNU Toolchain Authors. |
| 6 |
// |
| 7 |
// This file is part of the GNU ISO C++ Library. This library is free |
| 8 |
// software; you can redistribute it and/or modify it under the |
| 9 |
// terms of the GNU General Public License as published by the |
| 10 |
// Free Software Foundation; either version 3, or (at your option) |
| 11 |
// any later version. |
| 12 |
|
| 13 |
// This library is distributed in the hope that it will be useful, |
| 14 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
// GNU General Public License for more details. |
| 17 |
|
| 18 |
// You should have received a copy of the GNU General Public License along |
| 19 |
// with this library; see the file COPYING3. If not see |
| 20 |
// <http://www.gnu.org/licenses/>. |
| 21 |
|
| 22 |
#include <chrono> |
| 23 |
#include <iostream> |
| 24 |
|
| 25 |
int |
| 26 |
main() |
| 27 |
{ |
| 28 |
using namespace std::chrono; |
| 29 |
|
| 30 |
seconds just_a_sec(1); |
| 31 |
// { dg-final { note-test just_a_sec {std::chrono::duration = { 1s }} } } |
| 32 |
microseconds just_a_moment(5001); |
| 33 |
// { dg-final { note-test just_a_moment {std::chrono::duration = { 5001us }} } } |
| 34 |
duration<float, std::ratio<22, 7>> pie(2.72f); |
| 35 |
// { dg-final { note-test pie {std::chrono::duration = { 2.72[22/7]s }} } } |
| 36 |
|
| 37 |
sys_seconds half_past_epoch(1800s); |
| 38 |
// { dg-final { note-test half_past_epoch {std::chrono::sys_time = { 1800s [1970-01-01 00:30:00] }} } } |
| 39 |
utc_time utc(467664h); |
| 40 |
// { dg-final { note-test utc {std::chrono::utc_time = { 467664h }} } } |
| 41 |
|
| 42 |
#if _GLIBCXX_USE_CXX11_ABI && defined TEST_ZONED_TIME |
| 43 |
zoned_time<milliseconds> zt("Europe/London", half_past_epoch); |
| 44 |
// { dg-final { note-test zt {std::chrono::zoned_time = { "Europe/London" 1800000ms [1970-01-01 00:30:00] }} { target cxx11_abi } } } |
| 45 |
#endif |
| 46 |
|
| 47 |
[[maybe_unused]] day ninth(9); |
| 48 |
// { dg-final { note-test ninth {9} } } |
| 49 |
[[maybe_unused]] month may = May; |
| 50 |
// { dg-final { note-test may {May} } } |
| 51 |
auto twentytwentythree = 2023y; |
| 52 |
// { dg-final { note-test twentytwentythree {2023y} } } |
| 53 |
[[maybe_unused]] weekday tues = Tuesday; |
| 54 |
// { dg-final { note-test tues {Tuesday} } } |
| 55 |
[[maybe_unused]] weekday_indexed second_tues = Tuesday[2]; |
| 56 |
// { dg-final { note-test second_tues {Tuesday[2]} } } |
| 57 |
[[maybe_unused]] weekday_last last_tues = Tuesday[last]; |
| 58 |
// { dg-final { note-test last_tues {Tuesday[last]} } } |
| 59 |
[[maybe_unused]] month_day midsummer = June/21; |
| 60 |
// { dg-final { note-test midsummer {June/21} } } |
| 61 |
[[maybe_unused]] month_day_last end_jan = January/last; |
| 62 |
// { dg-final { note-test end_jan {January/last} } } |
| 63 |
[[maybe_unused]] month_weekday handsel = January/Monday[1]; |
| 64 |
// { dg-final { note-test handsel {January/Monday[1]} } } |
| 65 |
[[maybe_unused]] month_weekday_last reek = July/Sunday[last]; |
| 66 |
// { dg-final { note-test reek {July/Sunday[last]} } } |
| 67 |
[[maybe_unused]] year_month feb_2023 = 2023y/February; |
| 68 |
// { dg-final { note-test feb_2023 {2023y/February} } } |
| 69 |
[[maybe_unused]] year_month_day barbican = September/17/1997y; |
| 70 |
// { dg-final { note-test barbican {1997y/September/17} } } |
| 71 |
[[maybe_unused]] year_month_day_last party_like = 1999y/December/last; |
| 72 |
// { dg-final { note-test party_like {1999y/December/last} } } |
| 73 |
[[maybe_unused]] year_month_weekday easter = 2023y/April/Sunday[2]; |
| 74 |
// { dg-final { note-test easter {2023y/April/Sunday[2]} } } |
| 75 |
[[maybe_unused]] year_month_weekday_last donnerstag = 2017y/July/Thursday[last]; |
| 76 |
// { dg-final { note-test donnerstag {2017y/July/Thursday[last]} } } |
| 77 |
|
| 78 |
[[maybe_unused]] month nam(13); |
| 79 |
// { dg-final { note-test nam {13 is not a valid month} } } |
| 80 |
[[maybe_unused]] month nam0(0); |
| 81 |
// { dg-final { note-test nam0 {0 is not a valid month} } } |
| 82 |
[[maybe_unused]] weekday nawd(8); |
| 83 |
// { dg-final { note-test nawd {8 is not a valid weekday} } } |
| 84 |
// |
| 85 |
hh_mm_ss<seconds> hms(4h + 3min + 2s); |
| 86 |
// { dg-final { note-test hms {04:03:02} } } |
| 87 |
|
| 88 |
hh_mm_ss<nanoseconds> hms_nano(-14h - 13min - 12s - 11ns); |
| 89 |
// { dg-final { note-test hms_nano {-14:13:12.000000011} } } |
| 90 |
|
| 91 |
std::cout << "\n"; |
| 92 |
return 0; // Mark SPOT |
| 93 |
} |
| 94 |
|
| 95 |
// { dg-final { gdb-test SPOT } } |