Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenmemory_test.cpp
Go to the documentation of this file.
00001 #include <memory> 00002 00003 #include "cppunit/cppunit_proxy.h" 00004 00005 #if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES) 00006 using namespace std; 00007 #endif 00008 00009 // 00010 // TestCase class 00011 // 00012 class MemoryTest : public CPPUNIT_NS::TestCase 00013 { 00014 CPPUNIT_TEST_SUITE(MemoryTest); 00015 #if defined (_STLP_MSVC) && (_STLP_MSVC < 1310) 00016 CPPUNIT_IGNORE; 00017 #endif 00018 CPPUNIT_TEST(auto_ptr_test); 00019 CPPUNIT_TEST_SUITE_END(); 00020 00021 protected: 00022 void auto_ptr_test(); 00023 }; 00024 00025 CPPUNIT_TEST_SUITE_REGISTRATION(MemoryTest); 00026 00027 #if !defined (_STLP_MSVC) || (_STLP_MSVC >= 1310) 00028 auto_ptr<int> CreateAutoPtr(int val) 00029 { return auto_ptr<int>(new int(val)); } 00030 00031 bool CheckEquality(auto_ptr<int> pint, int val) 00032 { return *pint == val; } 00033 #endif 00034 00035 // 00036 // tests implementation 00037 // 00038 void MemoryTest::auto_ptr_test() 00039 { 00040 #if !defined (_STLP_MSVC) || (_STLP_MSVC >= 1310) 00041 { 00042 auto_ptr<int> pint(new int(1)); 00043 CPPUNIT_ASSERT( *pint == 1 ); 00044 *pint = 2; 00045 CPPUNIT_ASSERT( *pint == 2 ); 00046 } 00047 00048 { 00049 auto_ptr<int> pint(CreateAutoPtr(3)); 00050 CPPUNIT_ASSERT( *pint == 3 ); 00051 CPPUNIT_ASSERT( CheckEquality(pint, 3) ); 00052 } 00053 00054 { 00055 auto_ptr<const int> pint(new int(2)); 00056 CPPUNIT_ASSERT( *pint == 2 ); 00057 } 00058 { 00059 auto_ptr<volatile int> pint(new int(2)); 00060 CPPUNIT_ASSERT( *pint == 2 ); 00061 } 00062 { 00063 auto_ptr<const volatile int> pint(new int(2)); 00064 CPPUNIT_ASSERT( *pint == 2 ); 00065 } 00066 #endif 00067 } Generated on Sat May 26 2012 04:34:20 for ReactOS by
1.7.6.1
|