18 #include <cxxtest/TestSuite.h>
35 const double tempsInC[] = { -273.15, 0, 100, 374};
39 TS_ASSERT_DELTA( *( (
double* )bv.
getBytes() + 0 ), -459.67, 0.01 );
40 TS_ASSERT_DELTA( *( (
double* )bv.
getBytes() + 1 ), 32.0, 0.01 );
41 TS_ASSERT_DELTA( *( (
double* )bv.
getBytes() + 2 ), 212.0, 0.01 );
42 TS_ASSERT_DELTA( *( (
double* )bv.
getBytes() + 3 ), 705.0, 1.0 );
45 double tempsInF[4] = {};
47 TS_ASSERT_DELTA( tempsInF[0], -459.67, 0.01 );
48 TS_ASSERT_DELTA( tempsInF[1], 32.0, 0.01 );
49 TS_ASSERT_DELTA( tempsInF[2], 212.0, 0.01 );
50 TS_ASSERT_DELTA( tempsInF[3], 705.0, 1.0 );
53 double tempsInF2[2] = {};
55 TS_ASSERT_DELTA( tempsInF2[0], -459.67, 0.01 );
56 TS_ASSERT_DELTA( tempsInF2[1], 32.0, 0.01 );
59 double tempsInK[3] = {};
61 TS_ASSERT_DELTA( tempsInK[0], 0.0, 0.01 );
62 TS_ASSERT_DELTA( tempsInK[1], 273.15, 0.01 );
63 TS_ASSERT_DELTA( tempsInK[2], 373.15, 0.01 );
76 const double tempsInC[] = { -273.15, 0, 100, 374};
86 TS_ASSERT_DELTA( *( (
double* )bv.
getBytes() + 0 ), -459.67, 0.01 );
87 TS_ASSERT_DELTA( *( (
double* )bv.
getBytes() + 1 ), 32.0, 0.01 );
88 TS_ASSERT_DELTA( *( (
double* )bv.
getBytes() + 2 ), 212.0, 0.01 );
89 TS_ASSERT_DELTA( *( (
double* )bv.
getBytes() + 3 ), 705.0, 1.0 );
92 double tempsInF[4] = {};
94 TS_ASSERT_DELTA( tempsInF[0], -459.67, 0.01 );
95 TS_ASSERT_DELTA( tempsInF[1], 32.0, 0.01 );
96 TS_ASSERT_DELTA( tempsInF[2], 212.0, 0.01 );
97 TS_ASSERT_DELTA( tempsInF[3], 705.0, 1.0 );
100 double tempsInF2[4] = {};
102 TS_ASSERT_DELTA( tempsInF2[0], -459.67, 0.01 );
103 TS_ASSERT_DELTA( tempsInF2[1], 32.0, 0.01 );
104 TS_ASSERT_DELTA( tempsInF2[2], 212.0, 0.01 );
105 TS_ASSERT_DELTA( tempsInF2[3], 705.0, 1.0 );
108 double tempsInK[4] = {};
110 TS_ASSERT_DELTA( tempsInK[0], 0.0, 0.01 );
111 TS_ASSERT_DELTA( tempsInK[1], 273.15, 0.01 );
112 TS_ASSERT_DELTA( tempsInK[2], 373.15, 0.01 );
113 TS_ASSERT_DELTA( tempsInK[3], 647.15, 0.01 );
125 const double tempsInC[] = { -273.15, 0, 100, 374};
132 bool success =
false;
134 float fVal = nanf(
"" );
136 TS_ASSERT_DELTA( fVal, -459.67, 0.01 );
138 TS_ASSERT_DELTA( fVal, 32, 0.01 );
140 TS_ASSERT_DELTA( fVal, 212, 0.01 );
142 TS_ASSERT_DELTA( fVal, 705.0, 1.0 );
145 double tempsInF[4] = {};
147 TS_ASSERT_DELTA( tempsInF[0], -459.67, 0.01 );
148 TS_ASSERT_DELTA( tempsInF[1], 32.0, 0.01 );
149 TS_ASSERT_DELTA( tempsInF[2], 212.0, 0.01 );
150 TS_ASSERT_DELTA( tempsInF[3], 705.0, 1.0 );
153 double tempsInK[4] = {};
155 TS_ASSERT_DELTA( tempsInK[0], 0.0, 0.01 );
156 TS_ASSERT_DELTA( tempsInK[1], 273.15, 0.01 );
157 TS_ASSERT_DELTA( tempsInK[2], 373.15, 0.01 );
158 TS_ASSERT_DELTA( tempsInK[3], 647.15, 0.01 );
164 const int m = 2, n = 3;
168 const float dataF[m][n] = { { -40, 0, 32 }, { -459.67, 212, 705 } };
169 const float dataC[m][n] = { { -40, -17.78, 0 }, { -273.15, 100, 374 } };
174 for(
int i = 0; i < m; ++i )
176 for(
int j = 0; j < n; ++j )
178 TS_ASSERT_DELTA( dataF[i][j], dataOut[i][j], 1.f );
182 for(
int i = 0; i < m; ++i )
184 for(
int j = 0; j < n; ++j )
186 TS_ASSERT_DELTA( dataC[i][j], dataOut[i][j], 1.f );
191 for(
int i = 0; i < m; ++i )
193 for(
int j = 0; j < n; ++j )
195 TS_ASSERT_DELTA( dataC[i][j], dataOut[i][j], 1.f );
199 for(
int i = 0; i < m; ++i )
201 for(
int j = 0; j < n; ++j )
203 TS_ASSERT_DELTA( dataF[i][j], dataOut[i][j], 1.f );
210 for(
int i = 0; i < m; ++i )
212 for(
int j = 0; j < n; ++j )
214 pDataF[i][j] = dataF[i][j];
215 pDataC[i][j] = dataC[i][j];
221 for(
int i = 0; i < m; ++i )
223 for(
int j = 0; j < n; ++j )
225 TS_ASSERT_DELTA( pDataF[i][j], pDataOut[i][j], 1.f );
229 for(
int i = 0; i < m; ++i )
231 for(
int j = 0; j < n; ++j )
233 TS_ASSERT_DELTA( pDataC[i][j], pDataOut[i][j], 1.f );
238 for(
int i = 0; i < m; ++i )
240 for(
int j = 0; j < n; ++j )
242 TS_ASSERT_DELTA( pDataC[i][j], pDataOut[i][j], 1.f );
246 for(
int i = 0; i < m; ++i )
248 for(
int j = 0; j < n; ++j )
250 TS_ASSERT_DELTA( pDataF[i][j], pDataOut[i][j], 1.f );
262 const int m = 2, n = 3, o = 4;
266 const float dataF[m][n][o] = { { { -40, 50, 140, 230}, {0, 90, 180, 270}, {32, 122, 212, 302} },
267 { { -459.67, -369.67, -279.67, -189.67}, {212, 302, 392, 482}, {705, 795, 885, 975} }
269 const float dataC[m][n][o] = { { { -40, 10, 60, 110}, { -17.78, 32.22, 82.22, 132.22}, {0, 50, 100, 150} },
270 { { -273.15, -223.15, -173.15, -123.15}, {100, 150, 200, 250}, {374, 424, 474, 524} }
272 float dataOut[m][n][o];
276 for(
int i = 0; i < m; ++i )
278 for(
int j = 0; j < n; ++j )
280 for(
int k = 0; k < o; ++k )
282 TS_ASSERT_DELTA( dataF[i][j][k], dataOut[i][j][k], 1.f );
287 for(
int i = 0; i < m; ++i )
289 for(
int j = 0; j < n; ++j )
291 for(
int k = 0; k < o; ++k )
293 TS_ASSERT_DELTA( dataC[i][j][k], dataOut[i][j][k], 1.f );
299 for(
int i = 0; i < m; ++i )
301 for(
int j = 0; j < n; ++j )
303 for(
int k = 0; k < o; ++k )
305 TS_ASSERT_DELTA( dataC[i][j][k], dataOut[i][j][k], 1.f );
310 for(
int i = 0; i < m; ++i )
312 for(
int j = 0; j < n; ++j )
314 for(
int k = 0; k < o; ++k )
316 TS_ASSERT_DELTA( dataF[i][j][k], dataOut[i][j][k], 1.f );
324 for(
int i = 0; i < m; ++i )
326 for(
int j = 0; j < n; ++j )
328 for(
int k = 0; k < o; ++k )
330 pDataF[i][j][k] = dataF[i][j][k];
331 pDataC[i][j][k] = dataC[i][j][k];
338 for(
int i = 0; i < m; ++i )
340 for(
int j = 0; j < n; ++j )
342 for(
int k = 0; k < o; ++k )
344 TS_ASSERT_DELTA( pDataF[i][j][k], pDataOut[i][j][k], 1.f );
349 for(
int i = 0; i < m; ++i )
351 for(
int j = 0; j < n; ++j )
353 for(
int k = 0; k < o; ++k )
355 TS_ASSERT_DELTA( pDataC[i][j][k], pDataOut[i][j][k], 1.f );
361 for(
int i = 0; i < m; ++i )
363 for(
int j = 0; j < n; ++j )
365 for(
int k = 0; k < o; ++k )
367 TS_ASSERT_DELTA( pDataC[i][j][k], pDataOut[i][j][k], 1.f );
372 for(
int i = 0; i < m; ++i )
374 for(
int j = 0; j < n; ++j )
376 for(
int k = 0; k < o; ++k )
378 TS_ASSERT_DELTA( pDataF[i][j][k], pDataOut[i][j][k], 1.f );
389 #endif // _BLOB_TEST_H
void testReadWrite(void)
Test Read & Write.
Definition: Blob_Test.h:68
Contains the AsyncComponent class definition.
Contains the BlobReader class definition.
size_t getByteLength()
Definition: BlobValue.h:222
void * getBytes()
Definition: BlobValue.h:227
Definition: ElementURI.h:211
BlobValue readBlob(bool &success)
Definition: BlobReader.h:45
BlobReader * newBlobReader(const BlobURI &blobURI)
Definition: Component.cpp:547
Definition: BlobReader.h:212
void testBlobValue2D(void)
Definition: Blob_Test.h:162
Definition: BlobType.h:33
static T ** New2D(int m, int n, bool extra=false)
Definition: I2D.h:30
Definition: BlobWriter.h:227
size_t getElements()
Definition: BlobValue.h:217
int read1DArray(const Unit &unit, T(&x)[M])
Definition: BlobReader.h:53
static void Delete2D(T **array)
Definition: I2D.h:45
static const Unit FAHRENHEIT
Definition: Units.h:177
int copyTo(const Unit &unit, T *array, size_t elements)
Definition: BlobValue.cpp:272
void getElement(size_t index, T &value, bool flip)
Get an individual value, without bounds checking or scaling.
Definition: BlobValue.cpp:541
Wraps a StrValue as an arbitrary collection of binary values, with units.
Definition: BlobValue.h:26
BlobWriter * newBlobWriter(const BlobURI &blobURI, Logger::TimePrecisionType timePrecision=Logger::TIME_PRECISION_MILLIS)
Definition: Component.cpp:566
Definition: BlobType.h:34
static T *** New3D(int m, int n, int o, bool extra=false)
Definition: I3D.h:33
void testBlobValue3D(void)
Definition: Blob_Test.h:260
bool isActive(void)
Definition: DataReader.cpp:74
Definition: BlobType.h:35
static void Delete3D(T ***array)
Definition: I3D.h:58
void testBlobValue(void)
Definition: Blob_Test.h:30
Unit tests for the BlobValue, BlobReader, and BlobWriter classes.
Definition: Blob_Test.h:25
const CodedStr & getName(void) const
Returns the name.
Definition: Component.h:158
void setFrom(const Unit &unit, const T *array, size_t elements)
Definition: BlobValue.cpp:93
static const Unit CELSIUS
Definition: Units.h:110
Dummy implementation of AsyncComponent for testing purposes.
Definition: TestAsyncComponent.h:19
static const BaseUnit KELVIN
Definition: Units.h:40
Contains the BlobValue class definition.
Contains the BlobWriter class definition.
void testReadWriteConversions(void)
Test Read & Write with cast conversions.
Definition: Blob_Test.h:117