Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r69784 - sandbox/assign_v2/libs/assign/v2/test/put/pipe
From: erwann.rogard_at_[hidden]
Date: 2011-03-09 16:08:11


Author: e_r
Date: 2011-03-09 16:08:09 EST (Wed, 09 Mar 2011)
New Revision: 69784
URL: http://svn.boost.org/trac/boost/changeset/69784

Log:
upd assign_v2
Added:
   sandbox/assign_v2/libs/assign/v2/test/put/pipe/put.cpp (contents, props changed)
   sandbox/assign_v2/libs/assign/v2/test/put/pipe/put.h (contents, props changed)
   sandbox/assign_v2/libs/assign/v2/test/put/pipe/put_range.cpp (contents, props changed)
   sandbox/assign_v2/libs/assign/v2/test/put/pipe/put_range.h (contents, props changed)

Added: sandbox/assign_v2/libs/assign/v2/test/put/pipe/put.cpp
==============================================================================
--- (empty file)
+++ sandbox/assign_v2/libs/assign/v2/test/put/pipe/put.cpp 2011-03-09 16:08:09 EST (Wed, 09 Mar 2011)
@@ -0,0 +1,118 @@
+//////////////////////////////////////////////////////////////////////////////
+// Boost.Assign v2 //
+// //
+// Copyright (C) 2003-2004 Thorsten Ottosen //
+// Copyright (C) 2010 Erwann Rogard //
+// Use, modification and distribution are subject to 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 <map>
+#include <deque>
+#include <vector>
+#include <list>
+#include <string>
+#include <boost/array.hpp>
+#include <boost/tuple/tuple.hpp>
+#include <boost/numeric/conversion/bounds.hpp>
+#include <boost/assign/v2/detail/config/check.hpp>
+#include <boost/assign/v2/put/pipe/put.hpp>
+#include <boost/assign/v2/put/pipe/csv_put.hpp>
+
+#include <libs/assign/v2/test/put/pipe/put.h>
+
+namespace test_assign_v2{
+namespace xxx_put{
+namespace xxx_pipe{
+namespace xxx_put{
+
+ void test(){
+ namespace as2 = boost::assign::v2;
+ {
+ //pipe_str_literal
+ typedef const char* T;
+ std::deque<T> cont; typedef std::string str_;
+ BOOST_ASSIGN_V2_CHECK( str_(
+ ( cont | as2::_put( "x" )( "y" )( "z" ) )[0]
+ ) == "x" );
+ BOOST_ASSIGN_V2_CHECK( str_( cont[1] ) == "y" );
+ BOOST_ASSIGN_V2_CHECK( str_( cont[2] ) == "z" );
+ }
+ {
+ //[pipe_array
+ const int sz = 3;
+ typedef boost::array<int, sz> r_;
+ boost::array<r_, sz> matrix3x3;
+
+ {
+ r_ r0, r1, r2;
+ int front = ( /*Calls [^r0[i] = j] for [^( i, j ) = ( 0, 1 ), ( 1, 2 ), ( 2, 3 ) ] and returns r0*/ r0 | as2::_put( 1 )( 2 )( 3 ) ).front();
+ int back = r0.back();
+ r2 | as2::_put( 7 )( 8 )( 9 );
+ r_ r = (
+ matrix3x3 | as2::_put
+ ( r0 )
+ ( /*<<`r1` modified on the fly>>*/r1 | as2::_put( 4 )( 5 )( 6 ) )
+ ( r2 )
+ )[1];
+
+ BOOST_ASSIGN_V2_CHECK( front == 1 );
+ BOOST_ASSIGN_V2_CHECK( back == 3 );
+ BOOST_ASSIGN_V2_CHECK( r == r1 );
+ }
+ for(int i = 0; i < 9; i++)
+ {
+ BOOST_ASSIGN_V2_CHECK( matrix3x3[ i / 3 ][ i % 3 ] == i + 1 );
+ }
+ //]
+ }
+ {
+ //[pipe_seq_var_args
+ typedef double elem_; typedef std::list<elem_> r_; typedef std::vector<r_> ragged_array_;
+ r_ a, b; elem_ front, back;
+ front = ( a | as2::_put( 0.71 )( 0.63 )( 0.85 ) ).front();
+ back = a.back();
+
+ ragged_array_ ragged_array;
+ r_ r = (
+ ragged_array | as2::_put
+ ( a )
+ ( /*<<`b` modified on the fly>>*/ b | as2::_put( 0.61 )( 0.69 )( 0.92 )( 0.55 ) )
+ ( 1, -99.99 )
+ ( )
+ )[2];
+
+ elem_ eps = boost::numeric::bounds<elem_>::smallest();
+ BOOST_ASSIGN_V2_CHECK( abs( front - 0.71 ) < eps );
+ BOOST_ASSIGN_V2_CHECK( abs( back - 0.85 ) < eps );
+ BOOST_ASSIGN_V2_CHECK( abs( r.front() + 99.0 ) < eps );
+ BOOST_ASSIGN_V2_CHECK( abs( r.back() + 99.0 ) < eps );
+ //]
+ BOOST_ASSIGN_V2_CHECK( ragged_array[0].size() == a.size() );
+ BOOST_ASSIGN_V2_CHECK( ragged_array[1].size() == b.size() );
+ BOOST_ASSIGN_V2_CHECK( ragged_array[2].size() == 1 );
+ BOOST_ASSIGN_V2_CHECK( ragged_array[3].size() == 0 );
+ }
+ {
+ using namespace boost;
+ //[pipe_seq_ref_tuple
+ typedef const char state_ [3]; state_ ct = "CT", nj = "NJ", ny = "NY";
+ typedef int code_; typedef boost::tuple<state_/*<<Notice the reference>>*/&, code_> area_code_;
+ std::deque< area_code_ > tri_state;
+ area_code_ front = (
+ tri_state | as2::_put( nj, 201 )( ct, 203 )( ny, 212 )( ny, 315 )( ny, 347 )( nj, 551 )
+ ).front();
+
+ BOOST_ASSIGN_V2_CHECK( get<0>( front ) == nj );
+ BOOST_ASSIGN_V2_CHECK( get<1>( front ) == 201 );
+ BOOST_ASSIGN_V2_CHECK( get<0>( tri_state.back() ) == nj );
+ BOOST_ASSIGN_V2_CHECK( get<1>( tri_state.back() ) == 551 );
+ //]
+ }
+
+ }// test()
+
+}// xxx_put
+}// xxx_pipe
+}// xxx_put
+}// xxx_test_assign
\ No newline at end of file

