]>
Commit | Line | Data |
---|---|---|
4216708a | 1 | // { dg-require-namedlocale "ru_RU.ISO8859-5" } |
ac2bb437 | 2 | |
a945c346 | 3 | // Copyright (C) 2010-2024 Free Software Foundation, Inc. |
ac2bb437 PC |
4 | // |
5 | // This file is part of the GNU ISO C++ Library. This library is free | |
6 | // software; you can redistribute it and/or modify it under the | |
7 | // terms of the GNU General Public License as published by the | |
8 | // Free Software Foundation; either version 3, or (at your option) | |
9 | // any later version. | |
10 | ||
11 | // This library is distributed in the hope that it will be useful, | |
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | // GNU General Public License for more details. | |
15 | ||
16 | // You should have received a copy of the GNU General Public License along | |
17 | // with this library; see the file COPYING3. If not see | |
18 | // <http://www.gnu.org/licenses/>. | |
19 | ||
20 | // 22.2.5.1.1 time_get members | |
21 | ||
22 | #include <locale> | |
23 | #include <sstream> | |
24 | #include <cstring> | |
25 | #include <testsuite_hooks.h> | |
26 | ||
27 | // libstdc++/38081 | |
28 | void test01() | |
29 | { | |
30 | using namespace std; | |
ac2bb437 PC |
31 | |
32 | typedef istreambuf_iterator<char> iterator_type; | |
33 | ||
34 | // basic construction | |
4216708a | 35 | locale loc(ISO_8859(5,ru_RU)); |
ac2bb437 PC |
36 | |
37 | // create an ostream-derived object, cache the time_get facet | |
38 | iterator_type end; | |
39 | ||
40 | istringstream iss; | |
41 | iss.imbue(loc); | |
42 | const time_get<char>& tim_get = use_facet<time_get<char> >(iss.getloc()); | |
43 | ||
44 | const ios_base::iostate good = ios_base::goodbit; | |
45 | ios_base::iostate errorstate = good; | |
46 | ||
47 | // iter_type | |
48 | // get_weekday(iter_type, iter_type, ios_base&, | |
49 | // ios_base::iostate&, tm*) const | |
50 | ||
34b6bcad | 51 | #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 14) |
1590a835 JB |
52 | # if __GLIBC__ > 2 || __GLIBC_MINOR__ >= 17 |
53 | iss.str("\xbf\xdd"); | |
54 | # else | |
34b6bcad | 55 | iss.str("\xbf\xdd\x2e"); |
1590a835 | 56 | # endif |
34b6bcad | 57 | #else |
ac2bb437 | 58 | iss.str("\xbf\xdd\xd4"); |
34b6bcad | 59 | #endif |
ac2bb437 PC |
60 | iterator_type is_it01(iss); |
61 | tm time01; | |
62 | memset(&time01, -1, sizeof(tm)); | |
63 | errorstate = good; | |
64 | tim_get.get_weekday(is_it01, end, iss, errorstate, &time01); | |
65 | VERIFY( time01.tm_wday == 1 ); | |
66 | VERIFY( errorstate == ios_base::eofbit ); | |
67 | ||
68 | iss.str("\xbf\xde\xdd\xd5\xd4\xd5\xdb\xec\xdd\xd8\xda"); | |
69 | iterator_type is_it02(iss); | |
70 | tm time02; | |
71 | memset(&time02, -1, sizeof(tm)); | |
72 | errorstate = good; | |
73 | tim_get.get_weekday(is_it02, end, iss, errorstate, &time02); | |
74 | VERIFY( time02.tm_wday == 1 ); | |
75 | VERIFY( errorstate == ios_base::eofbit ); | |
76 | ||
34b6bcad | 77 | #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 14) |
1590a835 JB |
78 | # if __GLIBC__ > 2 || __GLIBC_MINOR__ >= 17 |
79 | iss.str("\xbf\xdd\xd5\xd4\xd5\xdb\xec\xdd\xd8\xda"); | |
80 | # else | |
34b6bcad | 81 | iss.str("\xbf\xdd\x2e\xd5\xd4\xd5\xdb\xec\xdd\xd8\xda"); |
1590a835 | 82 | # endif |
34b6bcad | 83 | #else |
ac2bb437 | 84 | iss.str("\xbf\xdd\xd4\xd5\xd4\xd5\xdb\xec\xdd\xd8\xda"); |
34b6bcad | 85 | #endif |
ac2bb437 PC |
86 | iterator_type is_it03(iss); |
87 | tm time03; | |
88 | memset(&time03, -1, sizeof(tm)); | |
89 | errorstate = good; | |
90 | iterator_type ret = tim_get.get_weekday(is_it03, end, iss, | |
91 | errorstate, &time03); | |
92 | VERIFY( time03.tm_wday == 1 ); | |
93 | VERIFY( errorstate == ios_base::goodbit ); | |
94 | VERIFY( *ret == '\xd5' ); | |
95 | } | |
96 | ||
97 | int main() | |
98 | { | |
99 | test01(); | |
100 | return 0; | |
101 | } |