]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/time_get/get/char/2.cc
1 // { dg-require-namedlocale "de_DE.UTF-8" }
2 // { dg-options " -std=gnu++11 " }
4 // 2014-04-14 RĂ¼diger Sonderfeld <ruediger@c-plusplus.de>
6 // Copyright (C) 2014-2015 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 #ifndef _GLIBCXX_ASSERT
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)
41 bool test
__attribute__((unused
)) = true;
43 locale loc_c
= locale::classic();
44 locale loc_de
= locale("de_DE.UTF-8");
45 VERIFY( loc_de
!= loc_c
);
49 const time_get
<char>& tget
= use_facet
<time_get
<char>>(iss
.getloc());
50 typedef istreambuf_iterator
<char> iter
;
53 ios_base::iostate err
;
56 TESTHEAD("German locale test");
57 iss
.str("Montag, den 14. April 2014");
58 string format
= "%A, den %d. %B %Y";
59 auto ret
= tget
.get(iter(iss
), end
, iss
, err
, &time
,
60 format
.data(), format
.data()+format
.size());
62 VERIFY(err
== ios_base::eofbit
);
64 VERIFY(time
.tm_year
== 114);
66 VERIFY(time
.tm_mon
== 3);
68 VERIFY(time
.tm_wday
== 1);
70 VERIFY(time
.tm_mday
== 14);
73 TESTHEAD("German locale: Check case-insensitivity");
75 iss
.str("Montag, den 14. April 2014");
76 format
= "%A, DEN %d. %B %Y"; // check case-insensitivity
77 ret
= tget
.get(iter(iss
), end
, iss
, err
, &time2
,
78 format
.data(), format
.data()+format
.size());
80 VERIFY(err
== ios_base::eofbit
);
82 VERIFY(time2
.tm_year
== 114);
84 VERIFY(time2
.tm_mon
== 3);
86 VERIFY(time2
.tm_wday
== 1);
88 VERIFY(time2
.tm_mday
== 14);
91 TESTHEAD("German locale: Check single");
93 ret
= tget
.get(iter(iss
), end
, iss
, err
, &time
, 'A');
95 VERIFY(err
== ios_base::eofbit
);
97 VERIFY(time
.tm_wday
== 3);