31
|
1 |
|
|
2 |
// STLport regression testsuite component.
|
|
3 |
// To compile as a separate example, please #define MAIN.
|
|
4 |
|
|
5 |
#include <vector>
|
|
6 |
#include <algorithm>
|
|
7 |
#include <functional>
|
|
8 |
#include <iterator>
|
|
9 |
#include <iostream>
|
|
10 |
|
|
11 |
#ifdef MAIN
|
|
12 |
#define inplmrg2_test main
|
|
13 |
#endif
|
|
14 |
|
|
15 |
#if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
|
|
16 |
using namespace std;
|
|
17 |
#endif
|
|
18 |
int inplmrg2_test(int, char**)
|
|
19 |
{
|
|
20 |
cout<<"Results of inplmrg2_test:"<<endl;
|
|
21 |
vector <int> v1(10);
|
|
22 |
int failures = 0;
|
|
23 |
for(int i = 0; i < v1.size(); i++)
|
|
24 |
v1[i] =(v1.size() - i - 1) % 5;
|
|
25 |
ostream_iterator <int> iter(cout, " ");
|
|
26 |
copy(v1.begin(), v1.end(), iter);
|
|
27 |
cout << endl;
|
|
28 |
inplace_merge(v1.begin(), v1.begin() + 5,
|
|
29 |
v1.end(),
|
|
30 |
greater<int>());
|
|
31 |
copy(v1.begin(), v1.end(), iter);
|
|
32 |
cout << endl;
|
|
33 |
if(v1[0] != 4)
|
|
34 |
failures++;
|
|
35 |
if(v1[1] != 4)
|
|
36 |
failures++;
|
|
37 |
if(v1[2] != 3)
|
|
38 |
failures++;
|
|
39 |
if(v1[3] != 3)
|
|
40 |
failures++;
|
|
41 |
if(v1[4] != 2)
|
|
42 |
failures++;
|
|
43 |
if(v1[5] != 2)
|
|
44 |
failures++;
|
|
45 |
if(v1[6] != 1)
|
|
46 |
failures++;
|
|
47 |
if(v1[7] != 1)
|
|
48 |
failures++;
|
|
49 |
if(v1[8] != 0)
|
|
50 |
failures++;
|
|
51 |
if(v1[9] != 0)
|
|
52 |
failures++;
|
|
53 |
|
|
54 |
return failures;
|
|
55 |
}
|