diff options
author | Brad King <brad.king@kitware.com> | 2007-04-19 16:53:13 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2007-04-19 16:53:13 (GMT) |
commit | 6984c0931036abab85c857b588025554006464d9 (patch) | |
tree | 29623b60d60d2d1e80d90750f3a7fbb26fe01f11 /Source/kwsys | |
parent | 94e27c10734db26b1b0a42b283e6457866168435 (diff) | |
download | CMake-6984c0931036abab85c857b588025554006464d9.zip CMake-6984c0931036abab85c857b588025554006464d9.tar.gz CMake-6984c0931036abab85c857b588025554006464d9.tar.bz2 |
ENH: Added testing for istringstream and stringstream.
Diffstat (limited to 'Source/kwsys')
-rw-r--r-- | Source/kwsys/testIOS.cxx | 101 |
1 files changed, 99 insertions, 2 deletions
diff --git a/Source/kwsys/testIOS.cxx b/Source/kwsys/testIOS.cxx index 632b5c2..7c02a1b 100644 --- a/Source/kwsys/testIOS.cxx +++ b/Source/kwsys/testIOS.cxx @@ -6,6 +6,7 @@ // Work-around CMake dependency scanning limitation. This must // duplicate the above list of headers. #if 0 +# include "kwsys_stl_string.hxx.in" # include "kwsys_stl_vector.h.in" # include "kwsys_ios_sstream.h.in" # include "kwsys_ios_iostream.h.in" @@ -14,7 +15,103 @@ int testIOS(int, char*[]) { kwsys_ios::ostringstream ostr; - ostr << "Hello, World!"; - kwsys_ios::cout << ostr.str() << kwsys_ios::endl; + ostr << "hello"; + if(ostr.str() != "hello") + { + kwsys_ios::cerr << "failed to write hello to ostr" << kwsys_ios::endl; + return 1; + } + kwsys_ios::istringstream istr(" 10 20 str "); + kwsys_stl::string s; + int x; + if(istr >> x) + { + if(x != 10) + { + kwsys_ios::cerr << "x != 10" << kwsys_ios::endl; + return 1; + } + } + else + { + kwsys_ios::cerr << "Failed to read 10 from istr" << kwsys_ios::endl; + return 1; + } + if(istr >> x) + { + if(x != 20) + { + kwsys_ios::cerr << "x != 20" << kwsys_ios::endl; + return 1; + } + } + else + { + kwsys_ios::cerr << "Failed to read 20 from istr" << kwsys_ios::endl; + return 1; + } + if(istr >> s) + { + if(s != "str") + { + kwsys_ios::cerr << "s != \"str\"" << kwsys_ios::endl; + return 1; + } + } + else + { + kwsys_ios::cerr << "Failed to read str from istr" << kwsys_ios::endl; + return 1; + } + if(istr >> s) + { + kwsys_ios::cerr << "Able to read past end of stream" << kwsys_ios::endl; + return 1; + } + istr.str("30"); + if(istr >> x) + { + if(x != 30) + { + kwsys_ios::cerr << "x != 30" << kwsys_ios::endl; + return 1; + } + } + else + { + kwsys_ios::cerr << "Failed to read 30 from istr" << kwsys_ios::endl; + return 1; + } + + kwsys_ios::stringstream sstr; + sstr << "40 str2"; + if(sstr >> x) + { + if(x != 40) + { + kwsys_ios::cerr << "x != 40" << kwsys_ios::endl; + return 1; + } + } + else + { + kwsys_ios::cerr << "Failed to read 40 from sstr" << kwsys_ios::endl; + return 1; + } + if(sstr >> s) + { + if(s != "str2") + { + kwsys_ios::cerr << "s != \"str2\"" << kwsys_ios::endl; + return 1; + } + } + else + { + kwsys_ios::cerr << "Failed to read str2 from sstr" << kwsys_ios::endl; + return 1; + } + + kwsys_ios::cout << "IOS tests passed" << kwsys_ios::endl; return 0; } |