diff options
author | Edward Smith-Rowland <3dw4rd@verizon.net> | 2008-10-15 16:48:13 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2008-10-15 16:48:13 +0000 |
commit | 3a63c9cdfce73e8184b36a3b3a1a5001cb49ffe6 (patch) | |
tree | f4e168d347de01f5a0c1999ad2ee49786cac002b /libstdc++-v3/testsuite/23_containers/forward_list | |
parent | 21c74256c36074cd3bab4895079977ab11672789 (diff) | |
download | gcc-3a63c9cdfce73e8184b36a3b3a1a5001cb49ffe6.tar.gz |
forward_list: New.
2008-10-15 Edward Smith-Rowland <3dw4rd@verizon.net>
* include/std/forward_list: New.
* include/bits/forward_list.h: Likewise.
* include/bits/forward_list.tcc: Likewise.
* include/precompiled/stdc++.h: Modified to include forward_list.
* include/Makefile.am: Add forward_list, forward_list.h, and
forward_list.tcc.
* include/Makefile.in: Regenerate.
* testsuite/23_containers/forward_list/modifiers/1.cc: New.
* testsuite/23_containers/forward_list/modifiers/2.cc: Likewise.
* testsuite/23_containers/forward_list/modifiers/3.cc: Likewise.
* testsuite/23_containers/forward_list/modifiers/4.cc: Likewise.
* testsuite/23_containers/forward_list/modifiers/5.cc: Likewise.
* testsuite/23_containers/forward_list/cons/1.cc: Likewise.
* testsuite/23_containers/forward_list/cons/2.cc: Likewise.
* testsuite/23_containers/forward_list/cons/3.cc: Likewise.
* testsuite/23_containers/forward_list/cons/4.cc: Likewise.
* testsuite/23_containers/forward_list/cons/5.cc: Likewise.
* testsuite/23_containers/forward_list/cons/6.cc: Likewise.
* testsuite/23_containers/forward_list/cons/7.cc: Likewise.
* testsuite/23_containers/forward_list/cons/8.cc: Likewise.
* testsuite/23_containers/forward_list/cons/9.cc: Likewise.
* testsuite/23_containers/forward_list/requirements/1.cc: Likewise.
* testsuite/23_containers/forward_list/operations/1.cc: Likewise.
* testsuite/23_containers/forward_list/operations/2.cc: Likewise.
* testsuite/23_containers/forward_list/operations/3.cc: Likewise.
* testsuite/23_containers/forward_list/operations/4.cc: Likewise.
* testsuite/23_containers/forward_list/operations/5.cc: Likewise.
* testsuite/23_containers/forward_list/operations/6.cc: Likewise.
* testsuite/23_containers/forward_list/operations/7.cc: Likewise.
* testsuite/23_containers/forward_list/capacity/1.cc: Likewise.
* testsuite/23_containers/forward_list/comparable.cc: Likewise.
* testsuite/23_containers/forward_list/moveable.cc: Likewise.
* testsuite/23_containers/headers/forward_list/synopsis.cc: Likewise.
* testsuite/17_intro/headers/c++200x/all_multiple_inclusion.cc: Update.
* testsuite/17_intro/headers/c++200x/all: Likewise.
From-SVN: r141146
Diffstat (limited to 'libstdc++-v3/testsuite/23_containers/forward_list')
25 files changed, 1480 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/capacity/1.cc b/libstdc++-v3/testsuite/23_containers/forward_list/capacity/1.cc new file mode 100644 index 00000000000..1489f9b9da5 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/capacity/1.cc @@ -0,0 +1,50 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list capacity [lib.forward_list.capacity] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following. +// +void +test01() +{ + std::forward_list<double> fld; + VERIFY(fld.empty() == true); + + fld.push_front(1.0); + VERIFY(fld.empty() == false); + + fld.resize(0); + VERIFY(fld.empty() == true); + + VERIFY(fld.max_size() == fld.get_allocator().max_size()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/comparable.cc b/libstdc++-v3/testsuite/23_containers/forward_list/comparable.cc new file mode 100644 index 00000000000..3ccfa357040 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/comparable.cc @@ -0,0 +1,59 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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. + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on list (via swap). If the implementation changed +// this test may begin to fail. + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +int main() +{ + std::forward_list<double> a = {0.0, 1.0, 2.0, 3.0, 4.0}; + std::forward_list<double> b = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; + + VERIFY((a == b) == false); + VERIFY((a < b) == true); + VERIFY((a != b) == true); + VERIFY((a > b) == false); + VERIFY((a >= b) == false); + VERIFY((a <= b) == true); + + VERIFY((b == a) == false); + VERIFY((b < a) == false); + VERIFY((b != a) == true); + VERIFY((b > a) == true); + VERIFY((b >= a) == true); + VERIFY((b <= a) == false); + + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/cons/1.cc b/libstdc++-v3/testsuite/23_containers/forward_list/cons/1.cc new file mode 100644 index 00000000000..4bb5501055c --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/cons/1.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// Default construction +void +test01() +{ + std::forward_list<double> fld; +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/cons/2.cc b/libstdc++-v3/testsuite/23_containers/forward_list/cons/2.cc new file mode 100644 index 00000000000..44c1318462c --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/cons/2.cc @@ -0,0 +1,46 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// Construction from iterator range +// Copy construction with allocator +void +test01() +{ + const int ni = 10; + int i[ni] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + + std::forward_list<int> flccin(i, i+ni); + std::forward_list<int> flcc(flccin, std::allocator<int>()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/cons/3.cc b/libstdc++-v3/testsuite/23_containers/forward_list/cons/3.cc new file mode 100644 index 00000000000..f09c884e1d7 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/cons/3.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// Move construction with allocator +void +test01() +{ + const int ni = 10; + int i[ni] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + + std::forward_list<int> flmc(std::forward_list<int>(i, i+ni), std::allocator<int>()); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/cons/4.cc b/libstdc++-v3/testsuite/23_containers/forward_list/cons/4.cc new file mode 100644 index 00000000000..7cb33913442 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/cons/4.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// Construction from given number of default item +void +test01() +{ + std::forward_list<double> flvd(10); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/cons/5.cc b/libstdc++-v3/testsuite/23_containers/forward_list/cons/5.cc new file mode 100644 index 00000000000..2a4540ce64f --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/cons/5.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// Construction from given number of given item +void +test01() +{ + std::forward_list<float> flv(10, 5.0F); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/cons/6.cc b/libstdc++-v3/testsuite/23_containers/forward_list/cons/6.cc new file mode 100644 index 00000000000..6210c0c8cdc --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/cons/6.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// Construction from iterator range +void +test01() +{ + const int ni = 10; + int i[ni] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + + std::forward_list<int> fl(i, i+ni); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/cons/7.cc b/libstdc++-v3/testsuite/23_containers/forward_list/cons/7.cc new file mode 100644 index 00000000000..2338db28cdc --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/cons/7.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// Copy construction +void +test01() +{ + const int ni = 10; + int i[ni] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + + std::forward_list<int> fl(i, i+ni); + std::forward_list<int> flc(fl); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/cons/8.cc b/libstdc++-v3/testsuite/23_containers/forward_list/cons/8.cc new file mode 100644 index 00000000000..daac89dafcb --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/cons/8.cc @@ -0,0 +1,45 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// Move construction +void +test01() +{ + const int ni = 10; + int i[ni] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + + std::forward_list<int> fl(i, i+ni); + std::forward_list<int> flm(std::move(fl)); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/cons/9.cc b/libstdc++-v3/testsuite/23_containers/forward_list/cons/9.cc new file mode 100644 index 00000000000..1470d8117d1 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/cons/9.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following. +// Construction from initializer list +void +test01() +{ + std::forward_list<double> flil({1.0, 2.0, 3.0, 4.0, 5.0}); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/1.cc b/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/1.cc new file mode 100644 index 00000000000..3498c6efacd --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/1.cc @@ -0,0 +1,73 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +#include <array> + +bool test __attribute__((unused)) = true; + +class PathPoint +{ +public: + PathPoint(char t, std::array<double, 3> & c) + : type(t), coord(c) { } + char getType() const { return type; } +private: + char type; + std::array<double, 3> coord; +}; + +// This test verifies the following. +// emplace_front +// pop_front +// emplace_after +void +test01() +{ + std::forward_list<PathPoint> path; + std::array<double, 3> coord1 = { { 0.0, 1.0, 2.0 } }; + path.emplace_front('a', coord1); + + std::forward_list<PathPoint>::const_iterator pos = path.cbegin(); + + std::array<double, 3> coord2 = { { 3.0, 4.0, 5.0 } }; + path.emplace_after(pos, 'b', coord2); + + VERIFY(path.front().getType() == 'a'); + + path.pop_front(); + + VERIFY(path.front().getType() == 'b'); + + path.pop_front(); + + VERIFY(path.empty() == true); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/2.cc b/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/2.cc new file mode 100644 index 00000000000..9d79b22986b --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/2.cc @@ -0,0 +1,135 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +#include <string> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// insert_after single item +// before_begin iterator +void +test01() +{ + std::forward_list<int> fl({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); + + fl.insert_after(fl.before_begin(), 42); + VERIFY(fl.front() == 42); +} + +// This test verifies the following: +void +test02() +{ + std::forward_list<int> fl({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); + + std::forward_list<int>::const_iterator pos = fl.cbegin(); + ++pos; + VERIFY(*pos == 1); + + // Note: Calling l.insert_after(pos, 5, 42); without the long five + // gets resolved to the iterator range version and fails to compile! + fl.insert_after(pos, 5L, 42); + VERIFY(*pos == 1); + + ++pos; + VERIFY(*pos == 42); + ++pos; + ++pos; + ++pos; + ++pos; + VERIFY(*pos == 42); +} + +// This test verifies the following: +void +test03() +{ + std::forward_list<int> fl({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); + + std::forward_list<int>::const_iterator pos = fl.cbegin(); + ++pos; + VERIFY(*pos == 1); + + int i[3] = {666, 777, 888}; + fl.insert_after(pos, i, i+3); + VERIFY(*pos == 1); + + ++pos; + ++pos; + ++pos; + VERIFY(*pos == 888); + ++pos; + VERIFY(*pos == 2); +} + +// This test verifies the following: +void +test04() +{ + std::forward_list<int> fl({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); + + std::forward_list<int>::const_iterator pos = fl.cbegin(); + ++pos; + VERIFY(*pos == 1); + + fl.insert_after(pos, {-1, -2, -3, -4, -5}); + VERIFY(*pos == 1); + + ++pos; + ++pos; + ++pos; + VERIFY(*pos == -3); +} + +// This test verifies the following: +void +test05() +{ + std::forward_list<std::string> fl({"AAA", "BBB", "CCC"}); + + std::forward_list<std::string>::const_iterator pos = fl.cbegin(); + ++pos; + VERIFY(*pos == "BBB"); + + std::string x( "XXX" ); + fl.insert_after(pos, std::move(x)); + VERIFY(*pos == "BBB"); + ++pos; + VERIFY(*pos == "XXX"); + ++pos; + VERIFY(*pos == "CCC"); +} + +int +main() +{ + test01(); + test02(); + test03(); + test04(); + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/3.cc b/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/3.cc new file mode 100644 index 00000000000..027dd18be97 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/3.cc @@ -0,0 +1,83 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// cbegin +// erase_after one iterator +// pos is useable and points to current element +void +test01() +{ + std::forward_list<int> fl({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); + + std::forward_list<int>::const_iterator pos = fl.cbegin(); + ++pos; + VERIFY(*pos == 1); + + std::forward_list<int>::iterator next = fl.erase_after(pos); + VERIFY(*next == 1); + + VERIFY(*pos == 1); + ++pos; + VERIFY(*pos == 3); +} + +// This test verifies the following: +// cbegin +// erase_after iterator range +// pos is useable and points to current element +void +test02() +{ + std::forward_list<int> fl({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); + + std::forward_list<int>::const_iterator pos = fl.cbegin(); + ++pos; + VERIFY(*pos == 1); + + std::forward_list<int>::iterator stop = fl.begin(); + ++stop; + ++stop; + ++stop; + ++stop; + VERIFY(*stop == 4); + + std::forward_list<int>::iterator next = fl.erase_after(pos, stop); + VERIFY(*next == 1); + + VERIFY(*pos == 1); + ++pos; + VERIFY(*pos == 5); +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/4.cc b/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/4.cc new file mode 100644 index 00000000000..9f9f8c65c8b --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/4.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// swap +void +test01() +{ + std::forward_list<int> fl1({0, 1, 2, 3, 4, 5}); + std::forward_list<int> fl2({666, 777, 888}); + + fl1.swap(fl2); + + VERIFY(fl1.front() == 666); + VERIFY(fl2.front() == 0); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/5.cc b/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/5.cc new file mode 100644 index 00000000000..17ad9297447 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/modifiers/5.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// clear +void +test01() +{ + std::forward_list<int> fl({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); + + VERIFY(fl.empty() == false); + + fl.clear(); + + VERIFY(fl.empty() == true); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/moveable.cc b/libstdc++-v3/testsuite/23_containers/forward_list/moveable.cc new file mode 100644 index 00000000000..3ca95fdf013 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/moveable.cc @@ -0,0 +1,56 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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. + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on list (via swap). If the implementation changed +// this test may begin to fail. + +#include <forward_list> +#include <utility> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +int main() +{ + std::forward_list<int> a, b; + a.push_front(1); + + b = std::move(a); + VERIFY(b.empty() == false); + VERIFY(*b.begin() == 1); + VERIFY(a.empty() == true); + + std::forward_list<int> c(std::move(b)); + VERIFY(c.empty() == false); + (*c.begin() == 1 ); + VERIFY( b.empty() == true ); + + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/operations/1.cc b/libstdc++-v3/testsuite/23_containers/forward_list/operations/1.cc new file mode 100644 index 00000000000..71dc27cde95 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/operations/1.cc @@ -0,0 +1,107 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// +void +test01() +{ + std::forward_list<double> a = {0.0, 1.0, 2.0, 3.0, 4.0}; + std::forward_list<double>::const_iterator posa = a.cbefore_begin(); + + std::forward_list<double> x = {666.0, 777.0, 888.0}; + + a.splice_after(posa, x); + + ++posa; + VERIFY(*posa == 666.0); + + VERIFY(x.empty() == true); +} + +// This test verifies the following: +// +void +test02() +{ + std::forward_list<double> a = {0.0, 1.0, 2.0, 3.0, 4.0}; + std::forward_list<double>::const_iterator posa = a.cbefore_begin(); + ++posa; + VERIFY(*posa == 0.0); + + std::forward_list<double> y = {10.0, 11.0, 12.0, 13.0, 14.0, 15.0}; + std::forward_list<double>::const_iterator befy = y.cbefore_begin(); + ++befy; + VERIFY(*befy == 10.0); + std::forward_list<double>::const_iterator endy = befy; + ++endy; + ++endy; + ++endy; + ++endy; + VERIFY(*endy == 14.0); + + a.splice_after(posa, y, befy, endy); + VERIFY(*posa == 0.0); + + VERIFY(*befy == 10.0); + ++befy; + VERIFY(*befy == 15.0); +} + +// This test verifies the following: +// +void +test03() +{ + std::forward_list<double> a = {0.0, 1.0, 2.0, 3.0, 4.0}; + std::forward_list<double>::const_iterator posa = a.cbefore_begin(); + ++posa; + ++posa; + VERIFY(*posa == 1.0); + + std::forward_list<double> z = {42.0, 43.0, 44.0}; + std::forward_list<double>::const_iterator posz = z.begin(); + VERIFY(*posz == 42.0); + + a.splice_after(posa, z, posz); + VERIFY(*posa == 1.0); + ++posa; + VERIFY(*posa == 43.0); + + VERIFY(*posz == 42.0); + ++posz; + VERIFY(*posz == 44.0); +} + +int +main() +{ + test01(); + test02(); + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/operations/2.cc b/libstdc++-v3/testsuite/23_containers/forward_list/operations/2.cc new file mode 100644 index 00000000000..bbd51af1202 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/operations/2.cc @@ -0,0 +1,51 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// remove +void +test01() +{ + std::forward_list<int> fl ={0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + + fl.remove(7); + + std::forward_list<int>::const_iterator pos = fl.cbefore_begin(); + for (std::size_t i = 0; i < 7; ++i) + ++pos; + VERIFY(*pos == 6); + + ++pos; + VERIFY(*pos == 8); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/operations/3.cc b/libstdc++-v3/testsuite/23_containers/forward_list/operations/3.cc new file mode 100644 index 00000000000..c5bbb8a0ca1 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/operations/3.cc @@ -0,0 +1,48 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +#include <algorithm> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// remove_if +void +test01() +{ + std::forward_list<int> fl ={0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + + fl.remove_if(std::bind2nd(std::less<int>(),5)); + + std::forward_list<int>::const_iterator pos = fl.cbegin(); + VERIFY(*pos == 5); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/operations/4.cc b/libstdc++-v3/testsuite/23_containers/forward_list/operations/4.cc new file mode 100644 index 00000000000..35e5bf8e21d --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/operations/4.cc @@ -0,0 +1,78 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// unique +void +test01() +{ + std::forward_list<int> fl = {99, 5, 99, 6, -5, 666, 777, 888, + 42, 42, 42, 42, 42, 7, 0, 0, 0, 9, 9, 9}; + + fl.unique(); + + std::forward_list<int> fl2 = {99, 5, 99, 6, -5, 666, 777, 888, 42, 7, 0, 9}; + VERIFY(fl == fl2); +} + +// Test comparison predicate. +template<typename Num> + class Mod + { + public: + Mod(const Num & mod) + { + m = mod; + } + bool operator()(const Num i, const Num j) + { + return i%m == j%m; + } + private: + Num m; + }; + +// This test verifies the following: +// unique with predicate +void +test02() +{ + std::forward_list<int> fl = {99, 5, 99, 6, -5, 666, 777, 888, 42, 7, 0, 9}; + + fl.unique(Mod<int>(111)); + + std::forward_list<int> fl2 = {99, 5, 99, 6, -5, 666, 42, 7, 0, 9}; + VERIFY(fl == fl2); +} + +int +main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/operations/5.cc b/libstdc++-v3/testsuite/23_containers/forward_list/operations/5.cc new file mode 100644 index 00000000000..a75b91d9cc8 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/operations/5.cc @@ -0,0 +1,49 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// +void +test01() +{ + std::forward_list<double> a = {0.0, 1.0, 2.0, 3.0, 4.0}; + std::forward_list<double> b = {1.0, 2.0, 3.0, 4.0, 4.0, 5.0}; + + a.merge(b); + + std::forward_list<double> r = {0.0, 1.0, 1.0, 2.0, 2.0, 3.0, 3.0, + 4.0, 4.0, 4.0, 5.0}; + + VERIFY(a == r); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/operations/6.cc b/libstdc++-v3/testsuite/23_containers/forward_list/operations/6.cc new file mode 100644 index 00000000000..dc6268bb329 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/operations/6.cc @@ -0,0 +1,84 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// Comparison functor. +template<typename Num> + class Comp + { + public: + Comp(const Num & num) + { + n = num; + } + bool operator()(const Num i, const Num j) + { + return (n * i) < (n * j); + } + private: + Num n; + }; + +// This test verifies the following: +// +void +test01() +{ + const unsigned int n = 13; + int order[][n] = { + { 0,1,2,3,4,5,6,7,8,9,10,11,12 }, + { 6,2,8,4,11,1,12,7,3,9,5,0,10 }, + { 12,11,10,9,8,7,6,5,4,3,2,1,0 }, + }; + std::forward_list<int> sorted(order[0], order[0] + n); + + for (unsigned int i = 0; i < sizeof(order)/sizeof(*order); ++i) + { + std::forward_list<int> head(order[i], order[i] + n); + + head.sort(); + + VERIFY(head == sorted); + } + + std::forward_list<int> reversed(order[2], order[2] + n); + for (unsigned int i = 0; i < sizeof(order)/sizeof(*order); ++i) + { + std::forward_list<int> head(order[i], order[i] + n); + + Comp<int> comp(-1); + head.sort( comp ); + + VERIFY(head == reversed); + } +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/operations/7.cc b/libstdc++-v3/testsuite/23_containers/forward_list/operations/7.cc new file mode 100644 index 00000000000..a51ce77eab5 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/operations/7.cc @@ -0,0 +1,55 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +#include <algorithm> + +bool test __attribute__((unused)) = true; + +// This test verifies the following: +// +void +test01() +{ + const unsigned int n = 13; + int order[n] = {0,1,2,3,4,5,6,7,8,9,10,11,12}; + + std::forward_list<int> fl(order, order + n); + + std::forward_list<int> fl2; + for (std::size_t i = 0; i < n; ++i) + fl2.push_front(order[i]); + + fl.reverse(); + + VERIFY(std::lexicographical_compare(fl.begin(), fl.end(), + fl2.begin(), fl2.end()) == false); +} + +int +main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/requirements/1.cc b/libstdc++-v3/testsuite/23_containers/forward_list/requirements/1.cc new file mode 100644 index 00000000000..40f8ad1d39f --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/forward_list/requirements/1.cc @@ -0,0 +1,70 @@ +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2008 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 Pred the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.3.n forward_list xxx [lib.forward_list.xxx] + +#include <forward_list> +#include <testsuite_hooks.h> + +bool test __attribute__((unused)) = true; + +// A nontrivial type. +template<typename T> + struct A { }; + +// Another nontrivial type +struct B { }; + +// A nontrivial type convertible from an int +struct C +{ + C(int i) : i_(i) { } + bool operator==(const C& rhs) { return i_ == rhs.i_; } + int i_; +}; + +// This test verifies the following. +// +void +test01() +{ + std::forward_list< A<B> > lst; + VERIFY(lst.begin() == lst.end()); + VERIFY(std::distance(lst.begin(), lst.end()) == 0); + + // check type definitions -- will fail compile if missing + typedef std::forward_list< A<B> >::reference reference; + typedef std::forward_list< A<B> >::const_reference const_reference; + typedef std::forward_list< A<B> >::iterator iterator; + typedef std::forward_list< A<B> >::const_iterator const_iterator; + typedef std::forward_list< A<B> >::size_type size_type; + typedef std::forward_list< A<B> >::difference_type difference_type; + typedef std::forward_list< A<B> >::value_type value_type; + typedef std::forward_list< A<B> >::allocator_type allocator_type; + typedef std::forward_list< A<B> >::pointer pointer; + typedef std::forward_list< A<B> >::const_pointer const_pointer; +} + +int +main() +{ + test01(); + return 0; +} |