home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stlpt453.zip / STLport-4.5.3 / test / regression / mismtch1.cpp < prev    next >
C/C++ Source or Header  |  2000-12-07  |  1KB  |  38 lines

  1. // STLport regression testsuite component.
  2. // To compile as a separate example, please #define MAIN.
  3.  
  4. #include <vector>
  5. #include <algorithm>
  6. #include <numeric>
  7. #include <iostream>
  8.  
  9. #ifdef MAIN 
  10. #define mismtch1_test main
  11. #endif
  12.  
  13. #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
  14. using namespace std;
  15. #endif
  16. int mismtch1_test(int, char**)
  17. {
  18.   cout<<"Results of mismtch1_test:"<<endl;
  19.   typedef vector<int> IntVec;
  20.   IntVec v1(10);
  21.   IntVec v2(v1.size());
  22.   iota(v1.begin(), v1.end(), 0);
  23.   iota(v2.begin(), v2.end(), 0);
  24.   pair <IntVec::iterator, IntVec::iterator> result =
  25.       mismatch(v1.begin(), v1.end(), v2.begin());
  26.   if(result.first == v1.end() && result.second == v2.end())
  27.     cout << "v1 and v2 are the same" << endl;
  28.   else
  29.     cout << "mismatch at index: " <<(result.first - v1.begin()) << endl;
  30.   v2[v2.size()/2] = 42;
  31.   result = mismatch(v1.begin(), v1.end(), v2.begin());
  32.   if(result.first == v1.end() && result.second == v2.end())
  33.     cout << "v1 and v2 are the same" << endl;
  34.   else
  35.     cout << "mismatch at index: " <<(result.first - v1.begin()) << endl;
  36.   return 0;
  37. }
  38.