From cd4f8c008dcdb2532bc6a5944a1b00a67299ab86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20J=C3=A4rvi?= Date: Fri, 19 Apr 2002 19:44:05 +0000 Subject: [PATCH] addedd var, constant, constant_ref tests, and cout << _1 etc. tests [SVN r13534] --- test/operator_tests_simple.cpp | 45 +++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/test/operator_tests_simple.cpp b/test/operator_tests_simple.cpp index be8a1bc..da1f5c4 100644 --- a/test/operator_tests_simple.cpp +++ b/test/operator_tests_simple.cpp @@ -10,6 +10,13 @@ #include #include +#include + + +#include + +using namespace std; +using namespace boost; using namespace boost::lambda; @@ -17,6 +24,42 @@ using namespace boost::lambda; class unary_plus_tester {}; unary_plus_tester operator+(const unary_plus_tester& a) { return a; } +void cout_tests() +{ + // standard ostream and istream operators work + // stringstreams etc. do not work: + + // ostringstream os; + // os << 1 + + // This should the derived basic_ostream instance (or a reference to it) + // but now the type deduction returns a reference to ostringstream. + // must be fixed. + using std::cout; + ostringstream os; + int i = 10; + ret(os << _1)(i); + + ret(os << constant("FOO"))(); + + BOOST_TEST(os.str() == std::string("10FOO")); + + + // test for constant, constant_ref and var + i = 5; + constant_type::type ci(constant(i)); + var_type::type vi(var(i)); + + (vi = _1)(make_const(100)); + BOOST_TEST((ci)() == 5); + BOOST_TEST(i == 100); + + int a; + constant_ref_type::type cr(constant_ref(i)); + (++vi, var(a) = cr)(); + BOOST_TEST(i == 101); +} + void arithmetic_operators() { int i = 1; int j = 2; int k = 3; @@ -330,7 +373,7 @@ int test_main(int, char *[]) { address_of_and_dereference(); comma(); pointer_arithmetic(); - + cout_tests(); return 0; }