]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/38081-2.cc
Update copyright years in libstdc++-v3/
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 22_locale / time_get / get_weekday / char / 38081-2.cc
1 // { dg-require-namedlocale "ru_RU.UTF8" }
2
3 // 2010-01-05 Paolo Carlini <paolo.carlini@oracle.com>
4
5 // Copyright (C) 2010-2014 Free Software Foundation, Inc.
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.
12
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.
17
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/>.
21
22 // 22.2.5.1.1 time_get members
23
24 #include <locale>
25 #include <sstream>
26 #include <cstring>
27 #include <testsuite_hooks.h>
28
29 void test01()
30 {
31 using namespace std;
32 bool test __attribute__((unused)) = true;
33
34 typedef istreambuf_iterator<char> iterator_type;
35
36 // basic construction
37 locale loc("ru_RU.UTF8");
38
39 // create an ostream-derived object, cache the time_get facet
40 iterator_type end;
41
42 istringstream iss;
43 iss.imbue(loc);
44 const time_get<char>& tim_get = use_facet<time_get<char> >(iss.getloc());
45
46 const ios_base::iostate good = ios_base::goodbit;
47 ios_base::iostate errorstate = good;
48
49 // iter_type
50 // get_weekday(iter_type, iter_type, ios_base&,
51 // ios_base::iostate&, tm*) const
52
53 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 14)
54 # if __GLIBC__ > 2 || __GLIBC_MINOR__ >= 17
55 const char* awdays[7] = { "\u0412\u0441",
56 "\u041F\u043D",
57 "\u0412\u0442",
58 "\u0421\u0440",
59 "\u0427\u0442",
60 "\u041F\u0442",
61 "\u0421\u0431" };
62 # else
63 const char* awdays[7] = { "\u0412\u0441\u002E",
64 "\u041F\u043D\u002E",
65 "\u0412\u0442\u002E",
66 "\u0421\u0440\u002E",
67 "\u0427\u0442\u002E",
68 "\u041F\u0442\u002E",
69 "\u0421\u0431\u002E" };
70 #endif
71 #else
72 const char* awdays[7] = { "\u0412\u0441\u043A",
73 "\u041F\u043D\u0434",
74 "\u0412\u0442\u0440",
75 "\u0421\u0440\u0434",
76 "\u0427\u0442\u0432",
77 "\u041F\u0442\u043D",
78 "\u0421\u0431\u0442" };
79 #endif
80
81 for (int i = 0; i < 7; ++i)
82 {
83 iss.str(awdays[i]);
84 iterator_type is_it01(iss);
85 tm time01;
86 memset(&time01, -1, sizeof(tm));
87 errorstate = good;
88 tim_get.get_weekday(is_it01, end, iss, errorstate, &time01);
89 VERIFY( time01.tm_wday == i );
90 VERIFY( errorstate == ios_base::eofbit );
91 }
92
93 const char* wdays[7] = { "\u0412\u043E\u0441\u043A\u0440\u0435"
94 "\u0441\u0435\u043D\u044C\u0435",
95 "\u041F\u043E\u043D\u0435\u0434\u0435"
96 "\u043B\u044C\u043D\u0438\u043A",
97 "\u0412\u0442\u043E\u0440\u043D\u0438\u043A",
98 "\u0421\u0440\u0435\u0434\u0430",
99 "\u0427\u0435\u0442\u0432\u0435\u0440\u0433",
100 "\u041F\u044F\u0442\u043D\u0438\u0446\u0430",
101 "\u0421\u0443\u0431\u0431\u043E\u0442\u0430" };
102
103 for (int i = 0; i < 7; ++i)
104 {
105 iss.str(wdays[i]);
106 iterator_type is_it01(iss);
107 tm time01;
108 memset(&time01, -1, sizeof(tm));
109 errorstate = good;
110 tim_get.get_weekday(is_it01, end, iss, errorstate, &time01);
111 VERIFY( time01.tm_wday == i );
112 VERIFY( errorstate == ios_base::eofbit );
113 }
114 }
115
116 int main()
117 {
118 test01();
119 return 0;
120 }