Debian Codegraph @

libstdc++-v3/testsuite/std/time/parse/125369.cc

raw
1 // { dg-do run { target c++20 } }
2
3 #include <chrono>
4 #include <sstream>
5 #include <testsuite_hooks.h>
6
7 using namespace std::chrono;
8
9 const std::string input = "2026-05-18 15:26:48 ";
10 const std::string fmt = "%F %T %";
11 sys_seconds ss;
12 minutes offset{};
13 std::string abbrev;
14
15 void
16 test_parse_z()
17 {
18 for (auto suffix : {"Z", "+", "+Z", "-A", "+1Z", "+010", "+010Z"})
19 {
20 std::istringstream in{input + suffix};
21 from_stream(in, (fmt + "z").c_str(), ss, &abbrev, &offset);
22
23 VERIFY( in.fail() );
24 VERIFY( ss == sys_seconds(0s) );
25 VERIFY( offset == 0min );
26 VERIFY( abbrev.empty() );
27 }
28 }
29
30 void
31 test_parse_Ez()
32 {
33 for (auto suffix : {"Z", "+", "-", "+01:", "+01:X"})
34 {
35 std::istringstream in{input + suffix};
36 from_stream(in, (fmt + "Ez").c_str(), ss, &abbrev, &offset);
37
38 VERIFY( in.fail() );
39 VERIFY( ss == sys_seconds(0s) );
40 VERIFY( offset == 0min );
41 VERIFY( abbrev.empty() );
42 }
43 }
44
45 void
46 test_parse_Oz()
47 {
48 for (auto suffix : {"Z", "+", "-", "+01:", "+01:X"})
49 {
50 std::istringstream in{input + suffix};
51 from_stream(in, (fmt + "Oz").c_str(), ss, &abbrev, &offset);
52
53 VERIFY( in.fail() );
54 VERIFY( ss == sys_seconds(0s) );
55 VERIFY( offset == 0min );
56 VERIFY( abbrev.empty() );
57 }
58 }
59
60 int main()
61 {
62 test_parse_z();
63 test_parse_Ez();
64 test_parse_Oz();
65 }