Update of /cvsroot/cppunit/cppunit2/src/cpputtest
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8769/src/cpputtest
Modified Files:
reflectiontest.cpp
Log Message:
* added support for reflection of method with return value
Index: reflectiontest.cpp
===================================================================
RCS file: /cvsroot/cppunit/cppunit2/src/cpputtest/reflectiontest.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** reflectiontest.cpp 5 Mar 2005 09:41:00 -0000 1.3
--- reflectiontest.cpp 5 Mar 2005 10:15:12 -0000 1.4
***************
*** 13,16 ****
--- 13,18 ----
CPPTL_REFLECT_METHOD( multiplyAndAdd )
CPPTL_REFLECT_METHOD( checkTotal )
+ CPPTL_REFLECT_METHOD_WITH_RETURN( isInitialized )
+ CPPTL_REFLECT_METHOD_WITH_RETURN( getTotal )
CPPTL_REFLECT_ATTRIBUT( initialized_ )
CPPTL_REFLECT_RENAMED_ATTRIBUT( total_, "total" )
***************
*** 43,46 ****
--- 45,58 ----
}
+ bool isInitialized() const
+ {
+ return initialized_;
+ }
+
+ int getTotal()
+ {
+ return total_;
+ }
+
bool initialized_;
int total_;
***************
*** 112,115 ****
--- 124,139 ----
CPPUT_ASSERT_EQUAL( 7 + 2*6, sampleTarget.total_ );
+ const CppTL::Method *getTotalMethod = class_->findMethod( "getTotal" );
+ CPPUT_ASSERT( getTotalMethod != 0, "Method 'getTotal' not found by reflection." );
+ CppTL::MethodParameters argsGetTotal;
+ CPPUT_ASSERT_EQUAL( 7 + 2*6, any_cast( getTotalMethod->invoke( target, argsGetTotal ),
+ CppTL::Type<int>() ) );
+
+ const CppTL::Method *isInitializedMethod = class_->findMethod( "isInitialized" );
+ CPPUT_ASSERT( isInitializedMethod != 0, "Method 'isInitialized' not found by reflection." );
+ CppTL::MethodParameters argsIsInitialized;
+ CPPUT_ASSERT_EQUAL( true, any_cast( isInitializedMethod->invoke( target, argsIsInitialized ),
+ CppTL::Type<bool>() ) );
+
const CppTL::Attribut *initializedAttribut = class_->findAttribut( "initialized_" );
CPPUT_ASSERT( initializedAttribut != 0, "Attribut 'initialized_' not found by reflection." );
|