stdcpp/tsrc/Stdcpp_test/stlport/auto/stlport_setintr/src/setintr1.cpp
changeset 31 ce057bb09d0b
child 34 5fae379060a7
equal deleted inserted replaced
30:e20de85af2ee 31:ce057bb09d0b
       
     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 #include <iterator>
       
    21 
       
    22 #include <algorithm>
       
    23 #include <vector>
       
    24 #include <iostream>
       
    25 #include <iterator>
       
    26 // #include <functional>
       
    27 #include <numeric>
       
    28 
       
    29 #ifdef MAIN 
       
    30 #define setintr1_test main
       
    31 #endif
       
    32 
       
    33 #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
       
    34 using namespace std;
       
    35 #endif
       
    36 int setintr1_test(int, char**)
       
    37 {
       
    38   int failures=0;
       
    39   cout<<"Results of setintr1_test:"<<endl;
       
    40   vector <int> v1(10);
       
    41   iota(v1.begin(), v1.end(), 0);
       
    42   vector <int> v2(10);
       
    43   vector <int> v3(3);
       
    44   iota(v2.begin(), v2.end(), 7);
       
    45   ostream_iterator <int> iter(cout, " ");
       
    46   cout << "v1: ";
       
    47   copy(v1.begin(), v1.end(), iter);
       
    48    
       
    49    if(0!=v1[0])
       
    50      failures++;
       
    51    else if(1!=v1[1])
       
    52      failures++;
       
    53    else if(2!=v1[2])
       
    54      failures++;  
       
    55    else if(3!=v1[3])
       
    56      failures++;
       
    57    else if(4!=v1[4])
       
    58      failures++;  
       
    59    else if(5!=v1[5])
       
    60      failures++;
       
    61    else if(6!=v1[6])
       
    62      failures++;  
       
    63    else if(7!=v1[7])
       
    64      failures++;
       
    65    else if(8!=v1[8])
       
    66      failures++; 
       
    67    else if(9!=v1[9])
       
    68      failures++;   
       
    69      
       
    70   cout << "\nv2: ";
       
    71   copy(v2.begin(), v2.end(), iter);
       
    72   cout << endl;
       
    73   
       
    74   if(7!=v2[0])
       
    75      failures++;
       
    76    else if(8!=v2[1])
       
    77      failures++;
       
    78    else if(9!=v2[2])
       
    79      failures++;  
       
    80    else if(10!=v2[3])
       
    81      failures++;
       
    82    else if(11!=v2[4])
       
    83      failures++;  
       
    84    else if(12!=v2[5])
       
    85      failures++;
       
    86    else if(13!=v2[6])
       
    87      failures++;  
       
    88    else if(14!=v2[7])
       
    89      failures++;
       
    90    else if(15!=v2[8])
       
    91      failures++; 
       
    92    else if(16!=v2[9])
       
    93      failures++;   
       
    94   
       
    95   set_intersection(v1.begin(), v1.end(), v2.begin(), v2.end(),v3.begin());
       
    96    copy(v3.begin(),v3.end(),iter);
       
    97   cout << endl;
       
    98   
       
    99   if(failures)
       
   100      return 1;
       
   101   else
       
   102      return 0;
       
   103 }
       
   104