OpenWalnut
1.2.5
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
src
core
common
test
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
*/
37
class
SomePrototypeClass1
:
public
WPrototyped
38
{
39
public
:
40
41
/**
42
* Gets the name of this prototype.
43
*
44
* \return the name.
45
*/
46
virtual
const
std::string
getName
()
const
47
{
48
return
"test1"
;
49
};
50
51
/**
52
* Gets the description for this prototype.
53
*
54
* \return the description
55
*/
56
virtual
const
std::string
getDescription
()
const
57
{
58
return
"test1"
;
59
};
60
};
61
62
63
/**
64
* Another helper class derived from WPrototyped. Used to check against \ref SomePrototypeClass1.
65
*/
66
class
SomePrototypeClass2
:
public
WPrototyped
67
{
68
public
:
69
70
/**
71
* Gets the name of this prototype.
72
*
73
* \return the name.
74
*/
75
virtual
const
std::string
getName
()
const
76
{
77
return
"test2"
;
78
};
79
80
/**
81
* Gets the description for this prototype.
82
*
83
* \return the description
84
*/
85
virtual
const
std::string
getDescription
()
const
86
{
87
return
"test2"
;
88
};
89
};
90
91
/**
92
* Test WPrototyped
93
*/
94
class
WPrototypedTest
:
public
CxxTest::TestSuite
95
{
96
public
:
97
98
/**
99
* Test the runtime type check
100
*/
101
void
testType
(
void
)
102
{
103
SomePrototypeClass1
a;
104
SomePrototypeClass2
b;
105
106
// check the type checking mechanism in WPrototyped
107
108
// these should be true
109
TS_ASSERT( a.
isA
<
WPrototyped
>() );
110
TS_ASSERT( a.
isA
<
SomePrototypeClass1
>() );
111
112
TS_ASSERT( b.
isA
<
WPrototyped
>() );
113
TS_ASSERT( b.
isA
<
SomePrototypeClass2
>() );
114
115
// check against other types not in polymorphic relation to each other (except the base class)
116
TS_ASSERT( !a.
isA
<
SomePrototypeClass2
>() );
117
TS_ASSERT( !b.
isA
<
SomePrototypeClass1
>() );
118
}
119
};
120
121
#endif // WPROTOTYPED_TEST_H
122
123
Generated by
1.8.1