1 // 2006-01-19 Paolo Carlini <pcarlini@suse.de>
3 // Copyright (C) 2006, 2009 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 3, or (at your option)
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.
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/>.
20 // 23.2.2.4 list operations [lib.list.ops]
23 #include <testsuite_hooks.h>
24 #include <testsuite_allocator.h>
26 // Check the splice (and merge) bits of N1599.
27 template<typename _Tp>
31 bool test __attribute__((unused)) = true;
33 typedef _Tp list_type;
34 typedef typename list_type::allocator_type allocator_type;
36 const int data1[] = {1, 2, 3, 4, 5};
37 const int data2[] = {6, 7, 8, 9, 10};
38 const size_t N1 = sizeof(data1) / sizeof(int);
39 const size_t N2 = sizeof(data2) / sizeof(int);
41 allocator_type alloc01(1), alloc02(2);
43 list_type l01(data1, data1 + N1, alloc01);
44 const list_type l01_ref = l01;
46 list_type l02(data2, data2 + N2, alloc02);
47 const list_type l02_ref = l02;
53 l01.splice(l01.begin(), l02);
55 catch(std::runtime_error&)
64 VERIFY( l01 == l01_ref );
65 VERIFY( l02 == l02_ref );
70 l01.splice(l01.begin(), l02, l02.begin());
72 catch(std::runtime_error&)
81 VERIFY( l01 == l01_ref );
82 VERIFY( l02 == l02_ref );
87 l01.splice(l01.begin(), l02, l02.begin(), l02.end());
89 catch(std::runtime_error&)
98 VERIFY( l01 == l01_ref );
99 VERIFY( l02 == l02_ref );
106 catch(std::runtime_error&)
115 VERIFY( l01 == l01_ref );
116 VERIFY( l02 == l02_ref );
121 l01.merge(l02, std::less<int>());
123 catch(std::runtime_error&)
132 VERIFY( l01 == l01_ref );
133 VERIFY( l02 == l02_ref );