]>
Commit | Line | Data |
---|---|---|
748086b7 | 1 | // Copyright (C) 2008, 2009 Free Software Foundation |
7391b597 PC |
2 | // |
3 | // This file is part of the GNU ISO C++ Library. This library is free | |
4 | // software; you can redistribute it and/or modify it under the | |
5 | // terms of the GNU General Public License as published by the | |
748086b7 | 6 | // Free Software Foundation; either version 3, or (at your option) |
7391b597 PC |
7 | // any later version. |
8 | ||
9 | // This library is distributed in the hope that it will be useful, | |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | // GNU General Public License for more details. | |
13 | ||
14 | // You should have received a copy of the GNU General Public License along | |
748086b7 JJ |
15 | // with this library; see the file COPYING3. If not see |
16 | // <http://www.gnu.org/licenses/>. | |
7391b597 PC |
17 | |
18 | // 22.2.2.2.1 num_put members | |
19 | ||
20 | #include <locale> | |
21 | #include <sstream> | |
22 | #include <testsuite_hooks.h> | |
23 | ||
24 | class my_punct : public std::numpunct<wchar_t> | |
25 | { | |
26 | protected: | |
27 | std::wstring do_falsename() const { return L"-no-"; } | |
28 | }; | |
29 | ||
30 | // libstdc++/38196 | |
31 | void test01() | |
32 | { | |
33 | bool test __attribute__((unused)) = true; | |
34 | using namespace std; | |
35 | ||
36 | wostringstream oss1, oss2, oss3, oss4; | |
37 | wstring result1, result2, result3, result4; | |
38 | ||
39 | oss1.imbue(locale(oss1.getloc(), new my_punct)); | |
40 | oss2.imbue(locale(oss2.getloc(), new my_punct)); | |
41 | oss3.imbue(locale(oss3.getloc(), new my_punct)); | |
42 | oss4.imbue(locale(oss4.getloc(), new my_punct)); | |
43 | const num_put<wchar_t>& ng1 = use_facet<num_put<wchar_t> >(oss1.getloc()); | |
44 | const num_put<wchar_t>& ng2 = use_facet<num_put<wchar_t> >(oss2.getloc()); | |
45 | const num_put<wchar_t>& ng3 = use_facet<num_put<wchar_t> >(oss3.getloc()); | |
46 | const num_put<wchar_t>& ng4 = use_facet<num_put<wchar_t> >(oss4.getloc()); | |
47 | ||
48 | oss1.width(6); | |
49 | oss1.setf(ios_base::boolalpha); | |
50 | ng1.put(oss1.rdbuf(), oss1, L'*', false); | |
51 | result1 = oss1.str(); | |
52 | VERIFY( result1 == L"**-no-" ); | |
53 | ||
54 | oss2.width(6); | |
55 | oss2.setf(ios_base::right, ios_base::adjustfield); | |
56 | oss2.setf(ios_base::boolalpha); | |
57 | ng2.put(oss2.rdbuf(), oss2, L'*', false); | |
58 | result2 = oss2.str(); | |
59 | VERIFY( result2 == L"**-no-" ); | |
60 | ||
61 | oss3.width(6); | |
62 | oss3.setf(ios_base::internal, ios_base::adjustfield); | |
63 | oss3.setf(ios_base::boolalpha); | |
64 | ng3.put(oss3.rdbuf(), oss3, L'*', false); | |
65 | result3 = oss3.str(); | |
66 | VERIFY( result3 == L"**-no-" ); | |
67 | ||
68 | oss4.width(6); | |
69 | oss4.setf(ios_base::left, ios_base::adjustfield); | |
70 | oss4.setf(ios_base::boolalpha); | |
71 | ng4.put(oss4.rdbuf(), oss4, L'*', false); | |
72 | result4 = oss4.str(); | |
73 | VERIFY( result4 == L"-no-**" ); | |
74 | } | |
75 | ||
76 | int main() | |
77 | { | |
78 | test01(); | |
79 | return 0; | |
80 | } |