home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stlpt453.zip / STLport-4.5.3 / test / regression / mismtch2.cpp < prev    next >
C/C++ Source or Header  |  2001-05-18  |  1KB  |  43 lines

  1. // STLport regression testsuite component.
  2. // To compile as a separate example, please #define MAIN.
  3.  
  4. #include <algorithm>
  5. #include <iostream>
  6. #include <cstring>
  7.  
  8. #ifdef MAIN 
  9. #define mismtch2_test main
  10. #endif
  11.  
  12. #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
  13. using namespace std;
  14. #endif
  15.  
  16. bool str_equal(const char* a_, const char* b_)
  17. {
  18.   return strcmp(a_, b_) == 0 ? 1 : 0;
  19. }
  20.  
  21. int mismtch2_test(int, char**)
  22. {
  23.   cout<<"Results of mismtch2_test:"<<endl;
  24.  
  25. const unsigned size = 5;
  26. char* n1[size] = { "Brett", "Graham", "Jack", "Mike", "Todd" };
  27.  
  28.   char* n2[size];
  29.   copy(n1, n1 + 5, (char**)n2);
  30.   pair <char**, char**> result = mismatch((char**)n1, (char**)n1 + size, (char**)n2, str_equal);
  31.   if(result.first == n1 + size && result.second == n2 + size)
  32.     cout << "n1 and n2 are the same" << endl;
  33.   else
  34.     cout << "mismatch at index: " <<(result.first - n1) << endl;
  35.   n2[2] = "QED";
  36.   result = mismatch((char**)n1, (char**)n1 + size, (char**)n2, str_equal);
  37.   if(result.first == n2 + size && result.second == n2 + size)
  38.     cout << "n1 and n2 are the same" << endl;
  39.   else
  40.     cout << "mismatch at index: " <<(result.first - n1) << endl;
  41.   return 0;
  42. }
  43.