Added: sandbox/assign_v2/libs/assign/v2/test/put/pipe/put.h
==============================================================================
--- (empty file)
+++ sandbox/assign_v2/libs/assign/v2/test/put/pipe/put.h 2011-03-09 16:08:09 EST (Wed, 09 Mar 2011)
@@ -0,0 +1,25 @@
+//////////////////////////////////////////////////////////////////////////////
+// Boost.Assign v2 //
+// //
+// Copyright (C) 2003-2004 Thorsten Ottosen //
+// Copyright (C) 2010 Erwann Rogard //
+// Use, modification and distribution are subject to 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) //
+//////////////////////////////////////////////////////////////////////////////
+#ifndef LIBS_ASSIGN_V2_TEST_PUT_PIPE_PUT_ER_2010_H
+#define LIBS_ASSIGN_V2_TEST_PUT_PIPE_PUT_ER_2010_H
+
+namespace test_assign_v2{
+namespace xxx_put{
+namespace xxx_pipe{
+namespace xxx_put{
+
+ void test();
+
+}// xxx_put
+}// xxx_pipe
+}// xxx_put
+}// test_assign_v2
+
+#endif

Added: sandbox/assign_v2/libs/assign/v2/test/put/pipe/put_range.cpp
==============================================================================
--- (empty file)
+++ sandbox/assign_v2/libs/assign/v2/test/put/pipe/put_range.cpp 2011-03-09 16:08:09 EST (Wed, 09 Mar 2011)
@@ -0,0 +1,62 @@
+////////////////////////////////////////////////////////////////////////////
+// Boost.Assign v2 //
+// //
+// Copyright (C) 2003-2004 Thorsten Ottosen //
+// Copyright (C) 2010 Erwann Rogard //
+// Use, modification and distribution are subject to 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 <stack>
+#include <vector>
+#include <deque>
+#include <boost/array.hpp>
+#include <boost/tuple/tuple.hpp>
+#include <boost/assign/v2/detail/config/check.hpp>
+#include <boost/assign/v2/put/pipe/range.hpp>
+#include <boost/assign/v2/put/container/put.hpp>
+#include <libs/assign/v2/test/put/pipe/put_range.h>
+
+namespace test_assign_v2{
+namespace xxx_put{
+namespace xxx_pipe{
+namespace xxx_put_range{
+
+ void test()
+ {
+ namespace as2 = boost::assign::v2;
+
+
+ {
+ //[pipe_range_assign
+ typedef const char state_ [3]; state_ ct = "CT", nj = "NJ", ny = "NY", ca = "CA", /* ore = "OR",*/ wa = "WA";
+ typedef int code_; typedef boost::tuple<state_/*<<Notice the reference>>*/&, code_> area_code_;
+ std::deque< area_code_ > tri_state; as2::put( tri_state )( nj, 201 )( ct, 203 )( ny, 212 )( ny, 315 )( ny, 347 )( nj, 551 );
+ std::deque< area_code_ > pacific ; as2::put( pacific )( wa, 206 )( ca, 209 )( ca, 213 )( wa, 253 );
+
+ std::deque< area_code_ > states; states | as2::_put_range( tri_state ) | as2::_put_range( pacific );
+
+ using namespace boost;
+ BOOST_ASSIGN_V2_CHECK( get<0>( states.front() ) == nj );
+ BOOST_ASSIGN_V2_CHECK( get<1>( states.front() ) == 201 );
+ BOOST_ASSIGN_V2_CHECK( get<0>( states[tri_state.size()-1] ) == nj );
+ BOOST_ASSIGN_V2_CHECK( get<1>( states[tri_state.size()-1] ) == 551 );
+ BOOST_ASSIGN_V2_CHECK( get<0>( states[tri_state.size()] ) == wa );
+ BOOST_ASSIGN_V2_CHECK( get<1>( states[tri_state.size()] ) == 206 );
+ BOOST_ASSIGN_V2_CHECK( get<0>( states.back() ) == wa );
+ BOOST_ASSIGN_V2_CHECK( get<1>( states.back() ) == 253 );
+ //]
+ }
+ {
+ //[pipe_range_constr
+ std::vector<int> r( 3 ); r[0] = 72; r[1] = 31; r[2] = 48;
+
+ BOOST_ASSIGN_V2_CHECK( ( ::boost::type< std::stack<int> >() | as2::_put_range( r ) ).top() == 48 );
+ //]
+ }
+ }
+
+}// xxx_put_range
+}// xxx_pipe
+}// xxx_put
+}// test_assign_v2

Added: sandbox/assign_v2/libs/assign/v2/test/put/pipe/put_range.h
==============================================================================
--- (empty file)
+++ sandbox/assign_v2/libs/assign/v2/test/put/pipe/put_range.h 2011-03-09 16:08:09 EST (Wed, 09 Mar 2011)
@@ -0,0 +1,25 @@
+//////////////////////////////////////////////////////////////////////////////
+// Boost.Assign v2 //
+// //
+// Copyright (C) 2003-2004 Thorsten Ottosen //
+// Copyright (C) 2010 Erwann Rogard //
+// Use, modification and distribution are subject to 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) //
+//////////////////////////////////////////////////////////////////////////////
+#ifndef LIBS_ASSIGN_V2_TEST_PUT_PIPE_PUT_RANGE_ER_2010_H
+#define LIBS_ASSIGN_V2_TEST_PUT_PIPE_PUT_RANGE_ER_2010_H
+
+namespace test_assign_v2{
+namespace xxx_put{
+namespace xxx_pipe{
+namespace xxx_put_range{
+
+ void test();
+
+}// xxx_put_range
+}// xxx_pipe
+}// xxx_put
+}// test_assign_v2
+
+#endif


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk