home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stlpt453.zip / STLport-4.5.3 / test / regression / unique2.cpp < prev    next >
C/C++ Source or Header  |  2001-05-18  |  890b  |  37 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. #include <iterator>
  8. #include <functional>
  9.  
  10. #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
  11. using namespace std;
  12. #endif
  13.  
  14. #ifdef MAIN 
  15. #define unique2_test main
  16. #endif
  17. static bool str_equal(const char* a_, const char* b_)
  18. {
  19.   return strcmp(a_, b_) == 0 ? 1 : 0;
  20. }
  21.  
  22. int unique2_test(int, char**)
  23. {
  24.   cout<<"Results of unique2_test:"<<endl;
  25.  
  26. char* labels[] = { "Q","Q","W","W","E","E","R","T","T","Y","Y" };
  27.  
  28.   const unsigned count = sizeof(labels) / sizeof(labels[0]);
  29.   ostream_iterator <char*> iter(cout);
  30.   copy((char**)labels, (char**)labels + count, iter);
  31.   cout << endl;
  32.   unique((char**)labels, (char**)labels + count, str_equal);
  33.   copy((char**)labels, (char**)labels + count, iter);
  34.   cout << endl;
  35.   return 0;
  36. }
  37.