]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/23_containers/list/operations/2.cc
Licensing changes to GPLv3 resp. GPLv3 with GCC Runtime Exception.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 23_containers / list / operations / 2.cc
CommitLineData
748086b7 1// Copyright (C) 2001, 2004, 2005, 2009 Free Software Foundation, Inc.
1fc61093
SW
2//
3// This file is part of the GNU ISO C++ Library. This library is free
4// software; you can redistribute it and/or modify it under the
5// terms of the GNU General Public License as published by the
748086b7 6// Free Software Foundation; either version 3, or (at your option)
1fc61093
SW
7// any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without Pred the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License along
748086b7
JJ
15// with this library; see the file COPYING3. If not see
16// <http://www.gnu.org/licenses/>.
1fc61093 17
17472bb6 18// 23.2.2.4 list operations [lib.list.ops]
1fc61093
SW
19
20#include <list>
21#include <testsuite_hooks.h>
22
11f10e6b 23bool test __attribute__((unused)) = true;
1fc61093 24
17472bb6 25// splice(p, x, i) + remove_if + operator==
1fc61093 26void
17472bb6 27test02()
1fc61093 28{
17472bb6
BK
29 const int A[] = {1, 2, 3, 4, 5};
30 const int B[] = {2, 1, 3, 4, 5};
31 const int C[] = {1, 3, 4, 5, 2};
32 const int N = sizeof(A) / sizeof(int);
33 std::list<int> list0201(A, A + N);
34 std::list<int> list0202(A, A + N);
35 std::list<int> list0203(B, B + N);
36 std::list<int> list0204(C, C + N);
37 std::list<int>::iterator i = list0201.begin();
38
39 // result should be unchanged
40 list0201.splice(list0201.begin(), list0201, i);
41 VERIFY(list0201 == list0202);
42
43 // result should be [2 1 3 4 5]
44 ++i;
45 list0201.splice(list0201.begin(), list0201, i);
46 VERIFY(list0201 != list0202);
47 VERIFY(list0201 == list0203);
48
49 // result should be [1 3 4 5 2]
50 list0201.splice(list0201.end(), list0201, i);
51 VERIFY(list0201 == list0204);
1fc61093
SW
52}
53
11f10e6b 54int main()
1fc61093 55{
17472bb6
BK
56 test02();
57 return 0;
1fc61093 58}