1 // 2006-01-19 Paolo Carlini <pcarlini@suse.de>
3 // Copyright (C) 2006 Free Software Foundation, Inc.
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 2, or (at your option)
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.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
21 // 23.2.2.4 list operations [lib.list.ops]
25 #include <testsuite_hooks.h>
26 #include <testsuite_allocator.h>
28 // Check the splice (and merge) bits of N1599.
32 bool test
__attribute__((unused
)) = true;
34 typedef __gnu_test::uneq_allocator
<int> my_alloc
;
35 typedef std::list
<int, my_alloc
> my_list
;
37 const int data1
[] = {1, 2, 3, 4, 5};
38 const int data2
[] = {6, 7, 8, 9, 10};
39 const size_t N1
= sizeof(data1
) / sizeof(int);
40 const size_t N2
= sizeof(data2
) / sizeof(int);
42 my_alloc
alloc01(1), alloc02(2);
44 my_list
l01(data1
, data1
+ N1
, alloc01
);
45 const my_list l01_ref
= l01
;
47 my_list
l02(data2
, data2
+ N2
, alloc02
);
48 const my_list l02_ref
= l02
;
54 l01
.splice(l01
.begin(), l02
);
56 catch(std::runtime_error
&)
65 VERIFY( l01
== l01_ref
);
66 VERIFY( l02
== l02_ref
);
71 l01
.splice(l01
.begin(), l02
, l02
.begin());
73 catch(std::runtime_error
&)
82 VERIFY( l01
== l01_ref
);
83 VERIFY( l02
== l02_ref
);
88 l01
.splice(l01
.begin(), l02
, l02
.begin(), l02
.end());
90 catch(std::runtime_error
&)
99 VERIFY( l01
== l01_ref
);
100 VERIFY( l02
== l02_ref
);
107 catch(std::runtime_error
&)
116 VERIFY( l01
== l01_ref
);
117 VERIFY( l02
== l02_ref
);
122 l01
.merge(l02
, std::less
<int>());
124 catch(std::runtime_error
&)
133 VERIFY( l01
== l01_ref
);
134 VERIFY( l02
== l02_ref
);