Boost logo

Boost-Commit :

From: fernando.cacciola_at_[hidden]
Date: 2007-11-02 19:41:37


Author: fcacciola
Date: 2007-11-02 19:41:37 EDT (Fri, 02 Nov 2007)
New Revision: 40707
URL: http://svn.boost.org/trac/boost/changeset/40707

Log:
Added test to ensure proper binding of optional references (in reference to Ticket 1301)
Text files modified:
   trunk/libs/optional/test/optional_test_ref.cpp | 18 ++++++++++++++++++
   1 files changed, 18 insertions(+), 0 deletions(-)

Modified: trunk/libs/optional/test/optional_test_ref.cpp
==============================================================================
--- trunk/libs/optional/test/optional_test_ref.cpp (original)
+++ trunk/libs/optional/test/optional_test_ref.cpp 2007-11-02 19:41:37 EDT (Fri, 02 Nov 2007)
@@ -337,12 +337,30 @@
   BOOST_CHECK ( X::count == 0 ) ;
 }
 
+void test_binding()
+{
+ int i = 0 ;
+ optional<int&> ori1 = i ;
+ BOOST_CHECK( &(*ori1) == &i ) ;
+
+ optional<int&> ori2(i) ;
+ BOOST_CHECK( &(*ori2) == &i ) ;
+
+ int const ci = 0 ;
+ optional<int const&> orci1 = ci ;
+ BOOST_CHECK( &(*orci1) == &ci ) ;
+
+ optional<int const&> orci2 = ci ;
+ BOOST_CHECK( &(*orci2) == &ci ) ;
+}
+
 int test_main( int, char* [] )
 {
   try
   {
     test_with_class_type();
     test_with_builtin_types();
+ test_binding();
   }
   catch ( ... )
   {


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