]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/time_get/get/char/2.cc
1 // { dg-do run { target c++11 } }
2 // { dg-require-namedlocale "de_DE.UTF-8" }
4 // 2014-04-14 RĂ¼diger Sonderfeld <ruediger@c-plusplus.de>
6 // Copyright (C) 2014-2024 Free Software Foundation, Inc.
8 // This file is part of the GNU ISO C++ Library. This library is free
9 // software; you can redistribute it and/or modify it under the
10 // terms of the GNU General Public License as published by the
11 // Free Software Foundation; either version 3, or (at your option)
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
19 // You should have received a copy of the GNU General Public License along
20 // with this library; see the file COPYING3. If not see
21 // <http://www.gnu.org/licenses/>.
23 // 22.4.5.1.1 (C++11) time_get members [locale.time.get.members]
27 #include <testsuite_hooks.h>
29 #ifdef TEST_TIMEGET_VERBOSE
31 # define PRINT(x) cout << #x << ": " << x << endl
32 # define TESTHEAD(x) cout << x << endl
34 # define PRINT(x) do {} while(false)
35 # define TESTHEAD(x) do {} while(false)
42 locale loc_c
= locale::classic();
43 locale loc_de
= locale("de_DE.UTF-8");
44 VERIFY( loc_de
!= loc_c
);
48 const time_get
<char>& tget
= use_facet
<time_get
<char>>(iss
.getloc());
49 typedef istreambuf_iterator
<char> iter
;
52 ios_base::iostate err
;
55 TESTHEAD("German locale test");
56 iss
.str("Montag, den 14. April 2014");
57 string format
= "%A, den %d. %B %Y";
58 auto ret
= tget
.get(iter(iss
), end
, iss
, err
, &time
,
59 format
.data(), format
.data()+format
.size());
61 VERIFY(err
== ios_base::eofbit
);
63 VERIFY(time
.tm_year
== 114);
65 VERIFY(time
.tm_mon
== 3);
67 VERIFY(time
.tm_wday
== 1);
69 VERIFY(time
.tm_mday
== 14);
72 TESTHEAD("German locale: Check case-insensitivity");
74 iss
.str("Montag, den 14. April 2014");
75 format
= "%A, DEN %d. %B %Y"; // check case-insensitivity
76 ret
= tget
.get(iter(iss
), end
, iss
, err
, &time2
,
77 format
.data(), format
.data()+format
.size());
79 VERIFY(err
== ios_base::eofbit
);
81 VERIFY(time2
.tm_year
== 114);
83 VERIFY(time2
.tm_mon
== 3);
85 VERIFY(time2
.tm_wday
== 1);
87 VERIFY(time2
.tm_mday
== 14);
90 TESTHEAD("German locale: Check single");
92 ret
= tget
.get(iter(iss
), end
, iss
, err
, &time
, 'A');
94 VERIFY(err
== ios_base::eofbit
);
96 VERIFY(time
.tm_wday
== 3);