ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

reference_wrapper_test.cpp
Go to the documentation of this file.
00001 #include <functional>
00002 
00003 #if !defined(_STLP_NO_EXTENSIONS) && defined(_STLP_USE_BOOST_SUPPORT)
00004 
00005 #include <typeinfo>
00006 #include "cppunit/cppunit_proxy.h"
00007 
00008 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
00009 using namespace std;
00010 #endif
00011 
00012 class RefWrapperTest :
00013     public CPPUNIT_NS::TestCase
00014 {
00015     CPPUNIT_TEST_SUITE(RefWrapperTest);
00016     CPPUNIT_TEST(ref);
00017     CPPUNIT_TEST(cref);
00018     CPPUNIT_TEST_SUITE_END();
00019 
00020   protected:
00021     void ref();
00022     void cref();
00023 };
00024 
00025 CPPUNIT_TEST_SUITE_REGISTRATION(RefWrapperTest);
00026 
00027 void RefWrapperTest::ref()
00028 {
00029   typedef std::tr1::reference_wrapper<int> rr_type;
00030 
00031   CPPUNIT_CHECK( (::boost::is_convertible<rr_type, int&>::value) );
00032   CPPUNIT_CHECK( (::boost::is_same<rr_type::type, int>::value) );
00033 
00034   int i = 1;
00035   int j = 2;
00036 
00037   rr_type r1 = std::tr1::ref(i);
00038 
00039   CPPUNIT_CHECK( r1.get() == 1 );
00040 
00041   r1 = std::tr1::ref(j);
00042 
00043   CPPUNIT_CHECK( r1.get() == 2 );
00044 
00045   i = 3;
00046 
00047   CPPUNIT_CHECK( r1.get() == 2 );
00048 
00049   j = 4;
00050 
00051   CPPUNIT_CHECK( r1.get() == 4 );
00052 
00053   r1.get() = 5;
00054 
00055   CPPUNIT_CHECK( j == 5 );
00056 }
00057 
00058 void RefWrapperTest::cref()
00059 {
00060   typedef std::tr1::reference_wrapper<const int> crr_type;
00061 
00062   CPPUNIT_CHECK( (::boost::is_convertible<crr_type, const int&>::value) );
00063   CPPUNIT_CHECK( (::boost::is_same<crr_type::type, const int>::value) );
00064 
00065   int i = 1;
00066   int j = 2;
00067 
00068   crr_type r1 = std::tr1::cref(i);
00069 
00070   CPPUNIT_CHECK( r1.get() == 1 );
00071 
00072   r1 = std::tr1::cref(j);
00073 
00074   CPPUNIT_CHECK( r1.get() == 2 );
00075 
00076   i = 3;
00077 
00078   CPPUNIT_CHECK( r1.get() == 2 );
00079 
00080   j = 4;
00081 
00082   CPPUNIT_CHECK( r1.get() == 4 );
00083 }
00084 
00085 #endif /* !_STLP_NO_EXTENSIONS && _STLP_USE_BOOST_SUPPORT */

Generated on Sun May 27 2012 04:35:44 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.