2009-07-17 Richard Guenther <rguenther@suse.de>
[official-gcc.git] / libstdc++-v3 / testsuite / 23_containers / list / operations / 3.h
blob4d28daea12bb49e5fec799ea20ec3366ba9d83a2
1 // Copyright (C) 2001, 2004, 2005, 2009 Free Software Foundation, Inc.
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
6 // Free Software Foundation; either version 3, or (at your option)
7 // any later version.
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.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // 23.2.2.4 list operations [lib.list.ops]
20 #include <testsuite_hooks.h>
22 // splice(p, x, f, l) + sort + merge + unique
23 template<typename _Tp>
24 void
25 operations03()
27 bool test __attribute__((unused)) = true;
28 typedef _Tp list_type;
29 typedef typename list_type::iterator iterator;
31 const int A[] = {103, 203, 603, 303, 403, 503};
32 const int B[] = {417, 417, 417, 417, 417};
33 const int E[] = {103, 417, 417, 203, 603, 303, 403, 503};
34 const int F[] = {103, 203, 303, 403, 417, 417, 503, 603};
35 const int C[] = {103, 203, 303, 403, 417, 417, 417, 417, 417, 503, 603};
36 const int D[] = {103, 203, 303, 403, 417, 503, 603};
37 const int N = sizeof(A) / sizeof(int);
38 const int M = sizeof(B) / sizeof(int);
39 const int P = sizeof(C) / sizeof(int);
40 const int Q = sizeof(D) / sizeof(int);
41 const int R = sizeof(E) / sizeof(int);
43 list_type list0301(A, A + N);
44 list_type list0302(B, B + M);
45 list_type list0303(C, C + P);
46 list_type list0304(D, D + Q);
47 list_type list0305(E, E + R);
48 list_type list0306(F, F + R);
49 iterator p = list0301.begin();
50 iterator q = list0302.begin();
52 ++p; ++q; ++q;
53 list0301.splice(p, list0302, list0302.begin(), q);
54 VERIFY(list0301 == list0305);
55 VERIFY(list0301.size() == N + 2);
56 VERIFY(list0302.size() == M - 2);
58 list0301.sort();
59 VERIFY(list0301 == list0306);
61 list0301.merge(list0302);
62 VERIFY(list0301.size() == N + M);
63 VERIFY(list0302.size() == 0);
64 VERIFY(list0301 == list0303);
66 list0301.unique();
67 VERIFY(list0301 == list0304);