OpenWalnut  1.3.1
WPrototyped_test.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WPROTOTYPED_TEST_H
26 #define WPROTOTYPED_TEST_H
27 
28 #include <string>
29 
30 #include <cxxtest/TestSuite.h>
31 
32 #include "../WPrototyped.h"
33 
34 /**
35  * Helper class derived from WPrototyped to check WPrototypes functionality.
36  */
38 {
39 public:
40  /**
41  * Gets the name of this prototype.
42  *
43  * \return the name.
44  */
45  virtual const std::string getName() const
46  {
47  return "test1";
48  };
49 
50  /**
51  * Gets the description for this prototype.
52  *
53  * \return the description
54  */
55  virtual const std::string getDescription() const
56  {
57  return "test1";
58  };
59 };
60 
61 
62 /**
63  * Another helper class derived from WPrototyped. Used to check against \ref SomePrototypeClass1.
64  */
66 {
67 public:
68  /**
69  * Gets the name of this prototype.
70  *
71  * \return the name.
72  */
73  virtual const std::string getName() const
74  {
75  return "test2";
76  };
77 
78  /**
79  * Gets the description for this prototype.
80  *
81  * \return the description
82  */
83  virtual const std::string getDescription() const
84  {
85  return "test2";
86  };
87 };
88 
89 /**
90  * Test WPrototyped
91  */
92 class WPrototypedTest : public CxxTest::TestSuite
93 {
94 public:
95  /**
96  * Test the runtime type check
97  */
98  void testType( void )
99  {
102 
103  // check the type checking mechanism in WPrototyped
104 
105  // these should be true
106  TS_ASSERT( a.isA< WPrototyped >() );
107  TS_ASSERT( a.isA< SomePrototypeClass1 >() );
108 
109  TS_ASSERT( b.isA< WPrototyped >() );
110  TS_ASSERT( b.isA< SomePrototypeClass2 >() );
111 
112  // check against other types not in polymorphic relation to each other (except the base class)
113  TS_ASSERT( !a.isA< SomePrototypeClass2 >() );
114  TS_ASSERT( !b.isA< SomePrototypeClass1 >() );
115  }
116 };
117 
118 #endif // WPROTOTYPED_TEST_H
119 
120