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

  1. // STLport regression testsuite component.
  2. // To compile as a separate example, please #define MAIN.
  3.  
  4. #include <string>
  5. #include <iostream>
  6.  
  7. #ifdef MAIN 
  8. #define string1_test main
  9. #endif
  10.  
  11. #if !defined (STLPORT) || defined(__STL_USE_NAMESPACES)
  12. using namespace std;
  13. #endif
  14. int string1_test(int, char**)
  15. {
  16.   cout<<"Results of string1_test:"<<endl;
  17.   char* array = "Hello, World!";
  18.   std::string v(array);
  19.   int i;
  20.   cout << v << endl;
  21.   v.erase(v.begin() + 1, v.end() - 1); // Erase all but first and last.
  22.   for(i = 0; i < v.size(); i++)
  23.     cout << "v[" << i << "] = " << v[i] << endl;
  24.   cout << endl;
  25.   v.insert(1, (char*)array);
  26.   v.erase(v.begin()); // Erase first element.
  27.   v.erase(v.end() - 1); // Erase last element.
  28.   cout << v << endl;
  29.   v.clear(); // Erase all.
  30.   return 0;
  31. }
  32.