]>
Commit | Line | Data |
---|---|---|
2f14cd74 | 1 | // 2001-09-12 Benjamin Kosnik <bkoz@redhat.com> |
2 | ||
f1717362 | 3 | // Copyright (C) 2001-2016 Free Software Foundation, Inc. |
2f14cd74 | 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 | |
6bc9506f | 8 | // Free Software Foundation; either version 3, or (at your option) |
2f14cd74 | 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 | |
6bc9506f | 17 | // with this library; see the file COPYING3. If not see |
18 | // <http://www.gnu.org/licenses/>. | |
2f14cd74 | 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; | |
f8ef786c | 32 | bool test __attribute__((unused)) = true; |
2f14cd74 | 33 | |
34 | typedef istreambuf_iterator<char> InIt; | |
35 | InIt iend1, iend2, iend3; | |
36 | ||
37 | locale loc_c = locale::classic(); | |
38 | string buffer1("123"); | |
39 | string buffer2("456"); | |
40 | string buffer3("Golgafrincham"); // From Nathan's original idea. | |
41 | ||
42 | string val; | |
43 | ||
44 | ios_base::iostate err; | |
45 | ||
fa305a14 | 46 | const money_get<char, InIt>& mg = use_facet<money_get<char, InIt> >(loc_c); |
2f14cd74 | 47 | |
48 | istringstream fmt1(buffer1); | |
fa305a14 | 49 | fmt1.imbue(loc_c); |
2f14cd74 | 50 | InIt ibeg1(fmt1); |
fa305a14 | 51 | mg.get(ibeg1, iend1, false, fmt1, err, val); |
2f14cd74 | 52 | VERIFY( val == buffer1 ); |
53 | ||
54 | istringstream fmt2(buffer2); | |
fa305a14 | 55 | fmt2.imbue(loc_c); |
2f14cd74 | 56 | InIt ibeg2(fmt2); |
fa305a14 | 57 | mg.get(ibeg2, iend2, false, fmt2, err, val); |
2f14cd74 | 58 | VERIFY( val == buffer2 ); |
59 | ||
60 | val = buffer3; | |
61 | istringstream fmt3(buffer3); | |
fa305a14 | 62 | fmt3.imbue(loc_c); |
2f14cd74 | 63 | InIt ibeg3(fmt3); |
fa305a14 | 64 | mg.get(ibeg3, iend3, false, fmt3, err, val); |
2f14cd74 | 65 | VERIFY( val == buffer3 ); |
66 | } | |
67 | ||
68 | int main() | |
69 | { | |
70 | test07(); | |
71 | return 0; | |
72 | } |