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 / sstream1.cpp < prev    next >
C/C++ Source or Header  |  2000-12-07  |  1KB  |  46 lines

  1. // STLport regression testsuite component.
  2. // To compile as a separate example, please #define MAIN.
  3.  
  4. #include <sstream>
  5. #include <cassert>
  6.  
  7. #ifdef MAIN 
  8. #define sstream1_test main
  9. #endif
  10.  
  11. int sstream1_test(int, char**)
  12. {
  13.     
  14.     std::istringstream iss;
  15.     int x[9];
  16.     std::fill_n(x, 9, 999);
  17.     iss.str(std::string("0-0+0 010-010+010 0x1-0x1+0x1"));
  18.     iss >> std::hex;
  19.     iss >> x[0] >> x[1] >> x[2] >> x[3] >> x[4] >> x[5] >> x[6] >> x[7] >> x[8];
  20.     assert(x[0] == 0x0);
  21.     assert(x[1] == -0x0);
  22.     assert(x[2] == +0x0);
  23.     assert(x[3] == 0x010);
  24.     assert(x[4] == -0x010);
  25.     assert(x[5] == +0x010);
  26.     assert(x[6] == 0x1);
  27.     assert(x[7] == -0x1);
  28.     assert(x[8] == +0x1);
  29.     
  30.     iss.clear();
  31.     iss.str(std::string("0-0+0 010-010+010 0x1-0x1+0x1"));
  32.     iss.unsetf(std::ios_base::dec | std::ios_base::hex);
  33.     std::fill_n(x, 9, 999);
  34.     iss >> x[0] >> x[1] >> x[2] >> x[3] >> x[4] >> x[5] >> x[6] >> x[7] >> x[8];
  35.     assert(x[0] == 0);
  36.     assert(x[1] == -0);
  37.     assert(x[2] == +0);
  38.     assert(x[3] == 010);
  39.     assert(x[4] == -010);
  40.     assert(x[5] == +010);
  41.     assert(x[6] == 0x1);
  42.     assert(x[7] == -0x1);
  43.     assert(x[8] == +0x1);
  44. }
  45.  
  46.