31
|
1 |
|
|
2 |
// STLport regression testsuite component.
|
|
3 |
// To compile as a separate example, please #define MAIN.
|
|
4 |
|
|
5 |
#include <iostream>
|
|
6 |
#include <list>
|
|
7 |
|
|
8 |
#ifdef MAIN
|
|
9 |
#define list2_test main
|
|
10 |
#endif
|
|
11 |
|
|
12 |
#if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
|
|
13 |
using namespace std;
|
|
14 |
#endif
|
|
15 |
int list2_test(int, char**)
|
|
16 |
{
|
|
17 |
cout<<"Results of list2_test:"<<endl;
|
|
18 |
int array1 [] = { 1, 16 };
|
|
19 |
int array2 [] = { 4, 9 };
|
|
20 |
int array3[4];
|
|
21 |
int failures = 0;int a=0;
|
|
22 |
list<int> l1(array1, array1 + 2);
|
|
23 |
list<int> l2(array2, array2 + 2);
|
|
24 |
std::list<int>::iterator i = l1.begin();
|
|
25 |
i++;
|
|
26 |
l1.splice(i, l2, l2.begin(), l2.end());
|
|
27 |
i = l1.begin();
|
|
28 |
while(i != l1.end())
|
|
29 |
{
|
|
30 |
array3[a++] = *i;
|
|
31 |
cout << *i++ << endl;
|
|
32 |
}
|
|
33 |
|
|
34 |
if(array3[0] != 1)
|
|
35 |
failures++;
|
|
36 |
if(array3[1] != 4)
|
|
37 |
failures++;
|
|
38 |
if(array3[2] != 9)
|
|
39 |
failures++;
|
|
40 |
if(array3[3] != 16)
|
|
41 |
failures++;
|
|
42 |
return failures;
|
|
43 |
}
|