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