]>
Commit | Line | Data |
---|---|---|
5f8d36fe BK |
1 | // 2001-09-12 Benjamin Kosnik <bkoz@redhat.com> |
2 | ||
99dee823 | 3 | // Copyright (C) 2001-2021 Free Software Foundation, Inc. |
5f8d36fe BK |
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 | |
748086b7 | 8 | // Free Software Foundation; either version 3, or (at your option) |
5f8d36fe BK |
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 | |
748086b7 JJ |
17 | // with this library; see the file COPYING3. If not see |
18 | // <http://www.gnu.org/licenses/>. | |
5f8d36fe BK |
19 | |
20 | // 22.2.6.1.1 money_get members | |
21 | ||
22 | #include <locale> | |
23 | #include <sstream> | |
24 | #include <testsuite_hooks.h> | |
25 | ||
26 | // We were appending to the string val passed by reference, instead | |
27 | // of constructing a temporary candidate, eventually copied into | |
28 | // val in case of successful parsing. | |
29 | void test07() | |
30 | { | |
31 | using namespace std; | |
5f8d36fe BK |
32 | |
33 | typedef istreambuf_iterator<wchar_t> InIt; | |
34 | InIt iend1, iend2, iend3; | |
35 | ||
36 | locale loc_c = locale::classic(); | |
37 | wstring buffer1(L"123"); | |
38 | wstring buffer2(L"456"); | |
39 | wstring buffer3(L"Golgafrincham"); // From Nathan's original idea. | |
40 | ||
41 | wstring val; | |
42 | ||
43 | ios_base::iostate err; | |
44 | ||
f1c89270 | 45 | const money_get<wchar_t, InIt>& mg = use_facet<money_get<wchar_t, InIt> >(loc_c); |
5f8d36fe BK |
46 | |
47 | wistringstream fmt1(buffer1); | |
f1c89270 | 48 | fmt1.imbue(loc_c); |
5f8d36fe | 49 | InIt ibeg1(fmt1); |
f1c89270 | 50 | mg.get(ibeg1, iend1, false, fmt1, err, val); |
5f8d36fe BK |
51 | VERIFY( val == buffer1 ); |
52 | ||
53 | wistringstream fmt2(buffer2); | |
f1c89270 | 54 | fmt2.imbue(loc_c); |
5f8d36fe | 55 | InIt ibeg2(fmt2); |
f1c89270 | 56 | mg.get(ibeg2, iend2, false, fmt2, err, val); |
5f8d36fe BK |
57 | VERIFY( val == buffer2 ); |
58 | ||
59 | val = buffer3; | |
60 | wistringstream fmt3(buffer3); | |
f1c89270 | 61 | fmt3.imbue(loc_c); |
5f8d36fe | 62 | InIt ibeg3(fmt3); |
f1c89270 | 63 | mg.get(ibeg3, iend3, false, fmt3, err, val); |
5f8d36fe BK |
64 | VERIFY( val == buffer3 ); |
65 | } | |
66 | ||
67 | int main() | |
68 | { | |
69 | test07(); | |
70 | return 0; | |
71 | } |