]>
Commit | Line | Data |
---|---|---|
8868286e | 1 | // { dg-options "-std=gnu++11" } |
270aef91 | 2 | // { dg-require-swprintf "" } |
d0ff4e64 | 3 | |
f1717362 | 4 | // Copyright (C) 2007-2016 Free Software Foundation, Inc. |
d0ff4e64 | 5 | // |
6 | // This file is part of the GNU ISO C++ Library. This library is free | |
7 | // software; you can redistribute it and/or modify it under the | |
8 | // terms of the GNU General Public License as published by the | |
6bc9506f | 9 | // Free Software Foundation; either version 3, or (at your option) |
d0ff4e64 | 10 | // any later version. |
11 | ||
12 | // This library is distributed in the hope that it will be useful, | |
13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | // GNU General Public License for more details. | |
16 | ||
17 | // You should have received a copy of the GNU General Public License along | |
6bc9506f | 18 | // with this library; see the file COPYING3. If not see |
19 | // <http://www.gnu.org/licenses/>. | |
d0ff4e64 | 20 | |
21 | #include <ostream> | |
22 | #include <sstream> | |
23 | #include <system_error> | |
24 | #include <algorithm> | |
be77e727 | 25 | #include <cwchar> |
d0ff4e64 | 26 | #include <testsuite_hooks.h> |
27 | ||
28 | // Effects: os << ec.category().name() << ':' << ec.value(); | |
29 | void test() | |
30 | { | |
31 | using namespace std; | |
32 | bool test __attribute__((unused)) = true; | |
33 | ||
34 | wchar_t buf[64]; | |
35 | error_code e1; | |
48a423de | 36 | error_code e2(make_error_code(errc::bad_address)); |
d0ff4e64 | 37 | wstring s, s1, s2; |
38 | ||
39 | { | |
40 | wostringstream ostr; | |
41 | ostr << e1 << endl; | |
42 | s1 = ostr.str(); | |
43 | ||
44 | if (ostr.rdstate() & ios_base::eofbit) | |
45 | test = false; | |
46 | } | |
47 | VERIFY( test ); | |
48 | VERIFY( find(s1.begin(), s1.end(), L':') != s1.end() ); | |
49 | ||
50 | swprintf(buf, 64, L"%i", e1.value()); | |
51 | s = buf; | |
52 | VERIFY( s1.find(s) != string::npos); | |
53 | ||
54 | { | |
55 | wostringstream ostr; | |
56 | ostr << e2 << endl; | |
57 | s2 = ostr.str(); | |
58 | ||
59 | if (ostr.rdstate() & ios_base::eofbit) | |
60 | test = false; | |
61 | } | |
62 | VERIFY( test ); | |
63 | VERIFY( find(s2.begin(), s2.end(), L':') != s2.end() ); | |
64 | ||
65 | swprintf(buf, 64, L"%i", e2.value()); | |
66 | s = buf; | |
67 | VERIFY( s2.find(s) != string::npos); | |
68 | } | |
69 | ||
70 | int | |
71 | main() | |
72 | { | |
73 | test(); | |
74 | return 0; | |
75 | } |