stdcpp/tsrc/Stdcpp_test/stlport/auto/stlport_stblptn/src/stblptn0.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 <iostream>
       
     7 
       
     8 #ifdef MAIN 
       
     9 #define stblptn0_test main
       
    10 #endif
       
    11 static bool less_10(int a_)
       
    12 {
       
    13   return a_ < 10 ? 1 : 0;
       
    14 }
       
    15 
       
    16 #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
       
    17 using namespace std;
       
    18 #endif
       
    19 int stblptn0_test(int, char**)
       
    20 {
       
    21   
       
    22   int failures=0;
       
    23   cout<<"Results of stblptn0_test:"<<endl;
       
    24 
       
    25 int numbers[6] = { 10, 5, 11, 20, 6, -2 };
       
    26 
       
    27   stable_partition((int*)numbers, (int*)numbers + 6, less_10);
       
    28   for(int i = 0; i < 6; i++)
       
    29     cout << numbers[i] << ' ';
       
    30   cout << endl;
       
    31   if(5!=numbers[0])
       
    32     failures++;
       
    33   else if(6!=numbers[1])
       
    34     failures++;
       
    35   else if(-2!=numbers[2])
       
    36     failures++;
       
    37   else if(10!=numbers[3])
       
    38     failures++;
       
    39   else if(11!=numbers[4])
       
    40     failures++;
       
    41   else if(20!=numbers[5])
       
    42     failures++;
       
    43   cout.flush();
       
    44  
       
    45   if(failures)
       
    46    return 1;
       
    47   else 
       
    48    return 0; 
       
    49 }
       
    50