OpenWalnut
1.2.5
|
00001 //--------------------------------------------------------------------------- 00002 // 00003 // Project: OpenWalnut ( http://www.openwalnut.org ) 00004 // 00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS 00006 // For more information see http://www.openwalnut.org/copying 00007 // 00008 // This file is part of OpenWalnut. 00009 // 00010 // OpenWalnut is free software: you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as published by 00012 // the Free Software Foundation, either version 3 of the License, or 00013 // (at your option) any later version. 00014 // 00015 // OpenWalnut is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public License 00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>. 00022 // 00023 //--------------------------------------------------------------------------- 00024 00025 #ifndef WPROTOTYPED_TEST_H 00026 #define WPROTOTYPED_TEST_H 00027 00028 #include <string> 00029 00030 #include <cxxtest/TestSuite.h> 00031 00032 #include "../WPrototyped.h" 00033 00034 /** 00035 * Helper class derived from WPrototyped to check WPrototypes functionality. 00036 */ 00037 class SomePrototypeClass1: public WPrototyped 00038 { 00039 public: 00040 00041 /** 00042 * Gets the name of this prototype. 00043 * 00044 * \return the name. 00045 */ 00046 virtual const std::string getName() const 00047 { 00048 return "test1"; 00049 }; 00050 00051 /** 00052 * Gets the description for this prototype. 00053 * 00054 * \return the description 00055 */ 00056 virtual const std::string getDescription() const 00057 { 00058 return "test1"; 00059 }; 00060 }; 00061 00062 00063 /** 00064 * Another helper class derived from WPrototyped. Used to check against \ref SomePrototypeClass1. 00065 */ 00066 class SomePrototypeClass2: public WPrototyped 00067 { 00068 public: 00069 00070 /** 00071 * Gets the name of this prototype. 00072 * 00073 * \return the name. 00074 */ 00075 virtual const std::string getName() const 00076 { 00077 return "test2"; 00078 }; 00079 00080 /** 00081 * Gets the description for this prototype. 00082 * 00083 * \return the description 00084 */ 00085 virtual const std::string getDescription() const 00086 { 00087 return "test2"; 00088 }; 00089 }; 00090 00091 /** 00092 * Test WPrototyped 00093 */ 00094 class WPrototypedTest : public CxxTest::TestSuite 00095 { 00096 public: 00097 00098 /** 00099 * Test the runtime type check 00100 */ 00101 void testType( void ) 00102 { 00103 SomePrototypeClass1 a; 00104 SomePrototypeClass2 b; 00105 00106 // check the type checking mechanism in WPrototyped 00107 00108 // these should be true 00109 TS_ASSERT( a.isA< WPrototyped >() ); 00110 TS_ASSERT( a.isA< SomePrototypeClass1 >() ); 00111 00112 TS_ASSERT( b.isA< WPrototyped >() ); 00113 TS_ASSERT( b.isA< SomePrototypeClass2 >() ); 00114 00115 // check against other types not in polymorphic relation to each other (except the base class) 00116 TS_ASSERT( !a.isA< SomePrototypeClass2 >() ); 00117 TS_ASSERT( !b.isA< SomePrototypeClass1 >() ); 00118 } 00119 }; 00120 00121 #endif // WPROTOTYPED_TEST_H 00122 00123