diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /libstdc++-v3/testsuite/19_diagnostics/system_error | |
download | cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2 cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'libstdc++-v3/testsuite/19_diagnostics/system_error')
8 files changed, 366 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/19_diagnostics/system_error/39880.cc b/libstdc++-v3/testsuite/19_diagnostics/system_error/39880.cc new file mode 100644 index 000000000..a6ac7470c --- /dev/null +++ b/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/libstdc++-v3/testsuite/19_diagnostics/system_error/cons-1.cc b/libstdc++-v3/testsuite/19_diagnostics/system_error/cons-1.cc new file mode 100644 index 000000000..4a145a993 --- /dev/null +++ b/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, 2010 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 <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::string(err1.what()).find(s) != std::string::npos ); + } + + // 2 + { + std::system_error err2(95, std::system_category(), s); + VERIFY( err2.code() == std::error_code(95, std::system_category()) ); + VERIFY( std::string((err2.what(), s)).find(s) != std::string::npos ); + } + + return 0; +} diff --git a/libstdc++-v3/testsuite/19_diagnostics/system_error/cons_virtual_derivation.cc b/libstdc++-v3/testsuite/19_diagnostics/system_error/cons_virtual_derivation.cc new file mode 100644 index 000000000..d1afadffd --- /dev/null +++ b/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/libstdc++-v3/testsuite/19_diagnostics/system_error/what-1.cc b/libstdc++-v3/testsuite/19_diagnostics/system_error/what-1.cc new file mode 100644 index 000000000..9899dfb7a --- /dev/null +++ b/libstdc++-v3/testsuite/19_diagnostics/system_error/what-1.cc @@ -0,0 +1,59 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2008, 2009, 2010 +// 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 <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( string(obj1.what()).find(s.data()) != string::npos ); + VERIFY( string(obj2.what()).find(s.data()) != string::npos ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + string s("lack of sunlight error"); + system_error x(error_code(), s); + + VERIFY( string(x.what()).find(s.data()) != string::npos ); +} + +int main(void) +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/19_diagnostics/system_error/what-2.cc b/libstdc++-v3/testsuite/19_diagnostics/system_error/what-2.cc new file mode 100644 index 000000000..b5fe39cb2 --- /dev/null +++ b/libstdc++-v3/testsuite/19_diagnostics/system_error/what-2.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2008, 2009, 2010 +// 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 <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::string(obj.what()).find("whoa") != std::string::npos ); } + catch(...) + { VERIFY( false ); } +} + +int main(void) +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/19_diagnostics/system_error/what-3.cc b/libstdc++-v3/testsuite/19_diagnostics/system_error/what-3.cc new file mode 100644 index 000000000..d1d2ffee4 --- /dev/null +++ b/libstdc++-v3/testsuite/19_diagnostics/system_error/what-3.cc @@ -0,0 +1,70 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2009, 2010 +// 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 <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; + // Suppress unused warnings. + for (size_t i = 0; i < num; i++) + array[i]=array[i]; +} + +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::string(obj1.what()).find(strlit1) != std::string::npos ); + + // 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::string(obj1.what()).find(strlit2) != std::string::npos ); +} + +int main(void) +{ + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/19_diagnostics/system_error/what-4.cc b/libstdc++-v3/testsuite/19_diagnostics/system_error/what-4.cc new file mode 100644 index 000000000..7c729c7f1 --- /dev/null +++ b/libstdc++-v3/testsuite/19_diagnostics/system_error/what-4.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2008, 2009, 2010 +// 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 <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/libstdc++-v3/testsuite/19_diagnostics/system_error/what-big.cc b/libstdc++-v3/testsuite/19_diagnostics/system_error/what-big.cc new file mode 100644 index 000000000..351fc2914 --- /dev/null +++ b/libstdc++-v3/testsuite/19_diagnostics/system_error/what-big.cc @@ -0,0 +1,39 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2007, 2008, 2009, 2010 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 <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::string(t.what()).find(xxx) != std::string::npos ); +} + +int main(void) +{ + test01(); + return 0; +} |