equal
deleted
inserted
replaced
|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 // STLport regression testsuite component. |
|
19 // To compile as a separate example, please #define MAIN. |
|
20 |
|
21 #include <functional> |
|
22 #include <algorithm> |
|
23 #include <vector> |
|
24 #include <iterator> |
|
25 #include <iostream> |
|
26 |
|
27 #ifdef MAIN |
|
28 #define pheap2_test main |
|
29 #endif |
|
30 |
|
31 #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES) |
|
32 using namespace std; |
|
33 #endif |
|
34 int pheap2_test(int, char**) |
|
35 { |
|
36 |
|
37 int failures=0; |
|
38 cout<<"Results of pheap2_test:"<<endl; |
|
39 vector<int> v; |
|
40 |
|
41 v.push_back(1); |
|
42 v.push_back(20); |
|
43 v.push_back(4); |
|
44 make_heap(v.begin(), v.end(), greater<int>()); |
|
45 |
|
46 v.push_back(7); |
|
47 push_heap(v.begin(), v.end(), greater<int>()); |
|
48 |
|
49 sort_heap(v.begin(), v.end(), greater<int>()); |
|
50 ostream_iterator<int> iter(cout, " "); |
|
51 copy(v.begin(), v.end(), iter); |
|
52 cout << endl; |
|
53 |
|
54 if( 20!=v[0]) |
|
55 failures++; |
|
56 else if(7!=v[1]) |
|
57 failures++; |
|
58 else if(4!=v[2]) |
|
59 failures++; |
|
60 else if(1!=v[3]) |
|
61 failures++; |
|
62 |
|
63 if(failures) |
|
64 return 1; |
|
65 else |
|
66 return 0; |
|
67 } |
|
68 |