]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/time_get/get/wchar_t/71557.cc
1 // { dg-do run { target c++11 } }
3 // Copyright (C) 2021-2023 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
23 #include <testsuite_hooks.h>
30 locale loc_c
= locale::classic();
34 const time_get
<wchar_t>& tget
= use_facet
<time_get
<wchar_t>>(iss
.getloc());
35 typedef istreambuf_iterator
<wchar_t> iter
;
39 ios_base::iostate err
= ios_base::badbit
;
41 iss
.str(L
"20:48:01 MAR 31 2016");
42 wstring format
= L
"%H:%M:%S %b %d %Y";
43 auto ret
= tget
.get(iter(iss
), end
, iss
, err
, &time
,
44 format
.data(), format
.data()+format
.size());
45 VERIFY( err
== ios_base::eofbit
);
47 VERIFY( time
.tm_year
== 2016 - 1900 );
48 VERIFY( time
.tm_mon
== 2 );
49 VERIFY( time
.tm_mday
== 31 );
50 VERIFY( time
.tm_hour
== 20 );
51 VERIFY( time
.tm_min
== 48 );
52 VERIFY( time
.tm_sec
== 01 );
54 iss
.str(L
"21:38:11 apr 30 2017");
55 ret
= tget
.get(iter(iss
), end
, iss
, err
, &time
,
56 format
.data(), format
.data()+format
.size());
57 VERIFY( err
== ios_base::eofbit
);
59 VERIFY( time
.tm_year
== 2017 - 1900 );
60 VERIFY( time
.tm_mon
== 3 );
61 VERIFY( time
.tm_mday
== 30 );
62 VERIFY( time
.tm_hour
== 21 );
63 VERIFY( time
.tm_min
== 38 );
64 VERIFY( time
.tm_sec
== 11 );
66 iss
.str(L
"22:28:21 mAy 29 2018");
67 ret
= tget
.get(iter(iss
), end
, iss
, err
, &time
,
68 format
.data(), format
.data()+format
.size());
69 VERIFY( err
== ios_base::eofbit
);
71 VERIFY( time
.tm_year
== 2018 - 1900 );
72 VERIFY( time
.tm_mon
== 4 );
73 VERIFY( time
.tm_mday
== 29 );
74 VERIFY( time
.tm_hour
== 22 );
75 VERIFY( time
.tm_min
== 28 );
76 VERIFY( time
.tm_sec
== 21 );
78 iss
.str(L
"23:18:31 JuN 28 2019");
79 ret
= tget
.get(iter(iss
), end
, iss
, err
, &time
,
80 format
.data(), format
.data()+format
.size());
81 VERIFY( err
== ios_base::eofbit
);
83 VERIFY( time
.tm_year
== 2019 - 1900 );
84 VERIFY( time
.tm_mon
== 5 );
85 VERIFY( time
.tm_mday
== 28 );
86 VERIFY( time
.tm_hour
== 23 );
87 VERIFY( time
.tm_min
== 18 );
88 VERIFY( time
.tm_sec
== 31 );