1// { dg-options "-std=gnu++11" }
2
3// Copyright (C) 2012-2015 Free Software Foundation, Inc.
4//
5// This file is part of the GNU ISO C++ Library.  This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 3, or (at your option)
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License along
17// with this library; see the file COPYING3.  If not see
18// <http://www.gnu.org/licenses/>.
19
20#include <forward_list>
21
22#include <testsuite_hooks.h>
23
24void test01()
25{
26  bool test __attribute__((unused)) = true;
27
28  std::forward_list<int> fl1(1, 5), fl2(1, 4), fl3(1, 3),
29                         fl4(1, 2), fl5(1, 1), fl6(1, 0);
30
31  fl1.splice_after(fl1.before_begin(), fl2);
32
33  auto it = fl1.begin();
34
35  VERIFY( *it == 4 );
36
37  ++it;
38
39  VERIFY( *it == 5 );
40
41  fl3.splice_after(fl3.before_begin(), fl4, fl4.before_begin());
42
43  it = fl3.begin();
44
45  VERIFY( *it == 2 );
46
47  ++it;
48
49  VERIFY( *it == 3 );
50
51  fl5.splice_after(fl5.before_begin(), fl6, fl6.before_begin(), fl6.end());
52
53  it = fl5.begin();
54
55  VERIFY( *it == 0 );
56
57  ++it;
58
59  VERIFY( *it == 1 );
60
61  fl1.merge(fl2);
62
63  it = fl1.begin();
64
65  VERIFY( *it == 4 );
66
67  ++it;
68
69  VERIFY( *it == 5 );
70
71  fl1.merge(fl3, std::less<int>());
72
73  it = fl1.begin();
74
75  VERIFY( *it == 2 );
76
77  ++it;
78
79  VERIFY( *it == 3 );
80
81  ++it;
82
83  VERIFY( *it == 4 );
84
85  ++it;
86
87  VERIFY( *it == 5 );
88}
89
90int main()
91{
92  test01();
93  return 0;
94}
95