aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc
diff options
context:
space:
mode:
authorAndrea Ornstein <andrea.ornstein@st.com>2009-04-20 15:54:16 +0000
committerAndrea Ornstein <andrea.ornstein@st.com>2009-04-20 15:54:16 +0000
commit28e559d03d6abd0c7f19b9301d8e05e8d60c5fe2 (patch)
tree9741dd1fced71957a68fe436062558d2b9906c2d /libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc
parentb49c1e36b5f0ba5db72be07b6427a3a57573229d (diff)
merge from trunk revisions 127002-132392, 3/N
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/st/cli-be@146434 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc')
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc75
1 files changed, 75 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc
new file mode 100644
index 00000000000..73c838b4399
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/error_code.cc
@@ -0,0 +1,75 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2007 Free Software Foundation
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+#include <ostream>
+#include <sstream>
+#include <system_error>
+#include <algorithm>
+#include <wchar.h>
+#include <testsuite_hooks.h>
+
+// Effects: os << ec.category().name() << ':' << ec.value();
+void test()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ wchar_t buf[64];
+ error_code e1;
+ error_code e2(posix_error::bad_address);
+ wstring s, s1, s2;
+
+ {
+ wostringstream ostr;
+ ostr << e1 << endl;
+ s1 = ostr.str();
+
+ if (ostr.rdstate() & ios_base::eofbit)
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( find(s1.begin(), s1.end(), L':') != s1.end() );
+
+ swprintf(buf, 64, L"%i", e1.value());
+ s = buf;
+ VERIFY( s1.find(s) != string::npos);
+
+ {
+ wostringstream ostr;
+ ostr << e2 << endl;
+ s2 = ostr.str();
+
+ if (ostr.rdstate() & ios_base::eofbit)
+ test = false;
+ }
+ VERIFY( test );
+ VERIFY( find(s2.begin(), s2.end(), L':') != s2.end() );
+
+ swprintf(buf, 64, L"%i", e2.value());
+ s = buf;
+ VERIFY( s2.find(s) != string::npos);
+}
+
+int
+main()
+{
+ test();
+ return 0;
+}