GetBaseObjVoidPtr_UnitTests.cpp

Go to the documentation of this file.
00001 #include "Teuchos_getBaseObjVoidPtr.hpp"
00002 #include "Teuchos_RCP.hpp"
00003 
00004 #include "TestClasses.hpp"
00005 
00006 #include "Teuchos_UnitTestHarness.hpp"
00007 
00008 
00009 namespace Teuchos {
00010 
00011 
00012 TEUCHOS_UNIT_TEST( GetBaseObjVoidPtr, polymorphicClasses )
00013 {
00014   RCP<C> c_ptr(new C);
00015   RCP<B1> b1_ptr = c_ptr;
00016   RCP<B2> b2_ptr = c_ptr;
00017   RCP<A> a_ptr = c_ptr;
00018   TEST_EQUALITY( getBaseObjVoidPtr(&*c_ptr), static_cast<const void*>(&*c_ptr) );
00019   TEST_EQUALITY( getBaseObjVoidPtr(&*b1_ptr), static_cast<const void*>(&*c_ptr) );
00020   TEST_INEQUALITY( static_cast<const void*>(&*b1_ptr), static_cast<const void*>(&*c_ptr) );
00021   TEST_EQUALITY( getBaseObjVoidPtr(&*b2_ptr), static_cast<const void*>(&*c_ptr) );
00022   TEST_INEQUALITY( static_cast<const void*>(&*b2_ptr), static_cast<const void*>(&*c_ptr) );
00023   TEST_EQUALITY( getBaseObjVoidPtr(&*a_ptr), static_cast<const void*>(&*c_ptr) );
00024   TEST_INEQUALITY( static_cast<const void*>(&*a_ptr), static_cast<const void*>(&*c_ptr) );
00025 }
00026 
00027 
00028 TEUCHOS_UNIT_TEST( GetBaseObjVoidPtr, nonPolymorphicClasses )
00029 {
00030   RCP<E> e_ptr(new E);
00031   RCP<D> d_ptr = e_ptr;
00032   TEST_EQUALITY( getBaseObjVoidPtr(&*e_ptr), static_cast<const void*>(&*e_ptr) );
00033   TEST_EQUALITY( getBaseObjVoidPtr(&*d_ptr), static_cast<const void*>(&*e_ptr) );
00034 }
00035 
00036 
00037 TEUCHOS_UNIT_TEST( GetBaseObjVoidPtr, nonPolymorphicBuiltInTypes )
00038 {
00039   RCP<int> i_ptr(new int);
00040   TEST_EQUALITY( getBaseObjVoidPtr(&*i_ptr), static_cast<const void*>(&*i_ptr) );
00041 }
00042 
00043 
00044 } // namespace Teuchos namespace
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Wed Apr 13 09:57:28 2011 for Teuchos Package Browser (Single Doxygen Collection) by  doxygen 1.6.3