aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error')
-rw-r--r--gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/39880.cc29
-rw-r--r--gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/cons-1.cc47
-rw-r--r--gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/cons_virtual_derivation.cc29
-rw-r--r--gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/what-1.cc60
-rw-r--r--gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/what-2.cc50
-rw-r--r--gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/what-3.cc68
-rw-r--r--gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/what-4.cc45
-rw-r--r--gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/what-big.cc40
8 files changed, 368 insertions, 0 deletions
diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/39880.cc b/gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/39880.cc
new file mode 100644
index 000000000..a6ac7470c
--- /dev/null
+++ b/gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/39880.cc
@@ -0,0 +1,29 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2009 Free Software Foundation, Inc.
+//
+// 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <system_error>
+
+// libstdc++/39880
+void test01()
+{
+ std::error_code ec;
+ if (ec == std::errc::not_supported)
+ { }
+}
diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/cons-1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/cons-1.cc
new file mode 100644
index 000000000..42f297985
--- /dev/null
+++ b/gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/cons-1.cc
@@ -0,0 +1,47 @@
+// { dg-options "-std=gnu++0x" }
+// 2007-06-05 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
+//
+// 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <cstring>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+int main()
+{
+ bool test __attribute__((unused)) = true;
+ const std::string s("too late: boulangerie out of pain au raisin");
+ const std::error_code
+ e(std::make_error_code(std::errc::operation_not_supported));
+
+ // 1
+ {
+ std::system_error err1(e, s);
+ VERIFY( err1.code() == e );
+ VERIFY( std::strcmp(err1.runtime_error::what(), s.c_str()) == 0 );
+ }
+
+ // 2
+ {
+ std::system_error err2(95, std::system_category(), s);
+ VERIFY( err2.code() == std::error_code(95, std::system_category()) );
+ VERIFY( std::strcmp(err2.runtime_error::what(), s.c_str()) == 0 );
+ }
+
+ return 0;
+}
diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/cons_virtual_derivation.cc b/gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/cons_virtual_derivation.cc
new file mode 100644
index 000000000..d1afadffd
--- /dev/null
+++ b/gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/cons_virtual_derivation.cc
@@ -0,0 +1,29 @@
+// { dg-options "-std=gnu++0x" }
+// 2007-05-29 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
+//
+// 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <system_error>
+#include <testsuite_api.h>
+
+int main()
+{
+ typedef std::system_error test_type;
+ __gnu_test::diamond_derivation<test_type, true>::test();
+ return 0;
+}
diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/what-1.cc b/gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/what-1.cc
new file mode 100644
index 000000000..213b196b5
--- /dev/null
+++ b/gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/what-1.cc
@@ -0,0 +1,60 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2007, 2008, 2009
+// Free Software Foundation, Inc.
+//
+// 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 19.1 Exception classes
+
+#include <string>
+#include <system_error>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+using namespace std;
+
+// libstdc++/1972
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ string s("lack of sunlight, no water error");
+
+ // 1
+ system_error obj1 = system_error(error_code(), s);
+
+ // 2
+ system_error obj2(error_code(), s);
+
+ VERIFY( strcmp(obj1.what(), s.data()) == 0 );
+ VERIFY( strcmp(obj2.what(), s.data()) == 0 );
+}
+
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+ string s("lack of sunlight error");
+ system_error x(error_code(), s);
+
+ VERIFY( strcmp(x.what(), s.data()) == 0 );
+}
+
+int main(void)
+{
+ test01();
+ test02();
+ return 0;
+}
diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/what-2.cc b/gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/what-2.cc
new file mode 100644
index 000000000..ff6641bd2
--- /dev/null
+++ b/gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/what-2.cc
@@ -0,0 +1,50 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2007, 2008, 2009
+// Free Software Foundation, Inc.
+//
+// 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 19.1 Exception classes
+
+#include <string>
+#include <system_error>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+// libstdc++/2089
+class fuzzy_logic : public std::system_error
+{
+public:
+ fuzzy_logic() : std::system_error(std::error_code(), "whoa") { }
+};
+
+void test03()
+{
+ bool test __attribute__((unused)) = true;
+ try
+ { throw fuzzy_logic(); }
+ catch(const fuzzy_logic& obj)
+ { VERIFY( std::strcmp("whoa", obj.what()) == 0 ); }
+ catch(...)
+ { VERIFY( false ); }
+}
+
+int main(void)
+{
+ test03();
+ return 0;
+}
diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/what-3.cc b/gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/what-3.cc
new file mode 100644
index 000000000..9dc701098
--- /dev/null
+++ b/gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/what-3.cc
@@ -0,0 +1,68 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2007, 2009
+// Free Software Foundation, Inc.
+//
+// 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <string>
+#include <system_error>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+// test copy ctors, assignment operators, and persistence of member string data
+// libstdc++/1972
+// via Greg Bumgardner <bumgard@roguewave.com>
+void allocate_on_stack(void)
+{
+ const size_t num = 512;
+ __extension__ char array[num];
+ for (size_t i = 0; i < num; i++)
+ array[i]=0;
+}
+
+void test04()
+{
+ bool test __attribute__((unused)) = true;
+ const std::string s("CA ISO emergency once again:immediate power down");
+ const char* strlit1 = "wish I lived in Palo Alto";
+ const char* strlit2 = "...or Santa Barbara";
+ std::system_error obj1(std::error_code(), s);
+
+ // block 01
+ {
+ const std::string s2(strlit1);
+ std::system_error obj2(std::error_code(), s2);
+ obj1 = obj2;
+ }
+ allocate_on_stack();
+ VERIFY( std::strcmp(strlit1, obj1.what()) == 0 );
+
+ // block 02
+ {
+ const std::string s3(strlit2);
+ std::system_error obj3 = std::system_error(std::error_code(), s3);
+ obj1 = obj3;
+ }
+ allocate_on_stack();
+ VERIFY( std::strcmp(strlit2, obj1.what()) == 0 );
+}
+
+int main(void)
+{
+ test04();
+ return 0;
+}
diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/what-4.cc b/gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/what-4.cc
new file mode 100644
index 000000000..2b5d51c45
--- /dev/null
+++ b/gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/what-4.cc
@@ -0,0 +1,45 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2007, 2008, 2009
+// Free Software Foundation, Inc.
+//
+// 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 19.1 Exception classes
+
+#include <cstring>
+#include <string>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+// Make sure each invocation of what() doesn't grow the message.
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ std::string s("after nine thirty, this request cannot be met");
+
+ std::system_error obj =
+ std::system_error(std::make_error_code(std::errc::invalid_argument), s);
+ std::string s1(obj.what());
+ std::string s2(obj.what());
+ VERIFY( s1 == s2 );
+}
+
+int main(void)
+{
+ test01();
+ return 0;
+}
diff --git a/gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/what-big.cc b/gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/what-big.cc
new file mode 100644
index 000000000..f3c1309f5
--- /dev/null
+++ b/gcc-4.4.3/libstdc++-v3/testsuite/19_diagnostics/system_error/what-big.cc
@@ -0,0 +1,40 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
+//
+// 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <cstring>
+#include <string>
+#include <system_error>
+#include <testsuite_hooks.h>
+
+// Can construct and return 10k character error string.
+void test01()
+{
+ typedef std::system_error test_type;
+
+ bool test __attribute__((unused)) = true;
+ const std::string xxx(10000, 'x');
+ test_type t(std::error_code(), xxx);
+ VERIFY( std::strcmp(t.what(), xxx.c_str()) == 0 );
+}
+
+int main(void)
+{
+ test01();
+ return 0;
+}