]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/22_locale/time_get/get/wchar_t/71367.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 22_locale / time_get / get / wchar_t / 71367.cc
CommitLineData
982a2c9b
JJ
1// { dg-do run { target c++11 } }
2
a945c346 3// Copyright (C) 2021-2024 Free Software Foundation, Inc.
982a2c9b
JJ
4//
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)
9// any later version.
10
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.
15
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/>.
19
20#include <locale>
21#include <sstream>
22#include <iterator>
23#include <testsuite_hooks.h>
24
25void
26test01()
27{
28 using namespace std;
29
30 locale loc_c = locale::classic();
31
32 wistringstream iss;
33 iss.imbue(loc_c);
34 const time_get<wchar_t>& tget = use_facet<time_get<wchar_t>>(iss.getloc());
35 typedef istreambuf_iterator<wchar_t> iter;
36 const iter end;
37
38 tm time;
39 ios_base::iostate err = ios_base::badbit;
40
41 iss.str(L"01:38:12 PM");
42 wstring format = L"%I:%M:%S %p";
43 auto ret = tget.get(iter(iss), end, iss, err, &time,
44 format.data(), format.data()+format.size());
45 VERIFY( err == ios_base::eofbit );
46 VERIFY( ret == end );
47 VERIFY( time.tm_hour == 13 );
48 VERIFY( time.tm_min == 38 );
49 VERIFY( time.tm_sec == 12 );
50
51 iss.str(L"11:17:42 PM");
52 format = L"%r";
53 ret = tget.get(iter(iss), end, iss, err, &time,
54 format.data(), format.data()+format.size());
55 VERIFY( err == ios_base::eofbit );
56 VERIFY( ret == end );
57 VERIFY( time.tm_hour == 23 );
58 VERIFY( time.tm_min == 17 );
59 VERIFY( time.tm_sec == 42 );
60}
61
62int
63main()
64{
65 test01();
66 return 0;
67}