Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r79567 - trunk/libs/proto/test
From: eric_at_[hidden]
Date: 2012-07-16 17:19:51


Author: eric_niebler
Date: 2012-07-16 17:19:50 EDT (Mon, 16 Jul 2012)
New Revision: 79567
URL: http://svn.boost.org/trac/boost/changeset/79567

Log:
tests for proto::protect
Added:
   trunk/libs/proto/test/protect.cpp (contents, props changed)
Text files modified:
   trunk/libs/proto/test/Jamfile.v2 | 1 +
   trunk/libs/proto/test/pack_expansion.cpp | 4 +++-
   2 files changed, 4 insertions(+), 1 deletions(-)

Modified: trunk/libs/proto/test/Jamfile.v2
==============================================================================
--- trunk/libs/proto/test/Jamfile.v2 (original)
+++ trunk/libs/proto/test/Jamfile.v2 2012-07-16 17:19:50 EDT (Mon, 16 Jul 2012)
@@ -38,6 +38,7 @@
         [ run mem_ptr.cpp : : : <toolset>msvc:<cxxflags>/wd4355 ]
         [ run noinvoke.cpp ]
         [ run pack_expansion.cpp ]
+ [ run protect.cpp ]
         [ compile bug2407.cpp ]
     ;
 

Modified: trunk/libs/proto/test/pack_expansion.cpp
==============================================================================
--- trunk/libs/proto/test/pack_expansion.cpp (original)
+++ trunk/libs/proto/test/pack_expansion.cpp 2012-07-16 17:19:50 EDT (Mon, 16 Jul 2012)
@@ -77,7 +77,9 @@
 void test_call_pack()
 {
     proto::terminal<int>::type i = {42};
- int res = eval1()(i + 2);
+ int res = eval1()(i);
+ BOOST_CHECK_EQUAL(res, 42);
+ res = eval1()(i + 2);
     BOOST_CHECK_EQUAL(res, 44);
     res = eval1()(i * 2);
     BOOST_CHECK_EQUAL(res, 84);

Added: trunk/libs/proto/test/protect.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/proto/test/protect.cpp 2012-07-16 17:19:50 EDT (Mon, 16 Jul 2012)
@@ -0,0 +1,69 @@
+///////////////////////////////////////////////////////////////////////////////
+// protect.hpp
+//
+// Copyright 2012 Eric Niebler. 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 <boost/proto/core.hpp>
+#include <boost/proto/transform/make.hpp>
+#include <boost/type_traits/add_pointer.hpp>
+#include <boost/type_traits/remove_pointer.hpp>
+#include <boost/test/unit_test.hpp>
+namespace proto=boost::proto;
+using proto::_;
+
+template<typename T>
+struct identity
+{
+ typedef T type;
+};
+
+struct Test
+ : proto::make< proto::protect<_> >
+{};
+
+struct Test1
+ : proto::make< identity<proto::protect<_> > >
+{};
+
+struct Test2
+ : proto::make< identity<proto::protect<int> > >
+{};
+
+struct Test3
+ : proto::make< identity<proto::protect<identity<_> > > >
+{};
+
+struct Test4
+ : proto::make< identity<proto::protect<identity<int> > > >
+{};
+
+struct Test5
+ : proto::make< identity<proto::protect<identity<identity<int> > > > >
+{};
+
+void test_protect()
+{
+ proto::terminal<int>::type i = {42};
+
+ _ t = Test()(i);
+ _ t1 = Test1()(i);
+ int t2 = Test2()(i);
+ identity<_> t3 = Test3()(i);
+ identity<int> t4 = Test4()(i);
+ identity<identity<int> > t5 = Test5()(i);
+}
+
+using namespace boost::unit_test;
+///////////////////////////////////////////////////////////////////////////////
+// init_unit_test_suite
+//
+test_suite* init_unit_test_suite( int argc, char* argv[] )
+{
+ test_suite *test = BOOST_TEST_SUITE("test proto::protect");
+
+ test->add(BOOST_TEST_CASE(&test_protect));
+
+ return test;
+}


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