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

  1. // STLport regression testsuite component.
  2. // To compile as a separate example, please #define MAIN.
  3.  
  4. #include <iostream>
  5. #include <cstring>
  6. #include <vector>
  7. #include <algorithm>
  8. #include <iterator>
  9. #include <functional>
  10.  
  11. #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
  12. using namespace std;
  13. #endif
  14.  
  15. #ifdef MAIN 
  16. #define uniqcpy2_test main
  17. #endif
  18. static bool str_equal(const char* a_, const char* b_)
  19. {
  20.   return strcmp(a_, b_) == 0 ? 1 : 0;
  21. }
  22.  
  23. int uniqcpy2_test(int, char**)
  24. {
  25.   cout<<"Results of uniqcpy2_test:"<<endl;
  26.  
  27.   char* labels[] = { "Q","Q","W","W","E","E","R","T","T","Y","Y" };
  28.  
  29.   const unsigned count = sizeof(labels) / sizeof(labels[0]);
  30.   ostream_iterator <char*> iter(cout);
  31.   copy((char**)labels, (char**)labels + count, iter);
  32.   cout << endl;
  33.   char* uCopy[count];
  34.   fill((char**)uCopy, (char**)uCopy + count, (char*)"");
  35.   unique_copy((char**)labels, (char**)labels + count, (char**)uCopy, str_equal);
  36.   copy((char**)labels, (char**)labels + count, iter);
  37.   cout << endl;
  38.   copy((char**)uCopy, (char**)uCopy + count, iter);
  39.   cout << endl;
  40.   return 0;
  41. }
  42.