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