home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stl453up.zip / stl453fx / test / regression / adjfind0.cpp < prev    next >
C/C++ Source or Header  |  2002-04-29  |  1KB  |  44 lines

  1. // STLport regression testsuite component.
  2. // To compile as a separate example, please #define MAIN.
  3.  
  4. #include <algorithm>
  5. #include <iostream>
  6.  
  7.  
  8. #ifdef MAIN 
  9. #define adjfind0_test main
  10. #endif
  11.  
  12. #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
  13. using namespace std;
  14. #endif
  15. int adjfind0_test(int, char**)
  16. {
  17.   cout<<"Results of adjfind0_test:"<<endl;
  18. int numbers1 [5] = { 1, 2, 4, 8, 16 };
  19. int numbers2 [5] = { 5, 3, 2, 1, 1 };
  20.  
  21.   int* location = adjacent_find((int*)numbers1, (int*)numbers1 + 5);
  22.  
  23.   if(location != numbers1 + 5)
  24.     cout
  25.       << "Found adjacent pair of: "
  26.       << *location
  27.       << " at offset "
  28.       <<(location - numbers1)
  29.       << endl;
  30.   else
  31.     cout << "No adjacent pairs" << endl;
  32.   location = adjacent_find((int*)numbers2, (int*)numbers2 + 5);
  33.   if(location != numbers2 + 5)
  34.     cout
  35.       << "Found adjacent pair of: "
  36.       << *location
  37.       << " at offset "
  38.       <<(location - numbers2)
  39.       << endl;
  40.   else
  41.     cout << "No adjacent pairs" << endl;
  42.   return 0;
  43. }
  44.