2
0
mirror of https://github.com/boostorg/phoenix.git synced 2026-02-14 13:02:10 +00:00
Files
phoenix/test/core/primitives_tests.cpp
Thomas Heller 398579a251 + implemented PP file iterations with predefined macros for typenames etc.
+ added full support for member operator
+ added full support for std::iostream operator
+ implemented perfect forwarding for actor
+ adapted some test cases for "best-practice"
+ implemented variadic arguments for all actors based on phoenix/core/limits.h
+ added proper boost build handling
+ arity calculation tweak from Eric



[SVN r63027]
2010-06-16 21:43:16 +00:00

70 lines
1.8 KiB
C++

/*=============================================================================
Copyright (c) 2001-2007 Joel de Guzman
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
==============================================================================*/
#include <iostream>
#include <string>
#include <boost/phoenix/core.hpp>
#include <boost/detail/lightweight_test.hpp>
using namespace boost::phoenix;
using namespace boost::phoenix::arg_names;
using namespace std;
int
main()
{
char c1 = '1';
int i1 = 1, i2 = 2, i = 4;
const char* s2 = "2";
///////////////////////////////////////////////////////////////////////////
//
// Values, references and arguments
//
///////////////////////////////////////////////////////////////////////////
// argument
BOOST_TEST(arg1(c1) == c1);
BOOST_TEST(arg1(i1, i2) == i1);
BOOST_TEST(arg2(i1, s2) == s2);
BOOST_TEST(&(arg1(c1)) == &c1); // must be an lvalue
// value
//cout << val("Hello,")(0) << val(' ')(0) << val("World")(0) << endl;
BOOST_TEST(val(3)() == 3);
//BOOST_TEST(val("Hello, world")(0) == std::string("Hello, world"));
//BOOST_TEST(val(_1)(i1) == i1);
// should not compile:
#ifdef PHOENIX_SHOULD_NOT_COMPILE_TEST
&val(_1)(i1); // should return an rvalue
#endif
// reference
BOOST_TEST(cref(i)() == ref(i)());
BOOST_TEST(cref(i)() == 4);
BOOST_TEST(i == 4);
BOOST_TEST(ref(++i)() == 5);
BOOST_TEST(i == 5);
// should not compile:
#ifdef PHOENIX_SHOULD_NOT_COMPILE_TEST
ref(arg1);
#endif
// testing consts
int const ic = 123;
BOOST_TEST(arg1(ic) == 123);
// should not compile:
#ifdef PHOENIX_SHOULD_NOT_COMPILE_TEST
arg1();
#endif
return boost::report_errors();
}