diff options
Diffstat (limited to 'libstdc++-v3/testsuite')
130 files changed, 6045 insertions, 73 deletions
diff --git a/libstdc++-v3/testsuite/17_intro/no_assert_neg.cc b/libstdc++-v3/testsuite/17_intro/no_assert_neg.cc new file mode 100644 index 00000000000..f3ffa4a48e0 --- /dev/null +++ b/libstdc++-v3/testsuite/17_intro/no_assert_neg.cc @@ -0,0 +1,89 @@ +// { dg-do compile } +// { dg-options "-D__GLIBCXX__=99999999" } +// NB: This is done to force any generated and possibly included PCH +// to be invalid. + +// 2005-05-24 bkoz + +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 17.4.1.2 Headers + +// This file tests that assert is not included in any of the standard +// includes by accident. + +// C++ headers +#include <algorithm> +#include <bitset> +#include <complex> +#include <deque> +#include <exception> +#include <fstream> +#include <functional> +#include <iomanip> +#include <ios> +#include <iosfwd> +#include <iostream> +#include <istream> +#include <iterator> +#include <limits> +#include <list> +#include <locale> +#include <map> +#include <memory> +#include <new> +#include <numeric> +#include <ostream> +#include <queue> +#include <set> +#include <sstream> +#include <stack> +#include <stdexcept> +#include <streambuf> +#include <string> +#include <typeinfo> +#include <utility> +#include <valarray> +#include <vector> + +// C headers +#include <cctype> +#include <cerrno> +#include <cfloat> +#include <ciso646> +#include <climits> +#include <clocale> +#include <cmath> +#include <csetjmp> +#include <csignal> +#include <cstdarg> +#include <cstddef> +#include <cstdio> +#include <cstdlib> +#include <cstring> +#include <ctime> + +void foo() +{ + assert(true); +} + +// { dg-error "not declared" "" { target *-*-* } 84 } + + diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/1.cc new file mode 100644 index 00000000000..e65fdd8b86a --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/1.cc @@ -0,0 +1,36 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// This file tests explicit instantiation of basic_string + +#include <string> + +// { dg-do compile } + +// libstdc++/21770 +template class std::basic_string<int, std::char_traits<int>, + std::allocator<char> >; diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/2.cc new file mode 100644 index 00000000000..36322929ac7 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/2.cc @@ -0,0 +1,36 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// This file tests explicit instantiation of basic_string + +#include <debug/string> + +// { dg-do compile } + +// libstdc++/21770 +template class __gnu_debug::basic_string<int, std::char_traits<int>, + std::allocator<char> >; diff --git a/libstdc++-v3/testsuite/23_containers/deque/explicit_instantiation.cc b/libstdc++-v3/testsuite/23_containers/deque/explicit_instantiation/1.cc index e6e758d0c74..e6e758d0c74 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/explicit_instantiation.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/explicit_instantiation/1.cc diff --git a/libstdc++-v3/testsuite/23_containers/deque/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/23_containers/deque/explicit_instantiation/2.cc new file mode 100644 index 00000000000..7084ff746a0 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/explicit_instantiation/2.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2004 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// This file tests explicit instantiation of library containers + +#include <deque> +#include <testsuite_hooks.h> + +// { dg-do compile } + +template class std::deque<__gnu_test::NonDefaultConstructible>; diff --git a/libstdc++-v3/testsuite/23_containers/deque/explicit_instantiation/3.cc b/libstdc++-v3/testsuite/23_containers/deque/explicit_instantiation/3.cc new file mode 100644 index 00000000000..51b4551c4da --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/explicit_instantiation/3.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// This file tests explicit instantiation of library containers + +#include <deque> + +// { dg-do compile } + +// libstdc++/21770 +template class std::deque<int, std::allocator<char> >; diff --git a/libstdc++-v3/testsuite/23_containers/list/explicit_instantiation.cc b/libstdc++-v3/testsuite/23_containers/list/explicit_instantiation/1.cc index 2c9db8d3f86..2c9db8d3f86 100644 --- a/libstdc++-v3/testsuite/23_containers/list/explicit_instantiation.cc +++ b/libstdc++-v3/testsuite/23_containers/list/explicit_instantiation/1.cc diff --git a/libstdc++-v3/testsuite/23_containers/list/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/23_containers/list/explicit_instantiation/2.cc new file mode 100644 index 00000000000..66d3934f427 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/explicit_instantiation/2.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2004 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// This file tests explicit instantiation of library containers + +#include <list> +#include <testsuite_hooks.h> + +// { dg-do compile } + +template class std::list<__gnu_test::NonDefaultConstructible>; diff --git a/libstdc++-v3/testsuite/23_containers/list/explicit_instantiation/3.cc b/libstdc++-v3/testsuite/23_containers/list/explicit_instantiation/3.cc new file mode 100644 index 00000000000..19f719dfff4 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/explicit_instantiation/3.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// This file tests explicit instantiation of library containers + +#include <list> + +// { dg-do compile } + +// libstdc++/21770 +template class std::list<int, std::allocator<char> >; diff --git a/libstdc++-v3/testsuite/23_containers/map/explicit_instantiation.cc b/libstdc++-v3/testsuite/23_containers/map/explicit_instantiation/1.cc index 4ceb2501569..4ceb2501569 100644 --- a/libstdc++-v3/testsuite/23_containers/map/explicit_instantiation.cc +++ b/libstdc++-v3/testsuite/23_containers/map/explicit_instantiation/1.cc diff --git a/libstdc++-v3/testsuite/23_containers/map/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/23_containers/map/explicit_instantiation/2.cc new file mode 100644 index 00000000000..8c3c744f080 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/explicit_instantiation/2.cc @@ -0,0 +1,37 @@ +// Copyright (C) 2004 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// This file tests explicit instantiation of library containers + +#include <map> +#include <testsuite_hooks.h> + +// { dg-do compile } + +// N.B. We cannot instantiate with T == NonDefaultConstructible +// because of 23.3.1.2. +template class std::map<__gnu_test::NonDefaultConstructible, double>; diff --git a/libstdc++-v3/testsuite/23_containers/map/explicit_instantiation/3.cc b/libstdc++-v3/testsuite/23_containers/map/explicit_instantiation/3.cc new file mode 100644 index 00000000000..8ce3b6feda3 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/explicit_instantiation/3.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// This file tests explicit instantiation of library containers + +#include <map> + +// { dg-do compile } + +// libstdc++/21770 +template class std::map<int, double, std::less<int>, std::allocator<char> >; diff --git a/libstdc++-v3/testsuite/23_containers/multimap/explicit_instantiation.cc b/libstdc++-v3/testsuite/23_containers/multimap/explicit_instantiation/1.cc index 4a740b250f6..4a740b250f6 100644 --- a/libstdc++-v3/testsuite/23_containers/multimap/explicit_instantiation.cc +++ b/libstdc++-v3/testsuite/23_containers/multimap/explicit_instantiation/1.cc diff --git a/libstdc++-v3/testsuite/23_containers/multimap/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/23_containers/multimap/explicit_instantiation/2.cc new file mode 100644 index 00000000000..46181ef3e25 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/multimap/explicit_instantiation/2.cc @@ -0,0 +1,36 @@ +// Copyright (C) 2004 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// This file tests explicit instantiation of library containers + +#include <map> +#include <testsuite_hooks.h> + +// { dg-do compile } + +template class std::multimap<__gnu_test::NonDefaultConstructible, + __gnu_test::NonDefaultConstructible>; diff --git a/libstdc++-v3/testsuite/23_containers/multimap/explicit_instantiation/3.cc b/libstdc++-v3/testsuite/23_containers/multimap/explicit_instantiation/3.cc new file mode 100644 index 00000000000..1c434b8501f --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/multimap/explicit_instantiation/3.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// This file tests explicit instantiation of library containers + +#include <map> + +// { dg-do compile } + +// libstdc++/21770 +template class std::multimap<int, double, std::less<int>, std::allocator<char> >; diff --git a/libstdc++-v3/testsuite/23_containers/multiset/explicit_instantiation.cc b/libstdc++-v3/testsuite/23_containers/multiset/explicit_instantiation/1.cc index fb6b5f1db19..fb6b5f1db19 100644 --- a/libstdc++-v3/testsuite/23_containers/multiset/explicit_instantiation.cc +++ b/libstdc++-v3/testsuite/23_containers/multiset/explicit_instantiation/1.cc diff --git a/libstdc++-v3/testsuite/23_containers/multiset/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/23_containers/multiset/explicit_instantiation/2.cc new file mode 100644 index 00000000000..0f5f3080aa4 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/multiset/explicit_instantiation/2.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2004 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// This file tests explicit instantiation of library containers + +#include <set> +#include <testsuite_hooks.h> + +// { dg-do compile } + +template class std::multiset<__gnu_test::NonDefaultConstructible>; diff --git a/libstdc++-v3/testsuite/23_containers/multiset/explicit_instantiation/3.cc b/libstdc++-v3/testsuite/23_containers/multiset/explicit_instantiation/3.cc new file mode 100644 index 00000000000..2b36bb92646 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/multiset/explicit_instantiation/3.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// This file tests explicit instantiation of library containers + +#include <set> + +// { dg-do compile } + +// libstdc++/21770 +template class std::multiset<int, std::less<int>, std::allocator<char> >; diff --git a/libstdc++-v3/testsuite/23_containers/set/explicit_instantiation.cc b/libstdc++-v3/testsuite/23_containers/set/explicit_instantiation/1.cc index 02e33be0456..02e33be0456 100644 --- a/libstdc++-v3/testsuite/23_containers/set/explicit_instantiation.cc +++ b/libstdc++-v3/testsuite/23_containers/set/explicit_instantiation/1.cc diff --git a/libstdc++-v3/testsuite/23_containers/set/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/23_containers/set/explicit_instantiation/2.cc new file mode 100644 index 00000000000..418c80e5543 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/set/explicit_instantiation/2.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2004 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// This file tests explicit instantiation of library containers + +#include <set> +#include <testsuite_hooks.h> + +// { dg-do compile } + +template class std::set<__gnu_test::NonDefaultConstructible>; diff --git a/libstdc++-v3/testsuite/23_containers/set/explicit_instantiation/3.cc b/libstdc++-v3/testsuite/23_containers/set/explicit_instantiation/3.cc new file mode 100644 index 00000000000..c2323226916 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/set/explicit_instantiation/3.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// This file tests explicit instantiation of library containers + +#include <set> + +// { dg-do compile } + +// libstdc++/21770 +template class std::set<int, std::less<int>, std::allocator<char> >; diff --git a/libstdc++-v3/testsuite/23_containers/vector/explicit_instantiation.cc b/libstdc++-v3/testsuite/23_containers/vector/explicit_instantiation/1.cc index 0668bbd12ab..0668bbd12ab 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/explicit_instantiation.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/explicit_instantiation/1.cc diff --git a/libstdc++-v3/testsuite/23_containers/vector/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/23_containers/vector/explicit_instantiation/2.cc new file mode 100644 index 00000000000..7020d42ebb0 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/explicit_instantiation/2.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2004 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// This file tests explicit instantiation of library containers + +#include <vector> +#include <testsuite_hooks.h> + +// { dg-do compile } + +template class std::vector<__gnu_test::NonDefaultConstructible>; diff --git a/libstdc++-v3/testsuite/23_containers/vector/explicit_instantiation/3.cc b/libstdc++-v3/testsuite/23_containers/vector/explicit_instantiation/3.cc new file mode 100644 index 00000000000..2cd0b23fcb6 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/explicit_instantiation/3.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// This file tests explicit instantiation of library containers + +#include <vector> + +// { dg-do compile } + +// libstdc++/21770 +template class std::vector<int, std::allocator<char> >; diff --git a/libstdc++-v3/testsuite/25_algorithms/adjacent_find/1.cc b/libstdc++-v3/testsuite/25_algorithms/adjacent_find/1.cc new file mode 100644 index 00000000000..fcce4b56596 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/adjacent_find/1.cc @@ -0,0 +1,67 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.5 [lib.alg.adjacent_find] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using std::adjacent_find; + +typedef test_container<int, forward_iterator_wrapper> Container; +int array[] = {0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}; + +void +test01() +{ + Container con(array, array); + VERIFY(adjacent_find(con.begin(), con.end()).ptr == array); +} + +void +test02() +{ + Container con(array, array + 1); + VERIFY(adjacent_find(con.begin(), con.end()).ptr == array + 1); +} + +void +test03() +{ + Container con(array, array + 2); + VERIFY(adjacent_find(con.begin(), con.end()).ptr == array); +} + +void +test04() +{ + Container con(array + 1, array + 10); + VERIFY(adjacent_find(con.begin(), con.end()).ptr == array + 10); +} + +int +main() +{ + test01(); + test02(); + test03(); + test04(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/adjacent_find/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/adjacent_find/check_type.cc new file mode 100644 index 00000000000..65f725df179 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/adjacent_find/check_type.cc @@ -0,0 +1,42 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.5 [lib.alg.adjacent_find] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct S { }; + +bool operator==(const S&, const S&) {return true;} + +struct X { }; + +bool predicate(const X&, const X&) {return true;} + +forward_iterator_wrapper<S> +test1(forward_iterator_wrapper<S>& s) +{ return std::adjacent_find(s, s); } + +forward_iterator_wrapper<X> +test2(forward_iterator_wrapper<X>& x) +{ return std::adjacent_find(x, x, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/binary_search/1.cc b/libstdc++-v3/testsuite/25_algorithms/binary_search/1.cc new file mode 100644 index 00000000000..5ee44419b8b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/binary_search/1.cc @@ -0,0 +1,54 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.3.4 [lib.binary.search] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using std::binary_search; + +typedef test_container<int, forward_iterator_wrapper> Container; + +void +test1() +{ + int array[] = {0}; + Container con(array, array); + VERIFY(!binary_search(con.begin(), con.end(), 1)); +} + +void +test2() +{ + int array[] = {0, 2, 4, 6, 8}; + Container con(array, array + 5); + for(int i = 0; i < 10; i += 2) + VERIFY(binary_search(con.begin(), con.end(), i)); + for(int i = -1; i < 11; i += 2) + VERIFY(!binary_search(con.begin(), con.end(), i)); +} + +int main() +{ + test1(); + test2(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/binary_search/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/binary_search/check_type.cc new file mode 100644 index 00000000000..853a6d2ee39 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/binary_search/check_type.cc @@ -0,0 +1,42 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.3.4 [lib.binary.search] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct S { }; + +bool operator<(const S&, const S&) {return true;} + +struct X { }; + +bool predicate(const X&, const X&) {return true;} + +bool +test1(forward_iterator_wrapper<S>& s) +{ return std::binary_search(s, s, *s); } + +bool +test2(forward_iterator_wrapper<X>& x) +{ return std::binary_search(x, x, *x, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/count/1.cc b/libstdc++-v3/testsuite/25_algorithms/count/1.cc new file mode 100644 index 00000000000..dec293cfc3c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/count/1.cc @@ -0,0 +1,58 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.6 count + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container<int, input_iterator_wrapper> Container; +int array[] = {0, 0, 0, 1, 0, 1}; + +void +test1() +{ + Container con(array, array); + VERIFY(std::count(con.begin(), con.end(), 1) == 0); +} + +void +test2() +{ + Container con(array, array + 1); + VERIFY(std::count(con.begin(), con.end(), 1) == 0); +} + +void +test3() +{ + Container con(array, array + 6); + VERIFY(std::count(con.begin(), con.end(), 1) == 2); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/count/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/count/check_type.cc new file mode 100644 index 00000000000..389c8a08459 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/count/check_type.cc @@ -0,0 +1,42 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.2 find_if + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +struct X { }; + +struct Y { }; + +using __gnu_test::input_iterator_wrapper; + +bool +operator==(const X&, const Y&) +{ return true; } + +typedef std::iterator_traits<input_iterator_wrapper<X> >::difference_type + diff_type; + +diff_type +test1(input_iterator_wrapper<X>& begin, + input_iterator_wrapper<X>& end) +{ return std::count(begin, end, Y()); } diff --git a/libstdc++-v3/testsuite/25_algorithms/count_if/1.cc b/libstdc++-v3/testsuite/25_algorithms/count_if/1.cc new file mode 100644 index 00000000000..d5e626f4754 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/count_if/1.cc @@ -0,0 +1,65 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.6 count_if + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container<int, input_iterator_wrapper> Container; +int array[] = {0, 0, 0, 1, 0, 1}; + +bool +predicate(const int& i) +{ return i == 1; } + +void +test1() +{ + Container con(array, array); + VERIFY(std::count_if(con.begin(), con.end(), + predicate) == 0); +} + +void +test2() +{ + Container con(array, array + 1); + VERIFY(std::count_if(con.begin(), con.end(), + predicate) == 0); +} + +void +test3() +{ + Container con(array, array + 6); + VERIFY(std::count_if(con.begin(), con.end(), + predicate) == 2); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/count_if/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/count_if/check_type.cc new file mode 100644 index 00000000000..8530985b935 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/count_if/check_type.cc @@ -0,0 +1,52 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.2 find_if + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +struct X { }; + +using __gnu_test::input_iterator_wrapper; + +bool +pred_function(const X&) +{ return true; } + +struct pred_obj +{ + bool + operator()(const X&) + { return true; } +}; + +typedef std::iterator_traits<input_iterator_wrapper<X> >::difference_type + diff_type; + +diff_type +test1(input_iterator_wrapper<X>& begin, + input_iterator_wrapper<X>& end) +{ return std::count_if(begin, end, pred_function); } + +diff_type +test2(input_iterator_wrapper<X>& begin, + input_iterator_wrapper<X>& end) +{ return std::count_if(begin, end, pred_obj()); } diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/1.cc b/libstdc++-v3/testsuite/25_algorithms/equal/1.cc new file mode 100644 index 00000000000..9a17c0276ae --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal/1.cc @@ -0,0 +1,73 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container<int, input_iterator_wrapper> Container; +int array1[] = {0, 1}; +int array2[] = {1, 0}; +int array3[] = {1, 0}; + +void test1() +{ + Container con1(array1, array1); + Container con2(array2, array2); + VERIFY( std::equal(con1.begin(), con1.end(), con2.begin()) ); +} + +void test2() +{ + Container con1(array1, array1 + 2); + Container con2(array2, array2 + 2); + VERIFY( !std::equal(con2.begin(), con2.end(), con1.begin()) ); +} + +void test3() +{ + Container con1(array1, array1 + 2); + Container con2(array2, array2 + 2); + VERIFY( !std::equal(con2.begin(), con2.end(), con1.begin()) ); +} + +void test4() +{ + Container con1(array1, array1 + 2); + Container con2(array2, array2 + 2); + VERIFY( !std::equal(con1.begin(), con1.end(), con2.begin()) ); +} + +void test5() +{ + Container con3(array3, array3 + 2); + Container con2(array2, array2 + 2); + VERIFY( std::equal(con3.begin(), con3.end(), con2.begin()) ); +} + +int main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/equal/check_type.cc new file mode 100644 index 00000000000..434d722e9a6 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal/check_type.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.8 [lib.alg.equal] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> +using __gnu_test::input_iterator_wrapper; + +struct Lhs1 { }; + +struct Rhs1 { }; + +bool operator==(const Lhs1&, const Rhs1&) {return true;} + +struct Lhs2 { }; + +struct Rhs2 { }; + +bool +predicate(const Lhs2&, const Rhs2&) {return true;} + +bool +test1(input_iterator_wrapper<Lhs1>& lhs1, + input_iterator_wrapper<Rhs1>& rhs1) +{ return std::equal(lhs1, lhs1, rhs1); } + +bool +test2(input_iterator_wrapper<Lhs2>& lhs2, + input_iterator_wrapper<Rhs2>& rhs2) +{ return std::equal(lhs2, lhs2, rhs2, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/equal.cc b/libstdc++-v3/testsuite/25_algorithms/equal/equal.cc index abb0446be21..abb0446be21 100644 --- a/libstdc++-v3/testsuite/25_algorithms/equal.cc +++ b/libstdc++-v3/testsuite/25_algorithms/equal/equal.cc diff --git a/libstdc++-v3/testsuite/25_algorithms/equal_range/1.cc b/libstdc++-v3/testsuite/25_algorithms/equal_range/1.cc new file mode 100644 index 00000000000..9a843e7e421 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal_range/1.cc @@ -0,0 +1,63 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.3.3 [lib.equal.range] + +#include <algorithm> +#include <utility> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using std::equal_range; + +typedef test_container<int, forward_iterator_wrapper> Container; +int array[] = {0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2}; + +void +test1() +{ + for(int i = 0; i < 6; ++i) + for(int j = 6; j < 12; ++j) + { + Container con(array + i, array + j); + VERIFY(equal_range(con.begin(), con.end(), 1).first.ptr == + array + std::max(i, 4)); + VERIFY(equal_range(con.begin(), con.end(), 1).second.ptr == + array + std::min(j, 8)); + } +} + +void +test2() +{ + int array[]={0, 0, 2, 2, 2}; + Container con(array, array + 5); + VERIFY(equal_range(con.begin(), con.end(), 1).first.ptr == + array + 2); + VERIFY(equal_range(con.begin(), con.end(), 1).second.ptr == + array + 2); +} + +int +main() +{ + test1(); + test2(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/equal_range/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/equal_range/check_type.cc new file mode 100644 index 00000000000..6a299c7081b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/equal_range/check_type.cc @@ -0,0 +1,43 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.3.3 [lib.equal.range] + +// { dg-do compile } + +#include <algorithm> +#include <utility> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct S { }; + +bool operator<(const S&, const S&) {return true;} + +struct X { }; + +bool predicate(const X&, const X&) {return true;} + +std::pair<forward_iterator_wrapper<S>, forward_iterator_wrapper<S> > +test1(forward_iterator_wrapper<S>& s) +{ return std::equal_range(s, s, *s); } + +std::pair<forward_iterator_wrapper<X>, forward_iterator_wrapper<X> > +test2(forward_iterator_wrapper<X>& x) +{ return std::equal_range(x, x, *x, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/find/1.cc b/libstdc++-v3/testsuite/25_algorithms/find/1.cc new file mode 100644 index 00000000000..19eb177c770 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find/1.cc @@ -0,0 +1,58 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.2 find + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container<int, input_iterator_wrapper> Container; +int array[] = {0, 0, 0, 1, 0, 1}; + +void +test1() +{ + Container con(array, array); + VERIFY(std::find(con.begin(), con.end(), 1).ptr == array); +} + +void +test2() +{ + Container con(array, array + 1); + VERIFY(std::find(con.begin(), con.end(), 1).ptr == array + 1); +} + +void +test3() +{ + Container con(array, array + 6); + VERIFY(std::find(con.begin(), con.end(), 1).ptr == array + 3); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/find/check_type.cc new file mode 100644 index 00000000000..40bfee8ddca --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find/check_type.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.2 find + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::input_iterator_wrapper; + +struct Lhs { }; +struct Rhs { }; + +bool +operator==(const Lhs&, const Rhs&) +{ return true; } + +input_iterator_wrapper<Lhs> +test1(input_iterator_wrapper<Lhs>& begin, + input_iterator_wrapper<Lhs>& end, Rhs& val) +{ return std::find(begin, end, val); } diff --git a/libstdc++-v3/testsuite/25_algorithms/find_end/1.cc b/libstdc++-v3/testsuite/25_algorithms/find_end/1.cc new file mode 100644 index 00000000000..9120e188f77 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_end/1.cc @@ -0,0 +1,57 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.3 [lib.alg.find.end] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +typedef test_container<int, forward_iterator_wrapper> Container; + +using std::find_end; + +void +test1() +{ + int array[] = {0}; + Container con1(array, array); + Container con2(array, array + 1); + VERIFY(find_end(con1.begin(), con1.end(), con1.begin(), con1.end()).ptr == array); + VERIFY(find_end(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr == array); + VERIFY(find_end(con2.begin(), con2.end(), con1.begin(), con1.end()).ptr == array + 1); +} + +void +test2() +{ + int array1[] = {2, 2, 1, 2, 2, 1}; + int array2[] = {2, 2}; + Container con1(array1, array1 + 6); + Container con2(array2, array2 + 2); + VERIFY(find_end(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr == array1 + 3); +} + +int main() +{ + test1(); + test2(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find_end/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/find_end/check_type.cc new file mode 100644 index 00000000000..1d998a7fa3a --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_end/check_type.cc @@ -0,0 +1,53 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.3 [lib.alg.find.end] + +// { dg-do compile } + + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct Lhs1 { }; + +struct Rhs1 { }; + +bool operator==(const Lhs1&, const Rhs1&) {return true;} + +struct X1 { }; + +struct X2 { }; + +bool predicate(const X1&, const X2&) {return true;} + +forward_iterator_wrapper<Lhs1> +test1(forward_iterator_wrapper<Lhs1>& lhs1, + forward_iterator_wrapper<Rhs1>& rhs1) +{ + return std::find_end(lhs1, lhs1, rhs1, rhs1); +} + +forward_iterator_wrapper<X1> +test2(forward_iterator_wrapper<X1>& x1, + forward_iterator_wrapper<X2>& x2) +{ + return std::find_end(x1, x1, x2, x2, predicate); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find_first_of/1.cc b/libstdc++-v3/testsuite/25_algorithms/find_first_of/1.cc new file mode 100644 index 00000000000..db441bd1a30 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_first_of/1.cc @@ -0,0 +1,58 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.4 [lib.alg.find.first.of] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +typedef test_container<int, forward_iterator_wrapper> Container; + +using std::find_first_of; + +void +test1() +{ + int array[] = {0}; + Container con1(array, array); + Container con2(array, array + 1); + VERIFY(find_first_of(con1.begin(), con1.end(), con1.begin(), con1.end()).ptr == array); + VERIFY(find_first_of(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr == array); + VERIFY(find_first_of(con2.begin(), con2.end(), con1.begin(), con1.end()).ptr == array + 1); +} + +void +test2() +{ + int array1[] = {1 ,2, 3, 4, 5, 6}; + int array2[] = {3, 4, 9}; + Container con1(array1, array1 + 6); + Container con2(array2, array2 + 3); + VERIFY(find_first_of(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr == array1 + 2); +} + +int +main() +{ + test1(); + test2(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find_first_of/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/find_first_of/check_type.cc new file mode 100644 index 00000000000..9a075c91120 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_first_of/check_type.cc @@ -0,0 +1,49 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.4 [lib.alg.find.first.of] + +// { dg-do compile } + + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct Lhs1 { }; + +struct Rhs1 { }; + +bool operator==(const Lhs1&, const Rhs1&) {return true;} + +struct X1 { }; + +struct X2 { }; + +bool predicate(const X1&, const X2&) {return true;} + +forward_iterator_wrapper<Lhs1> +test1(forward_iterator_wrapper<Lhs1>& lhs1, + forward_iterator_wrapper<Rhs1>& rhs1) +{ return std::find_first_of(lhs1, lhs1, rhs1, rhs1); } + +forward_iterator_wrapper<X1> +test2(forward_iterator_wrapper<X1>& x1, + forward_iterator_wrapper<X2>& x2) +{ return std::find_first_of(x1, x1, x2, x2, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/find_if/1.cc b/libstdc++-v3/testsuite/25_algorithms/find_if/1.cc new file mode 100644 index 00000000000..c1d9255ea42 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_if/1.cc @@ -0,0 +1,65 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.2 find_if + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container<int, input_iterator_wrapper> Container; +int array[] = {0, 0, 0, 1, 0, 1}; + +bool +predicate(const int& i) +{ return i == 1; } + +void +test1() +{ + Container con(array, array); + VERIFY(std::find_if(con.begin(), con.end(), + predicate).ptr == array); +} + +void +test2() +{ + Container con(array, array + 1); + VERIFY(std::find_if(con.begin(), con.end(), + predicate).ptr == array + 1); +} + +void +test3() +{ + Container con(array, array + 6); + VERIFY(std::find_if(con.begin(), con.end(), + predicate).ptr == array + 3); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/find_if/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/find_if/check_type.cc new file mode 100644 index 00000000000..8d56be96a9b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/find_if/check_type.cc @@ -0,0 +1,49 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.2 find_if + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +struct X { }; + +using __gnu_test::input_iterator_wrapper; + +bool +pred_function(const X&) +{ return true; } + +struct pred_obj +{ + bool + operator()(const X&) + { return true; } +}; + +input_iterator_wrapper<X> +test1(input_iterator_wrapper<X>& begin, + input_iterator_wrapper<X>& end) +{ return std::find_if(begin, end, pred_function); } + +input_iterator_wrapper<X> +test2(input_iterator_wrapper<X>& begin, + input_iterator_wrapper<X>& end) +{ return std::find_if(begin, end, pred_obj()); } diff --git a/libstdc++-v3/testsuite/25_algorithms/heap.cc b/libstdc++-v3/testsuite/25_algorithms/heap/heap.cc index 6d564f2f9ee..6d564f2f9ee 100644 --- a/libstdc++-v3/testsuite/25_algorithms/heap.cc +++ b/libstdc++-v3/testsuite/25_algorithms/heap/heap.cc diff --git a/libstdc++-v3/testsuite/25_algorithms/includes/1.cc b/libstdc++-v3/testsuite/25_algorithms/includes/1.cc new file mode 100644 index 00000000000..88d1d2b9cf4 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/includes/1.cc @@ -0,0 +1,90 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.5.1 [lib.includes] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using std::includes; + +typedef test_container<int, input_iterator_wrapper> Container; + +void +test1() +{ + bool test __attribute__((unused)) = true; + int array[] = {0}; + Container con1(array, array); + Container con2(array, array); + VERIFY(includes(con1.begin(), con1.end(), con2.begin(), con2.end())); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + int array[] = {0, 1}; + Container con1(array, array); + Container con2(array, array + 2); + VERIFY(!includes(con1.begin(), con1.end(), con2.begin(), con2.end())); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + int array[] = {0, 1}; + Container con1(array, array + 2); + Container con2(array, array); + VERIFY(includes(con1.begin(), con1.end(), con2.begin(), con2.end())); +} + +void +test4() +{ + bool test __attribute__((unused)) = true; + int array1[] = {1, 2, 3, 4, 6, 8, 9}; + int array2[] = {2, 4, 6, 8}; + Container con1(array1, array1 + 7); + Container con2(array2, array2 + 4); + VERIFY(includes(con1.begin(), con1.end(), con2.begin(), con2.end())); +} + +void +test5() +{ + bool test __attribute__((unused)) = true; + int array1[] = {1, 2, 3, 5}; + int array2[] = {2, 4, 6, 8}; + Container con1(array1, array1 + 4); + Container con2(array2, array2 + 4); + VERIFY(!includes(con1.begin(), con1.end(), con2.begin(), con2.end())); +} + +int main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/includes/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/includes/check_type.cc new file mode 100644 index 00000000000..4b1198e787f --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/includes/check_type.cc @@ -0,0 +1,46 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.5.1 [lib.includes] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::input_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) +{ return true; } + +struct X { }; + +bool +predicate(const X&, const X&) +{ return true; } + +bool +test1(input_iterator_wrapper<S>& s) +{ return std::includes(s, s, s, s); } + +bool +test2(input_iterator_wrapper<X>& x) +{ return std::includes(x, x, x, x, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/inplace_merge/1.cc b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/1.cc new file mode 100644 index 00000000000..f53c47e3e74 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/1.cc @@ -0,0 +1,84 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.4 [lib.alg.merge] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::bidirectional_iterator_wrapper; +using std::inplace_merge; + +typedef test_container<int, bidirectional_iterator_wrapper> container; + + +void +test1() +{ + int array[]={1}; + container con1(array, array); + inplace_merge(con1.begin(), con1.end(), con1.end()); + container con2(array, array + 1); + inplace_merge(con2.begin(), con2.end(), con2.end()); + inplace_merge(con2.begin(), con2.begin(), con2.end()); +} + +void +test2() +{ + int array[]={0,2,4,1,3,5}; + container con(array, array + 6); + inplace_merge(con.begin(), con.it(3), con.end()); + VERIFY(array[0] == 0 && array[1] == 1 && array[2] == 2 && + array[3] == 3 && array[4] == 4 && array[5] == 5); +} + +struct S +{ + int a; + int b; + S(int _a, int _b) : a(_a), b(_b) { } + S() { } + bool + operator<(const S& _s) const + { return _s.a < a; } +}; + +void +test3() +{ + S s[4]; + s[0].a = 0; + s[1].a = 1; + s[2].a = 0; + s[3].a = 1; + s[0].b = 0; + s[1].b = 0; + s[2].b = 1; + s[3].b = 1; + inplace_merge(s, s + 2, s + 4); + VERIFY(s[0].b == 0 && s[1].b == 1 && s[2].b == 0 && s[3].b == 1); +} + +int +main() +{ + test1(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/inplace_merge/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/check_type.cc new file mode 100644 index 00000000000..f8cacfa7696 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/inplace_merge/check_type.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.4 [lib.alg.merge] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::bidirectional_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +void +test1(bidirectional_iterator_wrapper<S>& s) +{ + std::inplace_merge(s, s, s); +} + +void +test2(bidirectional_iterator_wrapper<X>& x) +{ + std::inplace_merge(x, x, x, predicate); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/1.cc b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/1.cc new file mode 100644 index 00000000000..8d38dadb8e6 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/1.cc @@ -0,0 +1,86 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.8 [lib.alg.lex.comparison] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container<int, input_iterator_wrapper> Container; +int array1[] = {0, 1}; +int array2[] = {1, 0}; +int array3[] = {1, 0, 1}; + +void +test1() +{ + Container con1(array1, array1); + Container con2(array2, array2); + VERIFY( !std::lexicographical_compare(con1.begin(), con1.end(), + con2.begin(), con2.end()) ); +} + +void +test2() +{ + Container con1(array1, array1 + 2); + Container con2(array2, array2 + 2); + VERIFY( std::lexicographical_compare(con1.begin(), con1.end(), + con2.begin(), con2.end()) ); +} + +void +test3() +{ + Container con1(array1, array1 + 2); + Container con2(array2, array2 + 2); + VERIFY( !std::lexicographical_compare(con2.begin(), con2.end(), + con1.begin(), con1.end()) ); +} + +void +test4() +{ + Container con3(array3, array3 + 3); + Container con2(array2, array2 + 2); + VERIFY( std::lexicographical_compare(con2.begin(), con2.end(), + con3.begin(), con3.end()) ); +} + +void +test5() +{ + Container con3(array3, array3 + 3); + Container con2(array2, array2 + 2); + VERIFY( !std::lexicographical_compare(con3.begin(), con3.end(), + con2.begin(), con2.end()) ); +} + +int +main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/check_type.cc new file mode 100644 index 00000000000..20b594cc06a --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/check_type.cc @@ -0,0 +1,51 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.8 [lib.alg.lex.comparison] + +// { dg-do compile } + + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::input_iterator_wrapper; + +struct Lhs1 { }; + +struct Rhs1 { }; + +bool +operator<(const Lhs1&, const Rhs1&) {return true;} + +bool +operator<(const Rhs1&, const Lhs1&) {return false;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +bool +test1(input_iterator_wrapper<Lhs1>& lhs1, + input_iterator_wrapper<Rhs1>& rhs1) +{ return std::lexicographical_compare(lhs1, lhs1, rhs1, rhs1); } + +bool +test2(input_iterator_wrapper<X>& x) +{ return std::lexicographical_compare(x, x, x, x, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/lower_bound/1.cc b/libstdc++-v3/testsuite/25_algorithms/lower_bound/1.cc new file mode 100644 index 00000000000..baa00c1cd6c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/lower_bound/1.cc @@ -0,0 +1,47 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.3.1 [lib.lower.bound] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using std::lower_bound; + +typedef test_container<int, forward_iterator_wrapper> Container; +int array[] = {0, 0, 0, 0, 1, 1, 1, 1}; + +void +test1() +{ + for(int i = 0; i < 5; ++i) + for(int j = 4; j < 7; ++j) + { + Container con(array + i, array + j); + VERIFY(lower_bound(con.begin(), con.end(), 1).ptr == array + 4); + } +} + +int +main() +{ + test1(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/lower_bound/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/lower_bound/check_type.cc new file mode 100644 index 00000000000..1ba48d33f81 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/lower_bound/check_type.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.3.1 [lib.lower.bound] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +forward_iterator_wrapper<S> +test1(forward_iterator_wrapper<S>& s) +{ return std::lower_bound(s, s, *s); } + +forward_iterator_wrapper<X> +test2(forward_iterator_wrapper<X>& x) +{ return std::lower_bound(x, x, *x, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/lower_bound.cc b/libstdc++-v3/testsuite/25_algorithms/lower_bound/lower_bound.cc index 6afb28fffbc..6afb28fffbc 100644 --- a/libstdc++-v3/testsuite/25_algorithms/lower_bound.cc +++ b/libstdc++-v3/testsuite/25_algorithms/lower_bound/lower_bound.cc diff --git a/libstdc++-v3/testsuite/25_algorithms/max_element/1.cc b/libstdc++-v3/testsuite/25_algorithms/max_element/1.cc new file mode 100644 index 00000000000..02d870baadb --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/max_element/1.cc @@ -0,0 +1,71 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.7 [lib.alg.min.max] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using std::max_element; + +typedef test_container<int, forward_iterator_wrapper> Container; + +void +test1() +{ + // Note: The standard is unclear on what should happen in this case. + // This seems the only really sensible behaviour, and what is done. + int array[] = {0}; + Container con(array, array); + VERIFY(max_element(con.begin(), con.end()).ptr == array); +} + +void +test2() +{ + int array[] = {0}; + Container con(array, array + 1); + VERIFY(max_element(con.begin(), con.end()).ptr == array); +} + +void +test3() +{ + int array[] = {3, 0}; + Container con(array, array + 2); + VERIFY(max_element(con.begin(), con.end()).ptr == array); +} + +void +test4() +{ + int array[] = {0, 3, 6, 2, 6, 4, 0}; + Container con(array, array + 7); + VERIFY(max_element(con.begin(), con.end()).ptr == array + 2); +} + +int main() +{ + test1(); + test2(); + test3(); + test4(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/max_element/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/max_element/check_type.cc new file mode 100644 index 00000000000..f6bae763cc4 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/max_element/check_type.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.7 [lib.alg.min.max] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +forward_iterator_wrapper<S> +test1(forward_iterator_wrapper<S>& s) +{ return std::max_element(s, s); } + +forward_iterator_wrapper<X> +test2(forward_iterator_wrapper<X>& x) +{ return std::max_element(x, x, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/merge/1.cc b/libstdc++-v3/testsuite/25_algorithms/merge/1.cc new file mode 100644 index 00000000000..c0ccd78a97b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/merge/1.cc @@ -0,0 +1,101 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.4 [lib.alg.merge] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; +using std::merge; + +typedef test_container<int, input_iterator_wrapper> Icontainer; +typedef test_container<int, output_iterator_wrapper> Ocontainer; + +void +test1() +{ + int array1[1], array2[1]; + Icontainer con1(array1, array1); + Icontainer con2(array1, array1); + Ocontainer con3(array2, array2); + VERIFY(merge(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2); +} + +void +test2() +{ + int array1[]={0,1,4}; + int array2[]={2,3}; + int array3[5]; + Icontainer con1(array1, array1 + 3); + Icontainer con2(array2, array2 + 2); + Ocontainer con3(array3, array3 + 5); + VERIFY(merge(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array3 + 5); + VERIFY(array3[0] == 0 && array3[1] == 1 && array3[2] == 2 && + array3[3] == 3 && array3[4] == 4); + +} + +struct S +{ + int i; + int j; + S() {} + S(int in) + { + if(in > 0) + { + i = in; + j = 1; + } + else + { + i = -in; + j = 0; + } + } +}; + +bool +operator<(const S& s1, const S& s2) +{ return s1.i < s2.i; } + +void +test3() +{ + S array1[] = { -1 , -3}; + S array2[] = { 1, 2, 3}; + S array3[5]; + merge(array1, array1 + 2, array2, array2 + 3, array3); + VERIFY(array3[0].j == 0 && array3[1].j == 1 && array3[2].j == 1 && + array3[3].j == 0 && array3[4].j == 1); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/merge/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/merge/check_type.cc new file mode 100644 index 00000000000..27681d82dc9 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/merge/check_type.cc @@ -0,0 +1,46 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.4 [lib.alg.merge] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +output_iterator_wrapper<S> +test1(input_iterator_wrapper<S>& in, + output_iterator_wrapper<S>& out) +{ return std::merge(in, in, in, in, out); } + +output_iterator_wrapper<X> +test2(input_iterator_wrapper<X>& in, + output_iterator_wrapper<X>& out) +{ return std::merge(in, in, in, in, out, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/min_element/1.cc b/libstdc++-v3/testsuite/25_algorithms/min_element/1.cc new file mode 100644 index 00000000000..ba9a4a26e77 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/min_element/1.cc @@ -0,0 +1,71 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.7 [lib.alg.min.max] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using std::min_element; + +typedef test_container<int, forward_iterator_wrapper> Container; + +void +test1() +{ + // Note: The standard is unclear on what should happen in this case. + // This seems the only really sensible behaviour, and what is done. + int array[] = {0}; + Container con(array, array); + VERIFY(min_element(con.begin(), con.end()).ptr == array); +} + +void +test2() +{ + int array[] = {0}; + Container con(array, array + 1); + VERIFY(min_element(con.begin(), con.end()).ptr == array); +} + +void +test3() +{ + int array[] = {0, 3}; + Container con(array, array + 2); + VERIFY(min_element(con.begin(), con.end()).ptr == array); +} + +void +test4() +{ + int array[] = {6, 3, 0, 2, 6, 4, 0}; + Container con(array, array + 7); + VERIFY(min_element(con.begin(), con.end()).ptr == array + 2); +} + +int main() +{ + test1(); + test2(); + test3(); + test4(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/min_element/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/min_element/check_type.cc new file mode 100644 index 00000000000..e4ff8d341b5 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/min_element/check_type.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.7 [lib.alg.min.max] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +forward_iterator_wrapper<S> +test1(forward_iterator_wrapper<S>& s) +{ return std::min_element(s,s); } + +forward_iterator_wrapper<X> +test2(forward_iterator_wrapper<X>& x) +{ return std::min_element(x,x,predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/mismatch/1.cc b/libstdc++-v3/testsuite/25_algorithms/mismatch/1.cc new file mode 100644 index 00000000000..a75405999a3 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/mismatch/1.cc @@ -0,0 +1,89 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.7 [lib.mismatch] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; + +typedef test_container<int, input_iterator_wrapper> Container; +int array1[] = {0, 1}; +int array2[] = {1, 0}; +int array3[] = {1, 0, 1}; + +void test1a() +{ + Container con1(array1, array1); + Container con2(array2, array2); + VERIFY( std::mismatch(con1.begin(), con1.end(), con2.begin()).first.ptr + == array1 ); +} + +void test1b() +{ + Container con1(array1, array1); + Container con2(array2, array2); + VERIFY( std::mismatch(con1.begin(), con1.end(), con2.begin()).second.ptr + == array2 ); +} + +void test2a() +{ + Container con1(array1, array1 + 2); + Container con2(array2, array2 + 2); + VERIFY( std::mismatch(con1.begin(), con1.end(), con2.begin()).first.ptr + == array1 ); +} + +void test2b() +{ + Container con1(array1, array1 + 2); + Container con2(array2, array2 + 2); + VERIFY( std::mismatch(con1.begin(), con1.end(), con2.begin()).second.ptr + == array2 ); +} + +void test3a() +{ + Container con3(array3, array3 + 2); + Container con2(array2, array2 + 2); + VERIFY( std::mismatch(con3.begin(), con3.end(), con2.begin()).first.ptr + == array3 + 2 ); +} + +void test3b() +{ + Container con3(array3, array3 + 2); + Container con2(array2, array2 + 2); + VERIFY( std::mismatch(con3.begin(), con3.end(), con2.begin()).second.ptr + == array2 + 2 ); +} + +int main() +{ + test1a(); + test1b(); + test2a(); + test2b(); + test3a(); + test3b(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/mismatch/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/mismatch/check_type.cc new file mode 100644 index 00000000000..45f46296768 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/mismatch/check_type.cc @@ -0,0 +1,51 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.7 [lib.mismatch] + +// { dg-do compile } + +#include <algorithm> +#include <utility> +#include <testsuite_iterators.h> + +using __gnu_test::input_iterator_wrapper; + +struct Lhs1 { }; + +struct Rhs1 { }; + +bool operator==(const Lhs1&, const Rhs1&) {return true;} + +struct Lhs2 { }; + +struct Rhs2 { }; + +bool predicate(const Lhs2&, const Rhs2&) {return true;} + +std::pair<input_iterator_wrapper<Lhs1>, input_iterator_wrapper<Rhs1> > +test1(input_iterator_wrapper<Lhs1>& lhs1, input_iterator_wrapper<Rhs1>& rhs1) +{ + return std::mismatch(lhs1, lhs1, rhs1); +} + +std::pair<input_iterator_wrapper<Lhs2>, input_iterator_wrapper<Rhs2> > +test2(input_iterator_wrapper<Lhs2>& lhs2, input_iterator_wrapper<Rhs2>& rhs2) +{ + return std::mismatch(lhs2, lhs2, rhs2, predicate); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/next_permutation/1.cc b/libstdc++-v3/testsuite/25_algorithms/next_permutation/1.cc new file mode 100644 index 00000000000..4c0496c9d36 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/next_permutation/1.cc @@ -0,0 +1,84 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.9 [lib.alg.permutation.generators] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::bidirectional_iterator_wrapper; +using std::next_permutation; + +typedef test_container<int, bidirectional_iterator_wrapper> Container; + +void +test1() +{ + // Note: The standard is unclear on what should happen in this case. + // This seems the only really sensible behaviour, and what is done. + int array[] = {0}; + Container con(array, array); + VERIFY(!next_permutation(con.begin(), con.end())); +} + +void +test2() +{ + int array[] = {0}; + Container con(array, array + 1); + VERIFY(!next_permutation(con.begin(), con.end())); +} + +void +test3() +{ + int array[] = {0, 3}; + Container con(array, array + 2); + VERIFY(next_permutation(con.begin(), con.end())); + VERIFY(array[0] == 3 && array[1] == 0); + VERIFY(!next_permutation(con.begin(), con.end())); + VERIFY(array[0] == 0 && array[1] == 3); +} + +void +test4() +{ + int array[6] = {0, 1, 2, 3, 4, 5}; + Container con(array, array + 6); + for(int i = 0 ; i < 719; ++i) + { + int temp_array[6]; + std::copy(array, array + 6, temp_array); + VERIFY(next_permutation(array, array + 6)); + VERIFY(std::lexicographical_compare(temp_array, temp_array + 6, + array, array + 6)); + } + VERIFY(!next_permutation(array,array + 6)); + for(int i = 0; i < 6; ++i) + VERIFY(array[i] == i); +} + +int main() +{ + test1(); + test2(); + test3(); + test4(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/next_permutation/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/next_permutation/check_type.cc new file mode 100644 index 00000000000..15aff15e08b --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/next_permutation/check_type.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.9 [lib.alg.permutation.generators] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::bidirectional_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +bool +test1(bidirectional_iterator_wrapper<S>& s) +{ return std::next_permutation(s,s); } + +bool +test2(bidirectional_iterator_wrapper<X>& x) +{ return std::next_permutation(x,x,predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/nth_element/1.cc b/libstdc++-v3/testsuite/25_algorithms/nth_element/1.cc new file mode 100644 index 00000000000..469e64bedf5 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/nth_element/1.cc @@ -0,0 +1,79 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.2 [lib.alg.nth.element] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using std::nth_element; + +typedef test_container<int, random_access_iterator_wrapper> Container; + +void +test1() +{ + int array[]={0}; + Container con(array, array); + partial_sort(con.begin(), con.begin(), con.end()); +} + +void +test2() +{ + int array[]={2,1,0}; + Container con(array, array + 2); + partial_sort(con.begin(), con.begin(), con.end()); + partial_sort(con.begin(), con.end(), con.end()); +} + +void +test3() +{ + int array[] = {6, 5, 4, 3, 2, 1, 0}; + Container con(array, array + 7); + nth_element(con.begin(), con.it(3), con.end()); + for(int i = 0; i < 3; ++i) + VERIFY(array[i] < array[3]); + for(int i = 4; i < 7; ++i) + VERIFY(array[3] < array[i]); +} + +void +test4() +{ + int array[] = {0, 6, 1, 5, 2, 4, 3}; + Container con(array,array + 7); + nth_element(con.begin(), con.it(3), con.end()); + for(int i = 0; i < 3; ++i) + VERIFY(array[i] < array[3]); + for(int i = 4; i < 7; ++i) + VERIFY(array[3] < array[i]); +} + +int +main() +{ + test1(); + test2(); + test3(); + test4(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/nth_element/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/nth_element/check_type.cc new file mode 100644 index 00000000000..3fd1ebadb2a --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/nth_element/check_type.cc @@ -0,0 +1,45 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.2 [lib.alg.nth.element] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::random_access_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +void +test1(random_access_iterator_wrapper<S>& s) +{ std::nth_element(s, s, s); } + +void +test2(random_access_iterator_wrapper<X>& x) +{ std::nth_element(x, x, x, predicate); } + diff --git a/libstdc++-v3/testsuite/25_algorithms/partial_sort/1.cc b/libstdc++-v3/testsuite/25_algorithms/partial_sort/1.cc new file mode 100644 index 00000000000..35c64ca0665 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partial_sort/1.cc @@ -0,0 +1,66 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.1.3 [lib.partial.sort] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using std::partial_sort; + +typedef test_container<int, random_access_iterator_wrapper> Container; + +void +test1() +{ + int array[]={2,1,0}; + Container con1(array, array + 2); + Container con2(array, array); + partial_sort(con2.begin(), con2.begin(), con2.end()); + partial_sort(con1.begin(), con1.begin(), con1.end()); + partial_sort(con1.begin(), con1.end(), con1.end()); +} + +void +test2() +{ + int array[] = {6, 5, 4, 3, 2, 1, 0}; + Container con(array, array + 7); + partial_sort(con.begin(), con.it(3), con.end()); + VERIFY(array[0] == 0 && array[1] == 1 && array[2] == 2); +} + +void +test3() +{ + int array[] = {0, 6, 1, 5, 2, 4, 3}; + Container con(array,array + 7); + partial_sort(con.begin(), con.it(3), con.end()); + VERIFY(array[0] == 0 && array[1] == 1 && array[2] == 2); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/partial_sort/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/partial_sort/check_type.cc new file mode 100644 index 00000000000..1a6a2e0fec8 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partial_sort/check_type.cc @@ -0,0 +1,49 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.1.3 [lib.partial.sort] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::random_access_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +void +test1(random_access_iterator_wrapper<S>& s) +{ + std::partial_sort(s, s, s); +} + +void +test2(random_access_iterator_wrapper<X>& x) +{ + std::partial_sort(x, x, x, predicate); +} + diff --git a/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/1.cc b/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/1.cc new file mode 100644 index 00000000000..0b7263d3e30 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/1.cc @@ -0,0 +1,89 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.1.4 [lib.partial.sort.copy] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using __gnu_test::input_iterator_wrapper; +using std::partial_sort_copy; + +typedef test_container<int, random_access_iterator_wrapper> Rcontainer; +typedef test_container<int, input_iterator_wrapper> Icontainer; + +void +test1() +{ + int array[]={2,1,0}; + Rcontainer rcon1(array, array); + Rcontainer rcon2(array, array + 2); + Icontainer icon1(array, array); + Icontainer icon2(array, array + 2); + partial_sort_copy(icon1.begin(), icon1.end(), rcon1.begin(), rcon1.end()); + partial_sort_copy(icon1.begin(), icon1.end(), rcon2.begin(), rcon2.end()); + partial_sort_copy(icon2.begin(), icon2.end(), rcon1.begin(), rcon1.end()); + partial_sort_copy(icon2.begin(), icon2.end(), rcon2.begin(), rcon2.end()); +} + +void +test2() +{ + int array1[] = {4, 3, 2, 1, 0}; + int array2[5]; + Icontainer icon(array1, array1 + 5); + Rcontainer rcon(array2, array2 + 5); + partial_sort_copy(icon.begin(), icon.end(), rcon.begin(), rcon.end()); + VERIFY(array2[0] == 0 && array2[1] == 1 && array2[2] == 2 && + array2[3] == 3 && array2[4] == 4); +} + +void +test3() +{ + int array1[] = {4, 0, 1, 3, 2}; + int array2[5]; + Icontainer icon(array1, array1 + 5); + Rcontainer rcon(array2, array2 + 2); + partial_sort_copy(icon.begin(), icon.end(), rcon.begin(), rcon.end()); + VERIFY(array2[0] == 0 && array2[1] == 1); +} + +void +test4() +{ + int array1[] = {4, 1, 3, 2, 0}; + int array2[20]; + Icontainer icon(array1, array1 + 5); + Rcontainer rcon(array2, array2 + 20); + partial_sort_copy(icon.begin(), icon.end(), rcon.begin(), rcon.end()); + VERIFY(array2[0] == 0 && array2[1] == 1 && array2[2] == 2 && + array2[3] == 3 && array2[4] == 4); +} + +int +main() +{ + test1(); + test2(); + test3(); + test4(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/check_type.cc new file mode 100644 index 00000000000..140f15bcc4d --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/partial_sort_copy/check_type.cc @@ -0,0 +1,68 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.1.4 [lib.partial.sort.copy] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::input_iterator_wrapper; +using __gnu_test::random_access_iterator_wrapper; + +struct S1 { }; +struct S2 +{ + S2(const S1&) {} + S2() {} +}; + +bool +operator<(const S1&, const S1&) +{return true;} + +bool +operator<(const S2&, const S2&) +{return true;} + +struct X1 { }; +struct X2 +{ + X2(const X1&) {} + X2() {} +}; + +struct predicate +{ + bool + operator()(const X1&, const X1&) + {return true;} + + bool + operator()(const X2&, const X2&) + {return true;} +}; + +random_access_iterator_wrapper<S2> +test1(input_iterator_wrapper<S1>& s1, random_access_iterator_wrapper<S2>& s2) +{ return std::partial_sort_copy(s1, s1, s2, s2); } + +random_access_iterator_wrapper<X2> +test2(input_iterator_wrapper<X1>& x1, random_access_iterator_wrapper<X2>& x2) +{ return std::partial_sort_copy(x1, x1, x2, x2, predicate()); } diff --git a/libstdc++-v3/testsuite/25_algorithms/partition.cc b/libstdc++-v3/testsuite/25_algorithms/partition/partition.cc index b05c203bd32..b05c203bd32 100644 --- a/libstdc++-v3/testsuite/25_algorithms/partition.cc +++ b/libstdc++-v3/testsuite/25_algorithms/partition/partition.cc diff --git a/libstdc++-v3/testsuite/25_algorithms/prev_permutation/1.cc b/libstdc++-v3/testsuite/25_algorithms/prev_permutation/1.cc new file mode 100644 index 00000000000..530e032d7fc --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/prev_permutation/1.cc @@ -0,0 +1,84 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.9 [lib.alg.permutation.generators] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::bidirectional_iterator_wrapper; +using std::prev_permutation; + +typedef test_container<int, bidirectional_iterator_wrapper> Container; + +void +test1() +{ + // Note: The standard is unclear on what should happen in this case. + // This seems the only really sensible behaviour, and what is done. + int array[] = {0}; + Container con(array, array); + VERIFY(!prev_permutation(con.begin(), con.end())); +} + +void +test2() +{ + int array[] = {0}; + Container con(array, array + 1); + VERIFY(!prev_permutation(con.begin(), con.end())); +} + +void +test3() +{ + int array[] = {3, 0}; + Container con(array, array + 2); + VERIFY(prev_permutation(con.begin(), con.end())); + VERIFY(array[0] == 0 && array[1] == 3); + VERIFY(!prev_permutation(con.begin(), con.end())); + VERIFY(array[0] == 3 && array[1] == 0); +} + +void +test4() +{ + int array[6] = {5, 4, 3, 2, 1, 0}; + Container con(array, array + 6); + for(int i = 0 ; i < 719; ++i) + { + int temp_array[6]; + std::copy(array, array + 6, temp_array); + VERIFY(prev_permutation(array, array + 6)); + VERIFY(std::lexicographical_compare(array, array + 6, + temp_array, temp_array + 6)); + } + VERIFY(!prev_permutation(array,array + 6)); + for(int i = 0; i < 6; ++i) + VERIFY(array[i] == 5 - i); +} + +int main() +{ + test1(); + test2(); + test3(); + test4(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/prev_permutation/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/prev_permutation/check_type.cc new file mode 100644 index 00000000000..f0fafc60cff --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/prev_permutation/check_type.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.9 [lib.alg.permutation.generators] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::bidirectional_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +bool +test1(bidirectional_iterator_wrapper<S>& s) +{ return std::prev_permutation(s,s); } + +bool +test2(bidirectional_iterator_wrapper<X>& x) +{ return std::prev_permutation(x,x,predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/remove/1.cc b/libstdc++-v3/testsuite/25_algorithms/remove/1.cc new file mode 100644 index 00000000000..95ac53c1ba5 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove/1.cc @@ -0,0 +1,63 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.4 remove + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +typedef test_container<int, forward_iterator_wrapper> Container; + +void +test1() +{ + int array[1]; + Container con(array, array); + VERIFY(std::remove(con.begin(), con.end(), 1).ptr == array); +} + +void +test2() +{ + int array[] = {1}; + Container con(array, array + 1); + VERIFY(std::remove(con.begin(), con.end(), 0).ptr == array + 1); + VERIFY(std::remove(con.begin(), con.end(), 1).ptr == array); +} + +void +test3() +{ + int array[] = {0, 1, 0, 1, 0, 0, 1, 1}; + Container con(array, array + 8); + VERIFY(std::remove(con.begin(), con.end(), 1).ptr == array + 4); + VERIFY(array[0] == 0 && array[1] == 0 && array[2] == 0 && + array[3] == 0); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/remove/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/remove/check_type.cc new file mode 100644 index 00000000000..46a44de1cb9 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove/check_type.cc @@ -0,0 +1,39 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.7 Remove + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct X { }; + +struct Y { }; + +bool +operator==(const X&, const Y&) +{ return true; } + +forward_iterator_wrapper<X> +test1(forward_iterator_wrapper<X>& begin, + forward_iterator_wrapper<X>& end, const Y& val) +{ return std::remove(begin, end, val); } diff --git a/libstdc++-v3/testsuite/25_algorithms/remove_if/1.cc b/libstdc++-v3/testsuite/25_algorithms/remove_if/1.cc new file mode 100644 index 00000000000..b72e02491aa --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove_if/1.cc @@ -0,0 +1,66 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.4 remove + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +typedef test_container<int, forward_iterator_wrapper> Container; + +bool equal1(int val) { return val == 1; } +bool equal0(int val) { return val == 0; } + +void +test1() +{ + int array[1]; + Container con(array, array); + VERIFY(std::remove_if(con.begin(), con.end(), equal1).ptr == array); +} + +void +test2() +{ + int array[] = {1}; + Container con(array, array + 1); + VERIFY(std::remove_if(con.begin(), con.end(), equal0).ptr == array + 1); + VERIFY(std::remove_if(con.begin(), con.end(), equal1).ptr == array); +} + +void +test3() +{ + int array[] = {0, 1, 0, 1, 0, 0, 1, 1}; + Container con(array, array + 8); + VERIFY(std::remove_if(con.begin(), con.end(), equal1).ptr == array + 4); + VERIFY(array[0] == 0 && array[1] == 0 && array[2] == 0 && + array[3] == 0); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/remove_if/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/remove_if/check_type.cc new file mode 100644 index 00000000000..dbcde808bfb --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/remove_if/check_type.cc @@ -0,0 +1,50 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.7 Remove_if + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct X { }; + +bool +pred_fn(const X&) +{ return true; } + +struct pred_obj +{ + bool + operator()(const X&) const + { return true; } +}; + +forward_iterator_wrapper<X> +test1(forward_iterator_wrapper<X>& begin, + forward_iterator_wrapper<X>& end) +{ return std::remove_if(begin, end, pred_fn); } + +forward_iterator_wrapper<X> +test2(forward_iterator_wrapper<X>& begin, + forward_iterator_wrapper<X>& end) +{ return std::remove_if(begin, end, pred_obj()); } + diff --git a/libstdc++-v3/testsuite/25_algorithms/replace/1.cc b/libstdc++-v3/testsuite/25_algorithms/replace/1.cc new file mode 100644 index 00000000000..4878855dccd --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace/1.cc @@ -0,0 +1,61 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.4 replace + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +typedef test_container<int, forward_iterator_wrapper> Container; +int array[] = {0, 0, 0, 1, 0, 1}; + +void +test1() +{ + Container con(array, array); + std::replace(con.begin(), con.end(), 1, 1); +} + +void +test2() +{ + Container con(array, array + 1); + std::replace(con.begin(), con.end(), 0, 1); + VERIFY(array[0] == 1); +} + +void +test3() +{ + Container con(array, array + 6); + std::replace(con.begin(), con.end(), 1, 2); + VERIFY(array[0] == 2 && array[1] == 0 && array[2] == 0 && + array[3] == 2 && array[4] == 0 && array[5] == 2); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/replace/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/replace/check_type.cc new file mode 100644 index 00000000000..083342192ab --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace/check_type.cc @@ -0,0 +1,38 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.4 Replace + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct X { }; + +bool +operator==(const X&, const X&) +{ return true; } + +void +test1(forward_iterator_wrapper<X>& begin, + forward_iterator_wrapper<X>& end, const X& old_val, + const X& new_val) +{ return std::replace(begin, end, old_val, new_val); } diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_copy/1.cc b/libstdc++-v3/testsuite/25_algorithms/replace_copy/1.cc new file mode 100644 index 00000000000..ebaea0cb666 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace_copy/1.cc @@ -0,0 +1,72 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.4 replace_copy + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +typedef test_container<int, input_iterator_wrapper> Icontainer; +typedef test_container<int, output_iterator_wrapper> Ocontainer; +int array[] = {0, 0, 0, 1, 0, 1}; + +void +test1() +{ + int out[1]; + Icontainer in_con(array, array); + Ocontainer out_con(out, out); + VERIFY(std::replace_copy(in_con.begin(), in_con.end(), + out_con.begin(), 1, 1).ptr == out); +} + +void +test2() +{ + int out[1]; + Icontainer in_con(array, array + 1); + Ocontainer out_con(out, out + 1); + VERIFY(std::replace_copy(in_con.begin(), in_con.end(), + out_con.begin(), 0, 1).ptr == out + 1); + VERIFY(out[0] == 1); +} + +void +test3() +{ + int out[6]; + Icontainer in_con(array, array + 6); + Ocontainer out_con(out, out + 6); + VERIFY(std::replace_copy(in_con.begin(), in_con.end(), + out_con.begin(), 1, 2).ptr == out + 6); + VERIFY(out[0] == 0 && out[1] == 0 && out[2] == 0 && + out[3] == 2 && out[4] == 0 && out[5] == 2); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_copy/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/replace_copy/check_type.cc new file mode 100644 index 00000000000..1a19a16e4ac --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace_copy/check_type.cc @@ -0,0 +1,56 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.4 replace_copy + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct X { }; + +struct Y { }; + +struct Z +{ + Z& + operator=(const X&) + { } + + Z& + operator=(const Y&) + { } +}; + +bool +operator==(const X&, const Y&) +{ return true; } + +output_iterator_wrapper<Z> +test1(input_iterator_wrapper<X>& begin, + input_iterator_wrapper<X>& end, + output_iterator_wrapper<Z>& output, + const Y& old_val, const Y& new_val) +{ + return std::replace_copy(begin, end, output, old_val, + new_val); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/1.cc b/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/1.cc new file mode 100644 index 00000000000..2c9c32d67dd --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/1.cc @@ -0,0 +1,76 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.4 replace_copy_if + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +typedef test_container<int, input_iterator_wrapper> Icontainer; +typedef test_container<int, output_iterator_wrapper> Ocontainer; +int array[] = {0, 0, 0, 1, 0, 1}; + +bool +pred(int i) +{ return i == 1; } + +void +test1() +{ + int out[1]; + Icontainer in_con(array, array); + Ocontainer out_con(out, out); + VERIFY(std::replace_copy_if(in_con.begin(), in_con.end(), + out_con.begin(), pred, 1).ptr == out); +} + +void +test2() +{ + int out[1]; + Icontainer in_con(array, array + 1); + Ocontainer out_con(out, out + 1); + VERIFY(std::replace_copy_if(in_con.begin(), in_con.end(), + out_con.begin(), pred, 2).ptr == out + 1); + VERIFY(out[0] == 0); +} + +void +test3() +{ + int out[6]; + Icontainer in_con(array, array + 6); + Ocontainer out_con(out, out + 6); + VERIFY(std::replace_copy_if(in_con.begin(), in_con.end(), + out_con.begin(), pred, 2).ptr == out + 6); + VERIFY(out[0] == 0 && out[1] == 0 && out[2] == 0 && + out[3] == 2 && out[4] == 0 && out[5] == 2); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/check_type.cc new file mode 100644 index 00000000000..55b90402242 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace_copy_if/check_type.cc @@ -0,0 +1,56 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.4 replace_copy_if + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct X { }; + +struct Y { }; + +struct Z +{ + Z& + operator=(const X&) + { } + + Z& + operator=(const Y&) + { } +}; + +bool +predicate(const X&) +{ return true; } + +output_iterator_wrapper<Z> +test1(input_iterator_wrapper<X>& begin, + input_iterator_wrapper<X>& end, + output_iterator_wrapper<Z>& output, + const Y& new_val) +{ + return std::replace_copy_if(begin, end, output, predicate, + new_val); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_if/1.cc b/libstdc++-v3/testsuite/25_algorithms/replace_if/1.cc new file mode 100644 index 00000000000..98cf1f3dde1 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace_if/1.cc @@ -0,0 +1,65 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.4 replace_if + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +typedef test_container<int, forward_iterator_wrapper> Container; +int array[] = {1, 0, 0, 1, 0, 1}; + +bool +predicate(const int& i) +{ return i == 1; } + +void +test1() +{ + Container con(array, array); + std::replace_if(con.begin(), con.end(), predicate, 1); +} + +void +test2() +{ + Container con(array, array + 1); + std::replace_if(con.begin(), con.end(), predicate, 2); + VERIFY(array[0] == 2); +} + +void +test3() +{ + Container con(array, array + 6); + std::replace_if(con.begin(), con.end(), predicate, 3); + VERIFY(array[0] == 2 && array[1] == 0 && array[2] == 0 && + array[3] == 3 && array[4] == 0 && array[5] == 3); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/replace_if/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/replace_if/check_type.cc new file mode 100644 index 00000000000..b8adaec9fcc --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/replace_if/check_type.cc @@ -0,0 +1,52 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.4 replace_if + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct X { }; + +bool +pred_fn(const X&) +{ return true; } + +struct pred_obj +{ + bool + operator()(const X&) + { return true; } +}; + + +void +test1(forward_iterator_wrapper<X>& begin, + forward_iterator_wrapper<X>& end, const X& new_val) +{ return std::replace_if(begin, end, pred_fn, new_val); } + +void +test2(forward_iterator_wrapper<X>& begin, + forward_iterator_wrapper<X>& end, const X& new_val) +{ return std::replace_if(begin, end, pred_obj(), new_val); } + + diff --git a/libstdc++-v3/testsuite/25_algorithms/rotate/1.cc b/libstdc++-v3/testsuite/25_algorithms/rotate/1.cc new file mode 100644 index 00000000000..be41d57bc99 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/rotate/1.cc @@ -0,0 +1,126 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.10 rotate + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using __gnu_test::bidirectional_iterator_wrapper; +using __gnu_test::random_access_iterator_wrapper; + +typedef test_container<int, forward_iterator_wrapper> Fcontainer; +typedef test_container<int, bidirectional_iterator_wrapper> Bcontainer; +typedef test_container<int, random_access_iterator_wrapper> Rcontainer; + + + +void +test1() +{ + bool test __attribute__((unused)) = true; + int array[]={1}; + Fcontainer fcon(array, array); + Bcontainer bcon(array, array); + Rcontainer rcon(array, array); + std::rotate(fcon.begin(), fcon.begin(), fcon.end()); + std::rotate(bcon.begin(), bcon.begin(), bcon.end()); + std::rotate(rcon.begin(), rcon.begin(), rcon.end()); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + int array[] = {1}; + Fcontainer fcon(array, array + 1); + Bcontainer bcon(array, array + 1); + Rcontainer rcon(array, array + 1); + std::rotate(fcon.begin(), fcon.begin(), fcon.end()); + std::rotate(bcon.begin(), bcon.begin(), bcon.end()); + std::rotate(rcon.begin(), rcon.begin(), rcon.end()); + std::rotate(fcon.begin(), fcon.end(), fcon.end()); + std::rotate(bcon.begin(), bcon.end(), bcon.end()); + std::rotate(rcon.begin(), rcon.end(), rcon.end()); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + int array[] = {1, 2, 3, 4, 5}; + Fcontainer fcon(array, array + 5); + Bcontainer bcon(array, array + 5); + Rcontainer rcon(array, array + 5); + std::rotate(fcon.begin(), fcon.it(2), fcon.end()); + VERIFY(array[0] == 3 && array[1] == 4 && array[2] == 5 && + array[3] == 1 && array[4] == 2); + std::rotate(bcon.begin(), bcon.it(2), bcon.end()); + VERIFY(array[0] == 5 && array[1] == 1 && array[2] == 2 && + array[3] == 3 && array[4] == 4); + std::rotate(rcon.begin(), rcon.it(2), rcon.end()); + VERIFY(array[0] == 2 && array[1] == 3 && array[2] == 4 && + array[3] == 5 && array[4] == 1); +} + +void +test4() +{ + bool test __attribute__((unused)) = true; + int array[] = {1, 2, 3, 4}; + Fcontainer fcon(array, array + 4); + Bcontainer bcon(array, array + 4); + Rcontainer rcon(array, array + 4); + + std::rotate(fcon.begin(), fcon.it(3), fcon.end()); + VERIFY(array[0] == 4 && array[1] == 1 && array[2] == 2 && + array[3] == 3); + + std::rotate(bcon.begin(), bcon.it(3), bcon.end()); + VERIFY(array[0] == 3 && array[1] == 4 && array[2] == 1 && + array[3] == 2); + + std::rotate(rcon.begin(), rcon.it(3), rcon.end()); + VERIFY(array[0] == 2 && array[1] == 3 && array[2] == 4 && + array[3] == 1); + +} + +void +test5() +{ + bool test __attribute__((unused)) = true; + int array[] = {1, 2, 3, 4}; + Rcontainer con(array, array + 4); + std::rotate(con.begin(), con.it(2), con.end()); + VERIFY(array[0] == 3 && array[1] == 4 && array[2] == 1 && + array[3] == 2); +} + +int +main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/rotate/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/rotate/check_type.cc new file mode 100644 index 00000000000..31b7123954c --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/rotate/check_type.cc @@ -0,0 +1,48 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.10 Rotate + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +struct X { }; + +bool operator<(X,X) { return true;} + +void +test1(__gnu_test::forward_iterator_wrapper<X>& begin, + __gnu_test::forward_iterator_wrapper<X>& middle, + __gnu_test::forward_iterator_wrapper<X>& end) +{ return std::rotate(begin,middle,end); } + +void +test1(__gnu_test::bidirectional_iterator_wrapper<X>& begin, + __gnu_test::bidirectional_iterator_wrapper<X>& middle, + __gnu_test::bidirectional_iterator_wrapper<X>& end) +{ return std::rotate(begin,middle,end); } + +void +test1(__gnu_test::random_access_iterator_wrapper<X>& begin, + __gnu_test::random_access_iterator_wrapper<X>& middle, + __gnu_test::random_access_iterator_wrapper<X>& end) +{ return std::rotate(begin,middle,end); } + + diff --git a/libstdc++-v3/testsuite/25_algorithms/rotate.cc b/libstdc++-v3/testsuite/25_algorithms/rotate/rotate.cc index 00768a230c8..00768a230c8 100644 --- a/libstdc++-v3/testsuite/25_algorithms/rotate.cc +++ b/libstdc++-v3/testsuite/25_algorithms/rotate/rotate.cc diff --git a/libstdc++-v3/testsuite/25_algorithms/search/1.cc b/libstdc++-v3/testsuite/25_algorithms/search/1.cc new file mode 100644 index 00000000000..5a0ed51cb68 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/search/1.cc @@ -0,0 +1,113 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.5 [lib.alg.search] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using std::search; + +typedef test_container<int, forward_iterator_wrapper> Container; +int array1[] = {0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1}; +int array2[] = {0, 0, 0}; + +void +test1() +{ + bool test __attribute__((unused)) = true; + Container con1(array1, array1); + Container con2(array1, array1 + 1); + VERIFY(search(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr == array1); + VERIFY(search(con2.begin(), con2.end(), con1.begin(), con1.end()).ptr == array1); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + Container con1(array1, array1 + 3); + Container con2(array2, array2 + 3); + VERIFY(search(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr + == array1); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + Container con1(array1 + 3, array1 + 10); + Container con2(array2, array2 + 3); + VERIFY(search(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr + == array1 + 10); +} + +void +test4() +{ + bool test __attribute__((unused)) = true; + Container con1(array1, array1 + 10); + Container con2(array2, array2 + 1); + VERIFY(search(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr + == array1); +} + +void +test5() +{ + bool test __attribute__((unused)) = true; + Container con1(array1 + 6, array1 + 10); + Container con2(array2, array2 + 1); + VERIFY(search(con1.begin(), con1.end(), con2.begin(), con2.end()).ptr + == array1 + 10); +} + +void +test6() +{ + bool test __attribute__((unused)) = true; + int array3[]={2, 2, 1, 2, 3, 5}; + int array4[]={1, 2, 3, 4}; + Container con1(array3, array3 + 3); + Container con2(array3, array3 + 4); + Container con3(array3, array3 + 5); + Container con4(array3, array3 + 6); + Container endcon(array4, array4 + 4); + VERIFY(search(con1.begin(), con1.end(), endcon.begin(), endcon.end()).ptr + == array3 + 3); + VERIFY(search(con2.begin(), con2.end(), endcon.begin(), endcon.end()).ptr + == array3 + 4); + VERIFY(search(con3.begin(), con3.end(), endcon.begin(), endcon.end()).ptr + == array3 + 5); + VERIFY(search(con4.begin(), con4.end(), endcon.begin(), endcon.end()).ptr + == array3 + 6); +} + +int +main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); + test6(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/search/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/search/check_type.cc new file mode 100644 index 00000000000..9e3a587f2b7 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/search/check_type.cc @@ -0,0 +1,46 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.9 [lib.alg.search] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct S1 { }; +struct S2 { }; + +bool +operator==(const S1&, const S2&) {return true;} + +struct X1 { }; +struct X2 { }; + +bool +predicate(const X1&, const X2&) {return true;} + +forward_iterator_wrapper<S1> +test1(forward_iterator_wrapper<S1>& s1, forward_iterator_wrapper<S2>& s2) +{ return std::search(s1, s1, s2, s2); } + +forward_iterator_wrapper<X1> +test2(forward_iterator_wrapper<X1>& x1, forward_iterator_wrapper<X2>& x2) +{ return std::search(x1, x1, x2, x2, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/search_n/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/search_n/check_type.cc new file mode 100644 index 00000000000..dd4073ff308 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/search_n/check_type.cc @@ -0,0 +1,39 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.1.9 search_n + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct X { }; + +struct Y { }; + +bool +operator==(const X&, const Y&) +{ return true; } + +forward_iterator_wrapper<X> +test1(forward_iterator_wrapper<X>& begin, + forward_iterator_wrapper<X>& end, int i, Y& value) +{ return std::search_n(begin, end, i , value); } diff --git a/libstdc++-v3/testsuite/25_algorithms/search_n/iterator.cc b/libstdc++-v3/testsuite/25_algorithms/search_n/iterator.cc index f822745be22..fea009d2775 100644 --- a/libstdc++-v3/testsuite/25_algorithms/search_n/iterator.cc +++ b/libstdc++-v3/testsuite/25_algorithms/search_n/iterator.cc @@ -76,7 +76,7 @@ int main() { { test_container<int, forward_iterator_wrapper> forwardcon(array2, array2 + i); - test_container<int, bidirectional_iterator_wrapper> + test_container<int, random_access_iterator_wrapper> randomcon(array2, array2 + i); test_container<int, bidirectional_iterator_wrapper> bidircon(array2, array2 + i); diff --git a/libstdc++-v3/testsuite/25_algorithms/set_difference/1.cc b/libstdc++-v3/testsuite/25_algorithms/set_difference/1.cc new file mode 100644 index 00000000000..9d0fbe62639 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_difference/1.cc @@ -0,0 +1,132 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.5.3 [lib.set.difference] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; +using std::set_difference; + +typedef test_container<int, input_iterator_wrapper> Icontainer; +typedef test_container<int, output_iterator_wrapper> Ocontainer; + +void +test1() +{ + int array1[1], array2[1]; + Icontainer con1(array1, array1); + Icontainer con2(array1, array1); + Ocontainer con3(array2, array2); + VERIFY(set_difference(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2); +} + +void +test2() +{ + int array1[] = {1}; + int array2[] = {0}; + Icontainer con1(array1, array1); + Icontainer con2(array1, array1 + 1); + Ocontainer con3(array2, array2); + VERIFY(set_difference(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2); +} + +void +test3() +{ + int array1[] = {1}; + int array2[] = {0}; + Icontainer con1(array1, array1 + 1); + Icontainer con2(array1, array1); + Ocontainer con3(array2, array2 + 1); + VERIFY(set_difference(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2 + 1); +} + +void +test4() +{ + int array1[]={0,1,1,2,4}; + int array2[]={1,2,3}; + int array3[6]; + Icontainer con1(array1, array1 + 5); + Icontainer con2(array2, array2 + 3); + Ocontainer con3(array3, array3 + 3); + VERIFY(set_difference(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array3 + 3); + VERIFY(array3[0] == 0 && array3[1] == 1 && array3[2] == 4); +} + +struct S +{ + int i; + int j; + S() {} + S(int in) + { + if(in > 0) + { + i = in; + j = 1; + } + else + { + i = -in; + j = 0; + } + } +}; + +bool +operator<(const S& s1, const S& s2) +{ return s1.i < s2.i; } + +typedef test_container<S, input_iterator_wrapper> SIcontainer; +typedef test_container<S, output_iterator_wrapper> SOcontainer; + +void +test5() +{ + S array1[] = { -1, -1, -1, -2, -2, -3, -4}; + S array2[] = { 1, 1, 1, 1, 2, 4, 4}; + S array3[9]; + SIcontainer con1(array1, array1 + 7); + SIcontainer con2(array2, array2 + 7); + SOcontainer con3(array3, array3 + 2); + VERIFY(set_difference(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array3 + 2); + for(int i = 0; i < 2; ++i) + VERIFY(array3[i].j == 0); +} + +int main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); +} + diff --git a/libstdc++-v3/testsuite/25_algorithms/set_difference/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/set_difference/check_type.cc new file mode 100644 index 00000000000..43d54ad5ae3 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_difference/check_type.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.5.4 [lib.set.difference] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +output_iterator_wrapper<S> +test1(input_iterator_wrapper<S>& in, output_iterator_wrapper<S>& out) +{ return std::set_difference(in, in, in, in, out); } + +output_iterator_wrapper<X> +test2(input_iterator_wrapper<X>& in, output_iterator_wrapper<X>& out) +{ return std::set_difference(in, in, in, in, out, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/set_intersection/1.cc b/libstdc++-v3/testsuite/25_algorithms/set_intersection/1.cc new file mode 100644 index 00000000000..d0a648e9a53 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_intersection/1.cc @@ -0,0 +1,132 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.5.3 [lib.set.intersection] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; +using std::set_intersection; + +typedef test_container<int, input_iterator_wrapper> Icontainer; +typedef test_container<int, output_iterator_wrapper> Ocontainer; + +void +test1() +{ + int array1[1], array2[1]; + Icontainer con1(array1, array1); + Icontainer con2(array1, array1); + Ocontainer con3(array2, array2); + VERIFY(set_intersection(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2); +} + +void +test2() +{ + int array1[] = {1}; + int array2[] = {0}; + Icontainer con1(array1, array1); + Icontainer con2(array1, array1 + 1); + Ocontainer con3(array2, array2); + VERIFY(set_intersection(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2); +} + +void +test3() +{ + int array1[] = {1}; + int array2[] = {0}; + Icontainer con1(array1, array1 + 1); + Icontainer con2(array1, array1); + Ocontainer con3(array2, array2); + VERIFY(set_intersection(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2); +} + +void +test4() +{ + int array1[]={0,1,1,2,4}; + int array2[]={1,2,3}; + int array3[6]; + Icontainer con1(array1, array1 + 5); + Icontainer con2(array2, array2 + 3); + Ocontainer con3(array3, array3 + 2); + VERIFY(set_intersection(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array3 + 2); + VERIFY(array3[0] == 1 && array3[1] == 2); +} + +struct S +{ + int i; + int j; + S() {} + S(int in) + { + if(in > 0) + { + i = in; + j = 1; + } + else + { + i = -in; + j = 0; + } + } +}; + +bool +operator<(const S& s1, const S& s2) +{ return s1.i < s2.i; } + +typedef test_container<S, input_iterator_wrapper> SIcontainer; +typedef test_container<S, output_iterator_wrapper> SOcontainer; + +void +test5() +{ + S array1[] = { -1, -1, -1, -2, -2, -4}; + S array2[] = { 1, 1, 1, 1, 2, 3, 4, 4}; + S array3[5]; + SIcontainer con1(array1, array1 + 6); + SIcontainer con2(array2, array2 + 8); + SOcontainer con3(array3, array3 + 5); + VERIFY(set_intersection(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array3 + 5); + for(int i = 0; i < 5; ++i) + VERIFY(array3[i].j == 0); +} + +int main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); +} + diff --git a/libstdc++-v3/testsuite/25_algorithms/set_intersection/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/set_intersection/check_type.cc new file mode 100644 index 00000000000..a1ef6f9486e --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_intersection/check_type.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.5.3 [lib.set.intersection] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +output_iterator_wrapper<S> +test1(input_iterator_wrapper<S>& in, output_iterator_wrapper<S>& out) +{ return std::set_intersection(in, in, in, in, out); } + +output_iterator_wrapper<X> +test2(input_iterator_wrapper<X>& in, output_iterator_wrapper<X>& out) +{ return std::set_intersection(in, in, in, in, out, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/1.cc b/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/1.cc new file mode 100644 index 00000000000..932eb4f41cf --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/1.cc @@ -0,0 +1,134 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.5.5 [lib.set.symmetric.difference] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; +using std::set_symmetric_difference; + +typedef test_container<int, input_iterator_wrapper> Icontainer; +typedef test_container<int, output_iterator_wrapper> Ocontainer; + +void +test1() +{ + int array1[1], array2[1]; + Icontainer con1(array1, array1); + Icontainer con2(array1, array1); + Ocontainer con3(array2, array2); + VERIFY(set_symmetric_difference(con1.begin(), con1.end(), con2.begin(), + con2.end(), con3.begin()).ptr == array2); +} + +void +test2() +{ + int array1[] = {1}; + int array2[] = {0}; + Icontainer con1(array1, array1); + Icontainer con2(array1, array1 + 1); + Ocontainer con3(array2, array2 + 1); + VERIFY(set_symmetric_difference(con1.begin(), con1.end(), con2.begin(), + con2.end(), con3.begin()).ptr == array2 + 1); +} + +void +test3() +{ + int array1[] = {1}; + int array2[] = {0}; + Icontainer con1(array1, array1 + 1); + Icontainer con2(array1, array1); + Ocontainer con3(array2, array2 + 1); + VERIFY(set_symmetric_difference(con1.begin(), con1.end(), con2.begin(), + con2.end(), con3.begin()).ptr == array2 + 1); +} + +void +test4() +{ + int array1[]={0,1,1,2,4}; + int array2[]={1,2,2,3}; + int array3[5]; + Icontainer con1(array1, array1 + 5); + Icontainer con2(array2, array2 + 4); + Ocontainer con3(array3, array3 + 5); + VERIFY(set_symmetric_difference(con1.begin(), con1.end(), con2.begin(), + con2.end(), con3.begin()).ptr == array3 + 5); + VERIFY(array3[0] == 0 && array3[1] == 1 && array3[2] == 2 && + array3[3] == 3 && array3[4] == 4); +} + +struct S +{ + int i; + int j; + S() {} + S(int in) + { + if(in > 0) + { + i = in; + j = 1; + } + else + { + i = -in; + j = 0; + } + } +}; + +bool +operator<(const S& s1, const S& s2) +{ return s1.i < s2.i; } + +typedef test_container<S, input_iterator_wrapper> SIcontainer; +typedef test_container<S, output_iterator_wrapper> SOcontainer; + +void +test5() +{ + S array1[] = { -1, -1, -2, -2, -4, -5}; + S array2[] = { 1, 1, 1, 2, 3, 4}; + S array3[4]; + SIcontainer con1(array1, array1 + 6); + SIcontainer con2(array2, array2 + 6); + SOcontainer con3(array3, array3 + 4); + VERIFY(set_symmetric_difference(con1.begin(), con1.end(), con2.begin(), + con2.end(), con3.begin()).ptr == array3 + 4); + VERIFY(array3[0].j == 1 && array3[1].j == 0 && array3[2].j == 1 && + array3[3].j == 0); +} + +int +main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); +} + diff --git a/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/check_type.cc new file mode 100644 index 00000000000..c9c63a7f2d0 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_symmetric_difference/check_type.cc @@ -0,0 +1,45 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.5.5 [lib.set.symmetric.difference] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +output_iterator_wrapper<S> +test1(input_iterator_wrapper<S>& in, output_iterator_wrapper<S>& out) +{ return std::set_symmetric_difference(in, in, in, in, out); } + +output_iterator_wrapper<X> +test2(input_iterator_wrapper<X>& in, output_iterator_wrapper<X>& out) +{ return std::set_symmetric_difference(in, in, in, in, out, predicate); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/set_union/1.cc b/libstdc++-v3/testsuite/25_algorithms/set_union/1.cc new file mode 100644 index 00000000000..03bfcaca8b2 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_union/1.cc @@ -0,0 +1,137 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.5.2 [lib.set.union] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; +using std::set_union; + +typedef test_container<int, input_iterator_wrapper> Icontainer; +typedef test_container<int, output_iterator_wrapper> Ocontainer; + +void +test1() +{ + int array1[1], array2[1]; + Icontainer con1(array1, array1); + Icontainer con2(array1, array1); + Ocontainer con3(array2, array2); + VERIFY(set_union(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2); +} + +void +test2() +{ + int array1[] = {1}; + int array2[] = {0}; + Icontainer con1(array1, array1); + Icontainer con2(array1, array1 + 1); + Ocontainer con3(array2, array2 + 1); + VERIFY(set_union(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2 + 1); + VERIFY(array2[0] == 1); +} + +void +test3() +{ + int array1[] = {1}; + int array2[] = {0}; + Icontainer con1(array1, array1 + 1); + Icontainer con2(array1, array1); + Ocontainer con3(array2, array2 + 1); + VERIFY(set_union(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array2 + 1); + VERIFY(array2[0] == 1); +} + +void +test4() +{ + int array1[]={0,1,1,2,4}; + int array2[]={1,2,3}; + int array3[6]; + Icontainer con1(array1, array1 + 5); + Icontainer con2(array2, array2 + 3); + Ocontainer con3(array3, array3 + 6); + VERIFY(set_union(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array3 + 6); + VERIFY(array3[0] == 0 && array3[1] == 1 && array3[2] == 1 && + array3[3] == 2 && array3[4] == 3 && array3[5] == 4); +} + +struct S +{ + int i; + int j; + S() {} + S(int in) + { + if(in > 0) + { + i = in; + j = 1; + } + else + { + i = -in; + j = 0; + } + } +}; + +bool +operator<(const S& s1, const S& s2) +{ return s1.i < s2.i; } + +typedef test_container<S, input_iterator_wrapper> SIcontainer; +typedef test_container<S, output_iterator_wrapper> SOcontainer; + +void +test5() +{ + S array1[] = { -1, -1, -1, -2, -2, -4}; + S array2[] = { 1, 1, 1, 1, 2, 3, 4, 4}; + S array3[9]; + SIcontainer con1(array1, array1 + 6); + SIcontainer con2(array2, array2 + 8); + SOcontainer con3(array3, array3 + 9); + VERIFY(set_union(con1.begin(), con1.end(), con2.begin(), con2.end(), + con3.begin()).ptr == array3 + 9); + VERIFY(array3[0].j == 0 && array3[1].j == 0 && array3[2].j == 0 && + array3[3].j == 1 && array3[4].j == 0 && array3[5].j == 0 && + array3[6].j == 1 && array3[7].j == 0 && array3[8].j == 1); +} + +int +main() +{ + test1(); + test2(); + test3(); + test4(); + test5(); +} + diff --git a/libstdc++-v3/testsuite/25_algorithms/set_union/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/set_union/check_type.cc new file mode 100644 index 00000000000..286de97fec4 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/set_union/check_type.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.5.2 [lib.set.union] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +output_iterator_wrapper<S> +test1(input_iterator_wrapper<S>& in, output_iterator_wrapper<S>& out) +{ return std::set_union(in, in, in, in, out); } + +output_iterator_wrapper<X> +test2(input_iterator_wrapper<X>& in, output_iterator_wrapper<X>& out) +{ return std::set_union(in, in, in, in, out, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/stable_sort/1.cc b/libstdc++-v3/testsuite/25_algorithms/stable_sort/1.cc new file mode 100644 index 00000000000..659c2782a39 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/stable_sort/1.cc @@ -0,0 +1,90 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.1.2 [lib.stable.sort] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; +using std::stable_sort; + +typedef test_container<int, random_access_iterator_wrapper> Container; + +void +test1() +{ + int array[]={0}; + Container con(array, array); + stable_sort(con.begin(), con.end()); +} + +void +test2() +{ + int array[] = {6, 5, 4, 3, 2, 1, 0}; + Container con(array, array + 7); + stable_sort(con.begin(), con.end()); + VERIFY(array[0] == 0 && array[1] == 1 && array[2] == 2 && + array[3] == 3 && array[4] == 4 && array[5] == 5 && + array[6] == 6); +} +struct S +{ + int i; + int j; + S() {} + S(int in) + { + if(in > 0) + { + i = in; + j = 1; + } + else + { + i = -in; + j = 0; + } + } +}; + +bool +operator<(const S& s1, const S& s2) +{ return s1.i < s2.i; } + +void +test3() +{ + + S array[] = {-1, -2, 1, 2, -3 ,-5 ,3 , -4, 5, 4}; + test_container<S, random_access_iterator_wrapper> con(array,array + 10); + stable_sort(con.begin(), con.end()); + for(int i = 0; i < 10; ++i) + VERIFY(array[i].j == i % 2); +} + +int +main() +{ + test1(); + test2(); + test3(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/stable_sort/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/stable_sort/check_type.cc new file mode 100644 index 00000000000..8e7c51d18d7 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/stable_sort/check_type.cc @@ -0,0 +1,49 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.1.1 [lib.stable.sort] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::random_access_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +void +test1(random_access_iterator_wrapper<S>& s) +{ + std::stable_sort(s, s); +} + +void +test2(random_access_iterator_wrapper<X>& x) +{ + std::stable_sort(x, x, predicate); +} + diff --git a/libstdc++-v3/testsuite/25_algorithms/swap_ranges/1.cc b/libstdc++-v3/testsuite/25_algorithms/swap_ranges/1.cc new file mode 100644 index 00000000000..e4a23e28afd --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/swap_ranges/1.cc @@ -0,0 +1,60 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.2 swap_ranges + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; + +typedef test_container<int, forward_iterator_wrapper> Container; + + +void +test1() +{ + bool test __attribute__((unused)) = true; + int array1[]={1, 2}; + int array2[]={3, 4}; + Container con1(array1, array1 + 2); + Container con2(array2, array2 + 2); + VERIFY(std::swap_ranges(con1.begin(), con1.end(), con2.begin()).ptr == + array2 + 2); + VERIFY(array1[0] == 3 && array1[1] == 4 && array2[0] == 1 && array2[1] == 2); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + int array1[] = {1}; + int array2[] = {1}; + Container con1(array1, array1); + Container con2(array2, array2); + VERIFY(swap_ranges(con1.begin(), con1.end(), con2.begin()).ptr == array2); +} + +int +main() +{ + test1(); + test2(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/swap_ranges/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/swap_ranges/check_type.cc new file mode 100644 index 00000000000..a19d92c6518 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/swap_ranges/check_type.cc @@ -0,0 +1,35 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.2.4 Swap Ranges + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct X { +}; + +void +test1(forward_iterator_wrapper<X>& begin, + forward_iterator_wrapper<X>& end, + forward_iterator_wrapper<X>& begin2) +{ std::swap_ranges(begin, end, begin2); } diff --git a/libstdc++-v3/testsuite/25_algorithms/unique_copy/1.cc b/libstdc++-v3/testsuite/25_algorithms/unique_copy/1.cc new file mode 100644 index 00000000000..4f96c3a64c0 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/unique_copy/1.cc @@ -0,0 +1,85 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.5.8 [lib.alg.unique] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::input_iterator_wrapper; +using __gnu_test::forward_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; +using std::unique; + +typedef test_container<int, input_iterator_wrapper> Icontainer; +typedef test_container<int, forward_iterator_wrapper> Fcontainer; +typedef test_container<int, output_iterator_wrapper> Ocontainer; + +int array1[] = {0, 0, 0, 1, 1, 1}; +int array2[2]; + +void +test1() +{ + bool test __attribute__((unused)) = true; + Icontainer con1(array1, array1); + Ocontainer con2(array2, array2); + VERIFY(unique_copy(con1.begin(), con1.end(), con2.begin()).ptr == array2); +} + +void +test2() +{ + bool test __attribute__((unused)) = true; + Icontainer con1(array1, array1 + 6); + Ocontainer con2(array2, array2 + 2); + VERIFY(unique_copy(con1.begin(), con1.end(), con2.begin()).ptr + == array2 + 2); + VERIFY(array2[0] == 0 && array2[1] == 1); +} + +void +test3() +{ + bool test __attribute__((unused)) = true; + Icontainer con1(array1, array1); + Fcontainer con2(array2, array2); + VERIFY(unique_copy(con1.begin(), con1.end(), con2.begin()).ptr == array2); +} + +void +test4() +{ + bool test __attribute__((unused)) = true; + Icontainer con1(array1, array1 + 6); + Fcontainer con2(array2, array2 + 2); + VERIFY(unique_copy(con1.begin(), con1.end(), con2.begin()).ptr + == array2 + 2); + VERIFY(array2[0] == 0 && array2[1] == 1); +} + +int +main() +{ + test1(); + test2(); + test3(); + test4(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/unique_copy/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/unique_copy/check_type.cc new file mode 100644 index 00000000000..1c6731e9df9 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/unique_copy/check_type.cc @@ -0,0 +1,55 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.5.8 [lib.alg.unique_copy] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::input_iterator_wrapper; +using __gnu_test::output_iterator_wrapper; + +struct S1 { }; + +struct S2 +{ + S2(const S1& s1) {} +}; + +bool +operator==(const S1&, const S1&) {return true;} + +struct X1 { }; + +struct X2 +{ + X2(const X1& x1) {} +}; + +bool +predicate(const X1&, const X1&) {return true;} + +output_iterator_wrapper<S2> +test1(input_iterator_wrapper<S1>& s1, output_iterator_wrapper<S2>& s2) +{ return std::unique_copy(s1, s1, s2); } + +output_iterator_wrapper<X2> +test2(input_iterator_wrapper<X1>& x1, output_iterator_wrapper<X2>& x2) +{ return std::unique_copy(x1, x1, x2, predicate); } diff --git a/libstdc++-v3/testsuite/25_algorithms/upper_bound/1.cc b/libstdc++-v3/testsuite/25_algorithms/upper_bound/1.cc new file mode 100644 index 00000000000..8b518ef0098 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/upper_bound/1.cc @@ -0,0 +1,47 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.3.2 [lib.upper.bound] + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::forward_iterator_wrapper; +using std::upper_bound; + +typedef test_container<int, forward_iterator_wrapper> Container; +int array[] = {0, 0, 0, 0, 1, 1, 1, 1}; + +void +test1() +{ + for(int i = 0; i < 5; ++i) + for(int j = 4; j < 7; ++j) + { + Container con(array + i, array + j); + VERIFY(upper_bound(con.begin(), con.end(), 0).ptr == array + 4); + } +} + +int +main() +{ + test1(); +} diff --git a/libstdc++-v3/testsuite/25_algorithms/upper_bound/check_type.cc b/libstdc++-v3/testsuite/25_algorithms/upper_bound/check_type.cc new file mode 100644 index 00000000000..f0c0774add0 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/upper_bound/check_type.cc @@ -0,0 +1,44 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 25.3.3.2 [lib.upper.bound] + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::forward_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +forward_iterator_wrapper<S> +test1(forward_iterator_wrapper<S>& s) +{ return std::upper_bound(s, s, *s); } + +forward_iterator_wrapper<X> +test2(forward_iterator_wrapper<X>& x) +{ return std::upper_bound(x, x, *x, predicate); } diff --git a/libstdc++-v3/testsuite/26_numerics/cstdlib/13943.cc b/libstdc++-v3/testsuite/26_numerics/cstdlib/13943.cc new file mode 100644 index 00000000000..920ddcc43b3 --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/cstdlib/13943.cc @@ -0,0 +1,52 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +#include <cstdlib> +#include <testsuite_hooks.h> + +#if _GLIBCXX_USE_C99 +// libstdc++/13943 +void test01() +{ + using namespace std; + bool test __attribute__((unused)) = true; + + VERIFY( llabs(-3) == 3 ); + + lldiv_t q = lldiv(6, 4); + VERIFY( q.quot == 1 ); + VERIFY( q.rem == 2 ); +} +#endif + +int main() +{ +#if _GLIBCXX_USE_C99 + test01(); +#endif + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/in_avail/char/9701-3.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/in_avail/char/9701-3.cc index 5dc68c62b9a..5dc68c62b9a 100644 --- a/libstdc++-v3/testsuite/27_io/basic_streambuf/in_avail/char/9701-3.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/in_avail/char/9701-3.cc diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/in_avail/wchar_t/9701-3.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/in_avail/char/1.cc index 239f790fe47..ee9a81c816d 100644 --- a/libstdc++-v3/testsuite/27_io/basic_streambuf/in_avail/wchar_t/9701-3.cc +++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/in_avail/char/1.cc @@ -1,4 +1,6 @@ -// Copyright (C) 2003, 2004 Free Software Foundation, Inc. +// 2005-06-07 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2005 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 @@ -16,44 +18,37 @@ // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, // USA. -// 27.5.2.2.3 Get area +// 27.8.1.4 Overridden virtual functions #include <fstream> #include <testsuite_hooks.h> -class Derived_fbuf : public std::wfilebuf -{ -public: - const char_type* pub_egptr() const - { return egptr(); } +typedef std::basic_streambuf<char> streambuf_type; - const char_type* pub_gptr() const - { return gptr(); } +struct testbuf : streambuf_type +{ + testbuf() { } }; -// libstdc++/9701 (in_avail) -void test01() +void test05() { - using namespace std; - bool test __attribute__((unused)) = true; - const char* name = "tmp_file1_w"; + typedef streambuf_type::int_type int_type; + typedef streambuf_type::traits_type traits_type; + typedef streambuf_type::pos_type pos_type; + typedef streambuf_type::off_type off_type; + typedef size_t size_type; - Derived_fbuf df2; - df2.open(name, ios_base::in | ios_base::out | ios_base::trunc); - - df2.sputn(L"Comomoc", 7); - - df2.pubseekoff(0, ios_base::beg); - df2.sbumpc(); - df2.sputbackc(L't'); + bool test __attribute__((unused)) = true; + std::streamoff strmof_1, strmof_2; + testbuf sb01; - VERIFY( df2.pub_gptr() < df2.pub_egptr() ); - VERIFY( df2.in_avail() == df2.pub_egptr() - df2.pub_gptr() ); + // int in_avail() + strmof_1 = sb01.in_avail(); + VERIFY( strmof_1 == 0 ); } -int -main() +int main() { - test01(); + test05(); return 0; } diff --git a/libstdc++-v3/testsuite/27_io/basic_streambuf/in_avail/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_streambuf/in_avail/wchar_t/1.cc new file mode 100644 index 00000000000..fd10c0b0d9d --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_streambuf/in_avail/wchar_t/1.cc @@ -0,0 +1,54 @@ +// 2005-06-07 Benjamin Kosnik <bkoz@redhat.com> + +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 27.8.1.4 Overridden virtual functions + +#include <fstream> +#include <testsuite_hooks.h> + +typedef std::basic_streambuf<wchar_t> streambuf_type; + +struct testbuf : streambuf_type +{ + testbuf() { } +}; + +void test05() +{ + typedef streambuf_type::int_type int_type; + typedef streambuf_type::traits_type traits_type; + typedef streambuf_type::pos_type pos_type; + typedef streambuf_type::off_type off_type; + typedef size_t size_type; + + bool test __attribute__((unused)) = true; + std::streamoff strmof_1, strmof_2; + testbuf sb01; + + // int in_avail() + strmof_1 = sb01.in_avail(); + VERIFY( strmof_1 == 0 ); +} + +int main() +{ + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/in_avail/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/in_avail/char/1.cc index 99942f76610..5833c9652c9 100644 --- a/libstdc++-v3/testsuite/27_io/basic_stringbuf/in_avail/char/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/in_avail/char/1.cc @@ -1,6 +1,6 @@ // 981208 bkoz test functionality of basic_stringbuf for char_type == char -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -43,8 +43,8 @@ void test04() VERIFY( strmof_1 == static_cast<std::streamoff>(str_01.length()) ); VERIFY( strmof_2 == static_cast<std::streamoff>(str_02.length()) ); strmof_1 = strb_03.in_avail(); - // zero cuz write-only, or eof()? zero, from showmany - VERIFY( strmof_1 == 0 ); + // zero cuz write-only, or eof() to match basic_filebuf + VERIFY( strmof_1 == -1 ); } int main() diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/in_avail/char/21955.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/in_avail/char/21955.cc new file mode 100644 index 00000000000..023418cfd64 --- /dev/null +++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/in_avail/char/21955.cc @@ -0,0 +1,54 @@ +// 2005-06-07 Benjamin Kosnik + +// Copyright (C) 2005 +// 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +#include <sstream> +#include <testsuite_hooks.h> +#include <stdexcept> + +double +test_stringstream() +{ + double result; + char* source = "1918"; + std::stringstream s; + s << source; + + std::string tmp = s.str(); + std::streambuf* sb = s.rdbuf(); + int i = sb->in_avail(); + + if (i) + { + s >> result; + } + else + { + throw std::runtime_error("conversion failed"); + } + return result; +} + + +int main () +{ + test_stringstream(); + return 0; +} diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/in_avail/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/in_avail/wchar_t/1.cc index ed6f2484dbc..346a4db1baf 100644 --- a/libstdc++-v3/testsuite/27_io/basic_stringbuf/in_avail/wchar_t/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/in_avail/wchar_t/1.cc @@ -1,6 +1,6 @@ // 981208 bkoz test functionality of basic_stringbuf for char_type == wchar_t -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -43,8 +43,8 @@ void test04() VERIFY( strmof_1 == static_cast<std::streamoff>(str_01.length()) ); VERIFY( strmof_2 == static_cast<std::streamoff>(str_02.length()) ); strmof_1 = strb_03.in_avail(); - // zero cuz write-only, or eof()? zero, from showmany - VERIFY( strmof_1 == 0 ); + // zero cuz write-only, or eof() to match basic_filebuf + VERIFY( strmof_1 == -1 ); } int main() diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/str/char/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/str/char/1.cc index 2f9a5cf176f..d788f1274c2 100644 --- a/libstdc++-v3/testsuite/27_io/basic_stringbuf/str/char/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/str/char/1.cc @@ -1,6 +1,6 @@ // 981208 bkoz test functionality of basic_stringbuf for char_type == char -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -45,7 +45,7 @@ void test03() std::streamsize d1 = strb_01.in_avail(); std::streamsize d2 = strb_03.in_avail(); VERIFY( d1 ); // non-zero - VERIFY( !d2 ); // zero, cuz ios_base::out + VERIFY( d2 == -1 ); // -1, cuz ios_base::out VERIFY( d1 != d2 ); //these should be the same VERIFY( static_cast<std::streamsize>(str_01.length()) == d1 ); VERIFY( strb_01.str() == strb_03.str() ); //ditto diff --git a/libstdc++-v3/testsuite/27_io/basic_stringbuf/str/wchar_t/1.cc b/libstdc++-v3/testsuite/27_io/basic_stringbuf/str/wchar_t/1.cc index 4c89bc932c7..cc0e0ab2dcd 100644 --- a/libstdc++-v3/testsuite/27_io/basic_stringbuf/str/wchar_t/1.cc +++ b/libstdc++-v3/testsuite/27_io/basic_stringbuf/str/wchar_t/1.cc @@ -1,6 +1,6 @@ // 981208 bkoz test functionality of basic_stringbuf for char_type == wchar_t -// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -45,7 +45,7 @@ void test03() std::streamsize d1 = strb_01.in_avail(); std::streamsize d2 = strb_03.in_avail(); VERIFY( d1 ); // non-zero - VERIFY( !d2 ); // zero, cuz ios_base::out + VERIFY( d2 == -1 ); // -1, cuz ios_base::out VERIFY( d1 != d2 ); //these should be the same VERIFY( static_cast<std::streamsize>(str_01.length()) == d1 ); VERIFY( strb_01.str() == strb_03.str() ); //ditto diff --git a/libstdc++-v3/testsuite/27_io/ios_base/cons/assign_neg.cc b/libstdc++-v3/testsuite/27_io/ios_base/cons/assign_neg.cc index 50c8eb8b05f..ea6eb423cec 100644 --- a/libstdc++-v3/testsuite/27_io/ios_base/cons/assign_neg.cc +++ b/libstdc++-v3/testsuite/27_io/ios_base/cons/assign_neg.cc @@ -40,6 +40,7 @@ void test01() test_base io2; io1 = io2; } -// { dg-error "within this context" "" { target *-*-* } 41 } +// { dg-error "synthesized" "" { target *-*-* } 41 } +// { dg-error "within this context" "" { target *-*-* } 34 } // { dg-error "is private" "" { target *-*-* } 782 } // { dg-error "operator=" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/27_io/ios_base/cons/copy_neg.cc b/libstdc++-v3/testsuite/27_io/ios_base/cons/copy_neg.cc index 925087d5b27..2c047a5c3b5 100644 --- a/libstdc++-v3/testsuite/27_io/ios_base/cons/copy_neg.cc +++ b/libstdc++-v3/testsuite/27_io/ios_base/cons/copy_neg.cc @@ -40,6 +40,7 @@ void test02() test_base io1; test_base io2 = io1; } -// { dg-error "within this context" "" { target *-*-* } 41 } +// { dg-error "within this context" "" { target *-*-* } 35 } +// { dg-error "synthesized" "" { target *-*-* } 41 } // { dg-error "is private" "" { target *-*-* } 779 } // { dg-error "copy constructor" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/Makefile.in b/libstdc++-v3/testsuite/Makefile.in index 64f38c1dfb6..df262facdae 100644 --- a/libstdc++-v3/testsuite/Makefile.in +++ b/libstdc++-v3/testsuite/Makefile.in @@ -40,7 +40,8 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(top_srcdir)/fragment.am subdir = testsuite ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/../config/no-executables.m4 \ +am__aclocal_m4_deps = $(top_srcdir)/../config/lead-dot.m4 \ + $(top_srcdir)/../config/no-executables.m4 \ $(top_srcdir)/../libtool.m4 $(top_srcdir)/crossconfig.m4 \ $(top_srcdir)/linkage.m4 $(top_srcdir)/acinclude.m4 \ $(top_srcdir)/configure.ac diff --git a/libstdc++-v3/testsuite/ext/array_allocator/2.cc b/libstdc++-v3/testsuite/ext/array_allocator/2.cc index 1e837258923..f580ea250b7 100644 --- a/libstdc++-v3/testsuite/ext/array_allocator/2.cc +++ b/libstdc++-v3/testsuite/ext/array_allocator/2.cc @@ -1,4 +1,7 @@ -// Copyright (C) 2004, 2005 Free Software Foundation, Inc. +// Expected execution error for PR19495. +// { dg-do run { xfail powerpc*-*-linux* } } + +// Copyright (C) 2004 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 @@ -32,10 +35,7 @@ typedef char char_type; typedef std::char_traits<char_type> traits_type; -// NB: Array_allocator doesn't properly support rebinding, used by -// basic_string. See libstdc++/21609 for details. -typedef std::tr1::array<size_t, 16> array_type; -typedef __gnu_cxx::array_allocator<size_t, array_type> allocator_type; +typedef std::tr1::array<char_type, 32> array_type; array_type extern_array; @@ -44,8 +44,10 @@ void test01() bool test __attribute__((unused)) = true; using std::basic_string; + typedef __gnu_cxx::array_allocator<char_type, array_type> allocator_type; typedef basic_string<char_type, traits_type, allocator_type> string_type; + size_t index = array_type::_S_index; allocator_type a(&extern_array); string_type s(a); diff --git a/libstdc++-v3/testsuite/ext/is_heap/1.cc b/libstdc++-v3/testsuite/ext/is_heap/1.cc new file mode 100644 index 00000000000..3974f03c464 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/is_heap/1.cc @@ -0,0 +1,46 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +#include <algorithm> +#include <testsuite_hooks.h> +#include <testsuite_iterators.h> + +using __gnu_test::test_container; +using __gnu_test::random_access_iterator_wrapper; + +typedef test_container<int, random_access_iterator_wrapper> container; + +void +test1() +{ + int array[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + for(int i = 0; i < 10; ++i) + { + container con(array, array + i); + std::make_heap(con.begin(), con.end()); + VERIFY(std::__is_heap(con.begin(), con.end())); + VERIFY(std::__is_heap(con.begin(), i)); + } +} + +int +main() +{ + test1(); + return 0; +} diff --git a/libstdc++-v3/testsuite/ext/is_heap/check_type.cc b/libstdc++-v3/testsuite/ext/is_heap/check_type.cc new file mode 100644 index 00000000000..6c791bd80ac --- /dev/null +++ b/libstdc++-v3/testsuite/ext/is_heap/check_type.cc @@ -0,0 +1,47 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// { dg-do compile } + +#include <algorithm> +#include <testsuite_iterators.h> + +using __gnu_test::random_access_iterator_wrapper; + +struct S { }; + +bool +operator<(const S&, const S&) {return true;} + +struct X { }; + +bool +predicate(const X&, const X&) {return true;} + +bool +test1(random_access_iterator_wrapper<S>& start, + random_access_iterator_wrapper<S>& end) +{ return std::__is_heap(start, end) && std::__is_heap(start, 1); } + +bool +test2(random_access_iterator_wrapper<X>& start, + random_access_iterator_wrapper<X>& end) +{ + return std::__is_heap(start, end, predicate) && + std::__is_heap(start, predicate, 1); +} diff --git a/libstdc++-v3/testsuite/ext/median.cc b/libstdc++-v3/testsuite/ext/median.cc new file mode 100644 index 00000000000..97e44ea5bb9 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/median.cc @@ -0,0 +1,42 @@ +// Copyright (C) 2005 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 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// median - SGI extension + +#include <algorithm> +#include <testsuite_hooks.h> + +bool pred(const int& l, const int& r) +{ + return l<r; +} + +using std::__median; + +int main(void) +{ + const int i=1; + const int j=2; + const int k=3; + VERIFY(__median(i, j, k) == j && __median(i, j, k, pred) == j); + VERIFY(__median(i, k, j) == j && __median(i, k, j, pred) == j); + VERIFY(__median(j, i, k) == j && __median(j, i, k, pred) == j); + VERIFY(__median(j, k, i) == j && __median(j, k, i, pred) == j); + VERIFY(__median(k, i, j) == j && __median(k, i, j, pred) == j); + VERIFY(__median(k, j, i) == j && __median(k, j, i, pred) == j); +} diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp index 2dbf8217938..bcae3777e75 100644 --- a/libstdc++-v3/testsuite/lib/libstdc++.exp +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp @@ -103,14 +103,7 @@ proc libstdc++_init { testfile } { # headers, or without assertions. global DEFAULT_CXXFLAGS if ![info exists DEFAULT_CXXFLAGS] then { - # Set up includes for stdc++.h.gch, the precompiled header file. - if { [file exists $flags_file] } { - set cxxpchflags [exec sh $flags_file --cxxpchflags] - } else { - set cxxpchflags "" - } - set DEFAULT_CXXFLAGS " ${cxxpchflags}" - + set DEFAULT_CXXFLAGS "" # Host specific goo here. if { [string match "powerpc-*-darwin*" $target_triplet] } { append DEFAULT_CXXFLAGS " -multiply_defined suppress" @@ -195,6 +188,28 @@ proc libstdc++_init { testfile } { } } + # If a PCH file is available, use it. We must delay performing + # this check until $cxx and such have been initialized because we + # perform a test compilation. (Ideally, gcc --print-file-name would + # list PCH files, but it does not.) + global PCH_CXXFLAGS + if ![info exists PCH_CXXFLAGS] then { + set src "config[pid].cc" + set f [open $src "w"] + puts $f "int main () {}" + close $f + + set lines [v3_target_compile $src "config[pid].o" object \ + "additional_flags=-include additional_flags=bits/stdc++.h"] + if {$lines == "" } { + set PCH_CXXFLAGS "-include bits/stdc++.h" + } else { + set PCH_CXXFLAGS "" + } + file delete $src + v3track PCH_CXXFLAGS 2 + } + libstdc++_maybe_build_wrapper "${objdir}/testglue.o" } diff --git a/libstdc++-v3/testsuite/libstdc++-dg/normal.exp b/libstdc++-v3/testsuite/libstdc++-dg/normal.exp index 746c7a8ec3f..9d2f1a63a9a 100644 --- a/libstdc++-v3/testsuite/libstdc++-dg/normal.exp +++ b/libstdc++-v3/testsuite/libstdc++-dg/normal.exp @@ -87,7 +87,8 @@ set tests [lsort $tests] # Main loop. global DEFAULT_CXXFLAGS -dg-runtest $tests "" $DEFAULT_CXXFLAGS +global PCH_CXXFLAGS +dg-runtest $tests "" "$DEFAULT_CXXFLAGS $PCH_CXXFLAGS" # All done. dg-finish diff --git a/libstdc++-v3/testsuite/testsuite_abi.cc b/libstdc++-v3/testsuite/testsuite_abi.cc index 5f6e23ed83b..0aa594256fa 100644 --- a/libstdc++-v3/testsuite/testsuite_abi.cc +++ b/libstdc++-v3/testsuite/testsuite_abi.cc @@ -166,6 +166,7 @@ check_version(const symbol& test, bool added) known_versions.push_back("GLIBCXX_3.4.2"); known_versions.push_back("GLIBCXX_3.4.3"); known_versions.push_back("GLIBCXX_3.4.4"); + known_versions.push_back("GLIBCXX_3.4.5"); known_versions.push_back("CXXABI_1.2"); known_versions.push_back("CXXABI_1.2.1"); known_versions.push_back("CXXABI_1.3"); diff --git a/libstdc++-v3/testsuite/testsuite_hooks.h b/libstdc++-v3/testsuite/testsuite_hooks.h index 90104d36523..fc05186d400 100644 --- a/libstdc++-v3/testsuite/testsuite_hooks.h +++ b/libstdc++-v3/testsuite/testsuite_hooks.h @@ -160,6 +160,24 @@ namespace __gnu_test void run_tests_wrapped_env(const char*, const char*, const func_callback&); + + // For containers (23.1/3). + struct NonDefaultConstructible + { + NonDefaultConstructible(int) { } + }; + + inline bool + operator==(const NonDefaultConstructible& lhs, + const NonDefaultConstructible& rhs) + { return false; } + + inline bool + operator<(const NonDefaultConstructible& lhs, + const NonDefaultConstructible& rhs) + { return false; } + + // Counting. struct counter { diff --git a/libstdc++-v3/testsuite/testsuite_iterators.h b/libstdc++-v3/testsuite/testsuite_iterators.h index 435bb1d26b5..1a6a295ee97 100644 --- a/libstdc++-v3/testsuite/testsuite_iterators.h +++ b/libstdc++-v3/testsuite/testsuite_iterators.h @@ -1,7 +1,7 @@ // -*- C++ -*- // Iterator Wrappers for the C++ library testsuite. // -// Copyright (C) 2004 Free Software Foundation, Inc. +// Copyright (C) 2004, 2005 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 @@ -77,7 +77,7 @@ namespace __gnu_test { writtento = new bool[this->last - this->first]; for(int i = 0; i < this->last - this->first; i++) - writtento = false; + writtento[i] = false; } ~OutputContainer() @@ -96,12 +96,13 @@ namespace __gnu_test ptr(ptr_in), SharedInfo(SharedInfo_in) { } + template<class U> void - operator=(T& new_val) + operator=(const U& new_val) { ITERATOR_VERIFY(SharedInfo->writtento[ptr - SharedInfo->first] == 0); SharedInfo->writtento[ptr - SharedInfo->first] = 1; - ptr = new_val; + *ptr = new_val; } }; @@ -149,9 +150,9 @@ namespace __gnu_test operator++() { ITERATOR_VERIFY(SharedInfo && ptr < SharedInfo->last); - ITERATOR_VERIFY(ptr>=SharedInfo->first); + ITERATOR_VERIFY(ptr>=SharedInfo->incrementedto); ptr++; - SharedInfo->first=ptr; + SharedInfo->incrementedto=ptr; return *this; } @@ -423,7 +424,7 @@ namespace __gnu_test operator--(int) { random_access_iterator_wrapper<T> tmp = *this; - ++*this; + --*this; return tmp; } @@ -443,34 +444,27 @@ namespace __gnu_test return *this; } - random_access_iterator_wrapper - operator+(ptrdiff_t n) - { - random_access_iterator_wrapper<T> tmp = *this; - return tmp += n; - } - random_access_iterator_wrapper& operator-=(ptrdiff_t n) { return *this += -n; } random_access_iterator_wrapper - operator-(ptrdiff_t n) + operator-(ptrdiff_t n) const { random_access_iterator_wrapper<T> tmp = *this; return tmp -= n; } ptrdiff_t - operator-(const random_access_iterator_wrapper<T>& in) + operator-(const random_access_iterator_wrapper<T>& in) const { ITERATOR_VERIFY(this->SharedInfo == in.SharedInfo); return this->ptr - in.ptr; } T& - operator[](ptrdiff_t n) - { return *(this + n); } + operator[](ptrdiff_t n) const + { return *(*this + n); } bool operator<(const random_access_iterator_wrapper<T>& in) const @@ -498,6 +492,16 @@ namespace __gnu_test } }; + template<typename T> + random_access_iterator_wrapper<T> + operator+(random_access_iterator_wrapper<T> it, ptrdiff_t n) + { return it += n; } + + template<typename T> + random_access_iterator_wrapper<T> + operator+(ptrdiff_t n, random_access_iterator_wrapper<T> it) + { return it += n; } + /** * @brief A container-type class for holding iterator wrappers |