summaryrefslogtreecommitdiffstats
path: root/Source/kwsys/testIOS.cxx
blob: fdf7cd0f9a88b8c9b38195edf2a9f5d29599a0ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "kwsysPrivate.h"
#include KWSYS_HEADER(stl/vector)
#include KWSYS_HEADER(ios/sstream)
#include KWSYS_HEADER(ios/iostream)

// Work-around CMake dependency scanning limitation.  This must
// duplicate the above list of headers.
#if 0
# include "kwsys_stl_vector.h.in"
# include "kwsys_ios_sstream.h.in"
# include "kwsys_ios_iostream.h.in"
#endif

int main()
{
  const char refstring[] =  "Hello, World!";
  kwsys_ios::ostringstream ostr;
  ostr << refstring;
  kwsys_ios::cout << ostr.str() << kwsys_ios::endl;
  if( ostr.str() != refstring )
    {
    return 1;
    }


  kwsys_ios::istringstream istr;
  istr.str( refstring );
  kwsys_ios::cout << istr.str() << kwsys_ios::endl;
  if( istr.str() != refstring )
    {
    return 1;
    }


  const int val = 12345;
  const char valstr[] = "12345";
  kwsys_ios::stringstream sstr;
  sstr << val;
  int v = 0;
  sstr >> v;
  kwsys_ios::cout << sstr.str() << kwsys_ios::endl;
  if( /*v != val ||*/ sstr.str() != valstr)
    {
    kwsys_ios::cerr << v << " should be " << val << kwsys_ios::endl;
    return 1;
    }

  return 0;
}