| 1 | // { dg-require-namedlocale "ru_RU.UTF-8" } |
| 2 | |
| 3 | // 2010-01-05 Paolo Carlini <[email protected]> |
| 4 | |
| 5 | // Copyright (C) 2010-2025 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 | |
| 33 | typedef istreambuf_iterator<char> iterator_type; |
| 34 | |
| 35 | // basic construction |
| 36 | locale loc("ru_RU.UTF-8"); |
| 37 | |
| 38 | // create an ostream-derived object, cache the time_get facet |
| 39 | iterator_type end; |
| 40 | |
| 41 | istringstream iss; |
| 42 | iss.imbue(loc); |
| 43 | const time_get<char>& tim_get = use_facet<time_get<char> >(iss.getloc()); |
| 44 | |
| 45 | const ios_base::iostate good = ios_base::goodbit; |
| 46 | ios_base::iostate errorstate = good; |
| 47 | |
| 48 | // iter_type |
| 49 | // get_weekday(iter_type, iter_type, ios_base&, |
| 50 | // ios_base::iostate&, tm*) const |
| 51 | |
| 52 | #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 14) |
| 53 | # if __GLIBC__ > 2 || __GLIBC_MINOR__ >= 17 |
| 54 | const char* awdays[7] = { "\u0412\u0441", |
| 55 | "\u041F\u043D", |
| 56 | "\u0412\u0442", |
| 57 | "\u0421\u0440", |
| 58 | "\u0427\u0442", |
| 59 | "\u041F\u0442", |
| 60 | "\u0421\u0431" }; |
| 61 | # else |
| 62 | const char* awdays[7] = { "\u0412\u0441\u002E", |
| 63 | "\u041F\u043D\u002E", |
| 64 | "\u0412\u0442\u002E", |
| 65 | "\u0421\u0440\u002E", |
| 66 | "\u0427\u0442\u002E", |
| 67 | "\u041F\u0442\u002E", |
| 68 | "\u0421\u0431\u002E" }; |
| 69 | #endif |
| 70 | #else |
| 71 | const char* awdays[7] = { "\u0412\u0441\u043A", |
| 72 | "\u041F\u043D\u0434", |
| 73 | "\u0412\u0442\u0440", |
| 74 | "\u0421\u0440\u0434", |
| 75 | "\u0427\u0442\u0432", |
| 76 | "\u041F\u0442\u043D", |
| 77 | "\u0421\u0431\u0442" }; |
| 78 | #endif |
| 79 | |
| 80 | for (int i = 0; i < 7; ++i) |
| 81 | { |
| 82 | iss.str(awdays[i]); |
| 83 | iterator_type is_it01(iss); |
| 84 | tm time01; |
| 85 | memset(&time01, -1, sizeof(tm)); |
| 86 | errorstate = good; |
| 87 | tim_get.get_weekday(is_it01, end, iss, errorstate, &time01); |
| 88 | VERIFY( time01.tm_wday == i ); |
| 89 | VERIFY( errorstate == ios_base::eofbit ); |
| 90 | } |
| 91 | |
| 92 | const char* wdays[7] = { "\u0412\u043E\u0441\u043A\u0440\u0435" |
| 93 | "\u0441\u0435\u043D\u044C\u0435", |
| 94 | "\u041F\u043E\u043D\u0435\u0434\u0435" |
| 95 | "\u043B\u044C\u043D\u0438\u043A", |
| 96 | "\u0412\u0442\u043E\u0440\u043D\u0438\u043A", |
| 97 | "\u0421\u0440\u0435\u0434\u0430", |
| 98 | "\u0427\u0435\u0442\u0432\u0435\u0440\u0433", |
| 99 | "\u041F\u044F\u0442\u043D\u0438\u0446\u0430", |
| 100 | "\u0421\u0443\u0431\u0431\u043E\u0442\u0430" }; |
| 101 | |
| 102 | for (int i = 0; i < 7; ++i) |
| 103 | { |
| 104 | iss.str(wdays[i]); |
| 105 | iterator_type is_it01(iss); |
| 106 | tm time01; |
| 107 | memset(&time01, -1, sizeof(tm)); |
| 108 | errorstate = good; |
| 109 | tim_get.get_weekday(is_it01, end, iss, errorstate, &time01); |
| 110 | VERIFY( time01.tm_wday == i ); |
| 111 | VERIFY( errorstate == ios_base::eofbit ); |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | int main() |
| 116 | { |
| 117 | test01(); |
| 118 | return 0; |
| 119 | } |