Imported Upstream version 1.51.0
[platform/upstream/boost.git] / libs / spirit / phoenix / test / operator / io_tests.cpp
1 /*=============================================================================
2     Copyright (c) 2001-2007 Joel de Guzman
3
4     Distributed under the Boost Software License, Version 1.0. (See accompanying 
5     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
7 #include <iostream>
8 #include <vector>
9 #include <algorithm>
10 #include <sstream>
11 #include <string>
12 #include <algorithm>
13
14 #include <boost/detail/lightweight_test.hpp>
15 #include <boost/spirit/include/phoenix_core.hpp>
16 #include <boost/spirit/include/phoenix_operator.hpp>
17
18 #include <boost/fusion/include/io.hpp>
19
20 using namespace boost::phoenix;
21 using namespace boost::phoenix::arg_names;
22 using namespace std;
23
24 int
25 main()
26 {
27     int     i100 = 100;
28     string hello = "hello";
29     const char* world = " world";
30
31     int init[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
32     vector<int> v(init, init+10);
33
34     char const* msg = "cout assert\n";
35     (cout << arg1)(msg);
36     (cout << arg1 << endl)(hello);
37     (arg1 << hex)(cout);
38     (cout << val(hello))();
39
40     (cout << val(hello) << world << ", you da man!\n")();
41     for_each(v.begin(), v.end(), cout << arg1 << ',');
42     (cout << arg1 + 1)(i100);
43
44     (cout << arg1 << "this is it, shukz:" << hex << arg2 << endl << endl)(msg, i100);
45
46     int in;
47     int out = 12345;
48     stringstream sstr;
49     (sstr << arg1)(out);
50     (sstr >> arg1)(in);
51     BOOST_TEST(in == out);
52
53     return boost::report_errors();
54 }