OpenWalnut
1.3.1
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
src
core
dataHandler
test
WValueSetBase_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 WVALUESETBASE_TEST_H
26
#define WVALUESETBASE_TEST_H
27
28
#include <cxxtest/TestSuite.h>
29
30
#include "../WValueSetBase.h"
31
#include "../WDataHandlerEnums.h"
32
33
/**
34
* Dummy class for testing the abstract class WValueSetBase
35
*/
36
class
Dummy
:
public
WValueSetBase
37
{
38
friend
class
WValueSetBaseTest
;
39
40
public
:
41
/**
42
* Standard constructor of Dummy class.
43
*/
44
Dummy
()
45
:
WValueSetBase
( 0, 1, W_DT_INT8 )
46
{
47
}
48
49
/**
50
* Constructor of Dummy class for testing
51
* \param dimension tensor dimension
52
*/
53
explicit
Dummy
(
char
dimension
)
54
:
WValueSetBase
( 0, dimension, W_DT_INT8 )
55
{
56
}
57
58
/**
59
* Destructor.
60
*/
61
virtual
~Dummy
()
62
{
63
}
64
65
/**
66
* Get the size.
67
*
68
* \return The size.
69
*/
70
virtual
size_t
size
()
const
71
{
72
return
255;
73
}
74
75
/**
76
* Get the raw size.
77
*
78
* \return The raw size.
79
*/
80
virtual
size_t
rawSize
()
const
81
{
82
return
255;
83
}
84
85
/**
86
* Get the value.
87
*
88
* \return The value at position i.
89
*/
90
virtual
double
getScalarDouble
(
size_t
/* i */
)
const
91
{
92
return
255;
93
}
94
95
/**
96
* \return The i-th WValue stored in this value set. There are size() such scalars.
97
*/
98
virtual
WValue< double >
getWValueDouble
(
size_t
/*i*/
)
const
99
{
100
return
WValue< double >
(
size
() );
101
}
102
103
/**
104
* \return The i-th WValue (stored in this value set) as WVector_2. There are size() such scalars.
105
*/
106
virtual
WVector_2
getWVector
(
size_t
/*i*/
)
const
107
{
108
return
WVector_2(
size
() );
109
}
110
111
/**
112
* This method returns the smallest value in the valueset. It does not handle vectors, matrices and so on well. It simply returns the
113
* smallest value in the data array. This is especially useful for texture scaling or other statistic tools (histograms).
114
*
115
* \return the smallest value in the data.
116
*/
117
virtual
double
getMinimumValue
()
const
118
{
119
return
0.0;
120
}
121
122
/**
123
* This method returns the largest value in the valueset. It does not handle vectors, matrices and so on well. It simply returns the
124
* largest value in the data array. This is especially useful for texture scaling or other statistic tools (histograms).
125
*
126
* \return the largest value in the data.
127
*/
128
virtual
double
getMaximumValue
()
const
129
{
130
return
255.0;
131
}
132
};
133
134
/**
135
* Testing abstract class via a Dummy class derived esp. for this purpose.
136
*/
137
class
WValueSetBaseTest
:
public
CxxTest::TestSuite
138
{
139
public
:
140
/**
141
* Checks if the Dummy is instanceable.
142
*/
143
void
testInstantiation
(
void
)
144
{
145
Dummy
d;
146
}
147
148
/**
149
* Checks if the dimension using the dummy is right
150
*/
151
void
testDimension
(
void
)
152
{
153
Dummy
d1;
154
TS_ASSERT_EQUALS( d1.
dimension
(), 1 );
155
Dummy
d2( 2 );
156
TS_ASSERT_EQUALS( d2.dimension(), 2 );
157
}
158
/**
159
* Checks if the dimension using the dummy is right
160
*/
161
void
testDataType
(
void
)
162
{
163
Dummy
d1;
164
TS_ASSERT_EQUALS( d1.
getDataType
(), W_DT_INT8 );
165
}
166
};
167
168
#endif // WVALUESETBASE_TEST_H
Generated by
1.8.4