Merge from mainline (163495:164578).
[official-gcc/graphite-test-results.git] / libstdc++-v3 / testsuite / 22_locale / time_get / get_weekday / char / 38081-2.cc
blob1c079a400174221ab0196a297f62492250b981db
1 // { dg-require-namedlocale "ru_RU.UTF8" }
3 // 2010-01-05 Paolo Carlini <paolo.carlini@oracle.com>
5 // Copyright (C) 2010 Free Software Foundation
6 //
7 // This file is part of the GNU ISO C++ Library. This library is free
8 // software; you can redistribute it and/or modify it under the
9 // terms of the GNU General Public License as published by the
10 // Free Software Foundation; either version 3, or (at your option)
11 // any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License along
19 // with this library; see the file COPYING3. If not see
20 // <http://www.gnu.org/licenses/>.
22 // 22.2.5.1.1 time_get members
24 #include <locale>
25 #include <sstream>
26 #include <cstring>
27 #include <testsuite_hooks.h>
29 void test01()
31 using namespace std;
32 bool test __attribute__((unused)) = true;
34 typedef istreambuf_iterator<char> iterator_type;
36 // basic construction
37 locale loc("ru_RU.UTF8");
39 // create an ostream-derived object, cache the time_get facet
40 iterator_type end;
42 istringstream iss;
43 iss.imbue(loc);
44 const time_get<char>& tim_get = use_facet<time_get<char> >(iss.getloc());
46 const ios_base::iostate good = ios_base::goodbit;
47 ios_base::iostate errorstate = good;
49 // iter_type
50 // get_weekday(iter_type, iter_type, ios_base&,
51 // ios_base::iostate&, tm*) const
53 const char* awdays[7] = { "\u0412\u0441\u043A",
54 "\u041F\u043D\u0434",
55 "\u0412\u0442\u0440",
56 "\u0421\u0440\u0434",
57 "\u0427\u0442\u0432",
58 "\u041F\u0442\u043D",
59 "\u0421\u0431\u0442" };
61 for (int i = 0; i < 7; ++i)
63 iss.str(awdays[i]);
64 iterator_type is_it01(iss);
65 tm time01;
66 memset(&time01, -1, sizeof(tm));
67 errorstate = good;
68 tim_get.get_weekday(is_it01, end, iss, errorstate, &time01);
69 VERIFY( time01.tm_wday == i );
70 VERIFY( errorstate == ios_base::eofbit );
73 const char* wdays[7] = { "\u0412\u043E\u0441\u043A\u0440\u0435"
74 "\u0441\u0435\u043D\u044C\u0435",
75 "\u041F\u043E\u043D\u0435\u0434\u0435"
76 "\u043B\u044C\u043D\u0438\u043A",
77 "\u0412\u0442\u043E\u0440\u043D\u0438\u043A",
78 "\u0421\u0440\u0435\u0434\u0430",
79 "\u0427\u0435\u0442\u0432\u0435\u0440\u0433",
80 "\u041F\u044F\u0442\u043D\u0438\u0446\u0430",
81 "\u0421\u0443\u0431\u0431\u043E\u0442\u0430" };
83 for (int i = 0; i < 7; ++i)
85 iss.str(wdays[i]);
86 iterator_type is_it01(iss);
87 tm time01;
88 memset(&time01, -1, sizeof(tm));
89 errorstate = good;
90 tim_get.get_weekday(is_it01, end, iss, errorstate, &time01);
91 VERIFY( time01.tm_wday == i );
92 VERIFY( errorstate == ios_base::eofbit );
96 int main()
98 test01();
99 return 0;