Merge from mainline (163495:164578).
[official-gcc/graphite-test-results.git] / libstdc++-v3 / testsuite / 22_locale / time_get / get_weekday / wchar_t / 2.cc
blobdbab614d16552055de13077929057941d8676100
1 // { dg-require-namedlocale "en_HK" }
2 // { dg-require-namedlocale "de_DE" }
4 // 2001-09-21 Benjamin Kosnik <bkoz@redhat.com>
6 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2009
7 // Free Software Foundation
8 //
9 // This file is part of the GNU ISO C++ Library. This library is free
10 // software; you can redistribute it and/or modify it under the
11 // terms of the GNU General Public License as published by the
12 // Free Software Foundation; either version 3, or (at your option)
13 // any later version.
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
20 // You should have received a copy of the GNU General Public License along
21 // with this library; see the file COPYING3. If not see
22 // <http://www.gnu.org/licenses/>.
24 // 22.2.5.1.1 time_get members
26 #include <locale>
27 #include <sstream>
28 #include <testsuite_hooks.h>
30 void test02()
32 using namespace std;
33 bool test __attribute__((unused)) = true;
35 typedef istreambuf_iterator<wchar_t> iterator_type;
37 // basic construction and sanity checks.
38 locale loc_c = locale::classic();
39 locale loc_hk = locale("en_HK");
40 locale loc_de = locale("de_DE");
41 VERIFY( loc_hk != loc_c );
42 VERIFY( loc_hk != loc_de );
44 const wstring empty;
46 // create an ostream-derived object, cache the time_get facet
47 iterator_type end;
49 wistringstream iss;
50 const time_get<wchar_t>& tim_get = use_facet<time_get<wchar_t> >(iss.getloc());
52 const ios_base::iostate good = ios_base::goodbit;
53 ios_base::iostate errorstate = good;
55 // create "C" time objects
56 const tm time_bday = __gnu_test::test_tm(0, 0, 12, 4, 3, 71, 0, 93, 0);
58 // inspection of named locales, de_DE
59 iss.imbue(loc_de);
60 iss.str(L"Sonntag");
61 iterator_type is_it10(iss);
62 tm time10;
63 errorstate = good;
64 tim_get.get_weekday(is_it10, end, iss, errorstate, &time10);
65 VERIFY( time10.tm_wday == time_bday.tm_wday );
66 VERIFY( errorstate == ios_base::eofbit );
68 // inspection of named locales, en_HK
69 iss.imbue(loc_hk);
70 iss.str(L"Sunday");
71 iterator_type is_it20(iss);
72 tm time20;
73 errorstate = good;
74 tim_get.get_weekday(is_it20, end, iss, errorstate, &time20);
75 VERIFY( time20.tm_wday == time_bday.tm_wday );
76 VERIFY( errorstate == ios_base::eofbit );
79 int main()
81 test02();
82 return 0;