]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/23_containers/forward_list/operations/1.cc
forward_list.h (splice_after): Use forward.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 23_containers / forward_list / operations / 1.cc
CommitLineData
3a63c9cd
ESR
1// { dg-options "-std=gnu++0x" }
2
748086b7 3// Copyright (C) 2008, 2009 Free Software Foundation, Inc.
3a63c9cd
ESR
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
748086b7 8// Free Software Foundation; either version 3, or (at your option)
3a63c9cd
ESR
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without Pred 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
748086b7
JJ
17// with this library; see the file COPYING3. If not see
18// <http://www.gnu.org/licenses/>.
3a63c9cd
ESR
19
20// 23.2.3.n forward_list xxx [lib.forward_list.xxx]
21
22#include <forward_list>
23#include <testsuite_hooks.h>
24
25bool test __attribute__((unused)) = true;
26
27// This test verifies the following:
28//
29void
30test01()
31{
32 std::forward_list<double> a = {0.0, 1.0, 2.0, 3.0, 4.0};
33 std::forward_list<double>::const_iterator posa = a.cbefore_begin();
34
35 std::forward_list<double> x = {666.0, 777.0, 888.0};
36
4c650853 37 a.splice_after(posa, std::move(x));
3a63c9cd
ESR
38
39 ++posa;
40 VERIFY(*posa == 666.0);
41
42 VERIFY(x.empty() == true);
43}
44
45// This test verifies the following:
46//
47void
48test02()
49{
50 std::forward_list<double> a = {0.0, 1.0, 2.0, 3.0, 4.0};
51 std::forward_list<double>::const_iterator posa = a.cbefore_begin();
52 ++posa;
53 VERIFY(*posa == 0.0);
54
55 std::forward_list<double> y = {10.0, 11.0, 12.0, 13.0, 14.0, 15.0};
56 std::forward_list<double>::const_iterator befy = y.cbefore_begin();
57 ++befy;
58 VERIFY(*befy == 10.0);
59 std::forward_list<double>::const_iterator endy = befy;
60 ++endy;
61 ++endy;
62 ++endy;
63 ++endy;
64 VERIFY(*endy == 14.0);
65
4c650853 66 a.splice_after(posa, std::move(y), befy, endy);
3a63c9cd
ESR
67 VERIFY(*posa == 0.0);
68
69 VERIFY(*befy == 10.0);
70 ++befy;
71 VERIFY(*befy == 15.0);
72}
73
74// This test verifies the following:
75//
76void
77test03()
78{
79 std::forward_list<double> a = {0.0, 1.0, 2.0, 3.0, 4.0};
80 std::forward_list<double>::const_iterator posa = a.cbefore_begin();
81 ++posa;
82 ++posa;
83 VERIFY(*posa == 1.0);
84
85 std::forward_list<double> z = {42.0, 43.0, 44.0};
86 std::forward_list<double>::const_iterator posz = z.begin();
87 VERIFY(*posz == 42.0);
88
4c650853 89 a.splice_after(posa, std::move(z), posz);
3a63c9cd
ESR
90 VERIFY(*posa == 1.0);
91 ++posa;
92 VERIFY(*posa == 43.0);
93
94 VERIFY(*posz == 42.0);
95 ++posz;
96 VERIFY(*posz == 44.0);
97}
98
99int
100main()
101{
102 test01();
103 test02();
104 test03();
105 return 0;
106}