4 #define BOOST_TEST_DYN_LINK
16 #define BOOST_TEST_MODULE MultiplexedDataAccessorTest
17 #include <boost/test/data/test_case.hpp>
18 #include <boost/test/unit_test.hpp>
19 using namespace boost::unit_test_framework;
23 static const std::string DMAP_FILE_NAME_(
"dummies.dmap");
24 static const std::string TEST_MODULE_NAME(
"TEST");
25 static const std::string INVALID_MODULE_NAME(
"INVALID");
26 static const RegisterPath TEST_MODULE_PATH(TEST_MODULE_NAME);
27 static const RegisterPath INVALID_MODULE_PATH(INVALID_MODULE_NAME);
45 static TestParameters AREA_PARAMS{
"dummies.dmap",
"SEQUENCES",
"INVALID_SEQUENCES",
"SEQUENCES",
"sequences.map"};
48 "newMuxedDummies.dmap",
"NEW_SEQUENCES",
"NEW_INVALID_SEQUENCES",
"NEW_SEQUENCES",
"newSequences.mapp"};
50 BOOST_AUTO_TEST_SUITE(MultiplexedDataAccessorTestSuite)
53 BackendFactory::getInstance().setDMapFilePath(sample.dmapFile);
57 BOOST_TEST(deMultiplexer[0].size() == 5);
64 template<
class SequenceWordType>
66 std::cout <<
"testDeMultiplexing areaName = " << areaName
67 <<
" SequenceWordType = " <<
typeid(SequenceWordType).name() << std::endl;
70 BackendFactory::getInstance().setDMapFilePath(sample.
dmapFile);
74 std::vector<SequenceWordType> ioBuffer(15);
76 size_t nBytes = std::min(area.getNElements() *
sizeof(int32_t), 15 *
sizeof(SequenceWordType));
92 memcpy(&(area[0]), ioBuffer.data(), nBytes);
98 BOOST_TEST(deMultiplexer.isReadOnly() ==
false);
99 BOOST_TEST(deMultiplexer.isReadable());
100 BOOST_TEST(deMultiplexer.isWriteable());
102 deMultiplexer.read();
104 BOOST_TEST(deMultiplexer[0][0] ==
'A');
105 BOOST_TEST(deMultiplexer[0][1] ==
'B');
106 BOOST_TEST(deMultiplexer[0][2] ==
'C');
107 BOOST_TEST(deMultiplexer[0][3] ==
'D');
108 BOOST_TEST(deMultiplexer[0][4] ==
'E');
109 BOOST_TEST(deMultiplexer[1][0] ==
'a');
110 BOOST_TEST(deMultiplexer[1][1] ==
'b');
111 BOOST_TEST(deMultiplexer[1][2] ==
'c');
112 BOOST_TEST(deMultiplexer[1][3] ==
'd');
113 BOOST_TEST(deMultiplexer[1][4] ==
'e');
114 BOOST_TEST(deMultiplexer[2][0] ==
'0');
115 BOOST_TEST(deMultiplexer[2][1] ==
'1');
116 BOOST_TEST(deMultiplexer[2][2] ==
'2');
117 BOOST_TEST(deMultiplexer[2][3] ==
'3');
118 BOOST_TEST(deMultiplexer[2][4] ==
'4');
120 for(
size_t sequenceIndex = 0; sequenceIndex < 3; ++sequenceIndex) {
121 for(
size_t i = 0; i < 5; ++i) {
122 deMultiplexer[sequenceIndex][i] += 5;
126 deMultiplexer.write();
128 memcpy(ioBuffer.data(), &(area[0]), nBytes);
130 BOOST_TEST(ioBuffer[0] ==
'F');
131 BOOST_TEST(ioBuffer[1] ==
'f');
132 BOOST_TEST(ioBuffer[2] ==
'5');
133 BOOST_TEST(ioBuffer[3] ==
'G');
134 BOOST_TEST(ioBuffer[4] ==
'g');
135 BOOST_TEST(ioBuffer[5] ==
'6');
136 BOOST_TEST(ioBuffer[6] ==
'H');
137 BOOST_TEST(ioBuffer[7] ==
'h');
138 BOOST_TEST(ioBuffer[8] ==
'7');
139 BOOST_TEST(ioBuffer[9] ==
'I');
140 BOOST_TEST(ioBuffer[10] ==
'i');
141 BOOST_TEST(ioBuffer[11] ==
'8');
142 BOOST_TEST(ioBuffer[12] ==
'J');
143 BOOST_TEST(ioBuffer[13] ==
'j');
144 BOOST_TEST(ioBuffer[14] ==
'9');
148 testDeMultiplexing<int32_t>(
"INT", sample);
151 testDeMultiplexing<int16_t>(
"SHORT", sample);
154 testDeMultiplexing<int8_t>(
"CHAR", sample);
159 template<
class SequenceWordType>
162 BackendFactory::getInstance().setDMapFilePath(sample.
dmapFile);
166 std::vector<SequenceWordType> ioBuffer(15);
168 size_t nBytes = std::min(area.getNElements() *
sizeof(int32_t), 15 *
sizeof(SequenceWordType));
170 for(
size_t i = 0; i < ioBuffer.size(); ++i) {
173 memcpy(&(area[0]), ioBuffer.data(), nBytes);
180 BOOST_TEST(accessor[0][0] == 0);
181 BOOST_TEST(accessor[1][0] == 0.25);
182 BOOST_TEST(accessor[2][0] == 0.25);
183 BOOST_TEST(accessor[0][1] == 1.5);
184 BOOST_TEST(accessor[1][1] == 1);
185 BOOST_TEST(accessor[2][1] == 0.625);
186 BOOST_TEST(accessor[0][2] == 3.);
187 BOOST_TEST(accessor[1][2] == 1.75);
188 BOOST_TEST(accessor[2][2] == 1.);
189 BOOST_TEST(accessor[0][3] == 4.5);
190 BOOST_TEST(accessor[1][3] == 2.5);
191 BOOST_TEST(accessor[2][3] == 1.375);
192 BOOST_TEST(accessor[0][4] == 6.);
193 BOOST_TEST(accessor[1][4] == 3.25);
194 BOOST_TEST(accessor[2][4] == 1.75);
196 for(
size_t sequenceIndex = 0; sequenceIndex < 3; ++sequenceIndex) {
197 for(
size_t i = 0; i < 5; ++i) {
198 accessor[sequenceIndex][i] += 1.;
205 memcpy(ioBuffer.data(), &(area[0]), nBytes);
207 for(
size_t i = 0; i < 15; ++i) {
210 int addedValue = 1 << (i % 3 + 1);
211 std::stringstream message;
212 message <<
"ioBuffer[" << i <<
"] is " << ioBuffer[i] <<
", expected " << i + addedValue;
213 BOOST_CHECK_MESSAGE(ioBuffer[i] ==
static_cast<SequenceWordType
>(i + addedValue), message.str());
218 testWithConversion<int32_t>(
"FRAC_INT", sample);
221 testWithConversion<int16_t>(
"FRAC_SHORT", sample);
224 testWithConversion<int8_t>(
"FRAC_CHAR", sample);
229 BackendFactory::getInstance().setDMapFilePath(sample.dmapFile);
238 BOOST_TEST(myMixedData[0].size() == 372);
240 myMixedData[0][0] = -24673;
241 myMixedData[1][0] = -13724;
242 myMixedData[2][0] = 130495;
243 myMixedData[3][0] = 513;
244 myMixedData[4][0] = 1027;
245 myMixedData[5][0] = -56.4;
246 myMixedData[6][0] = 78;
247 myMixedData[7][0] = 45.2;
248 myMixedData[8][0] = -23.9;
249 myMixedData[9][0] = 61.3;
250 myMixedData[10][0] = -12;
255 BOOST_TEST(myRawData[0] == -899375201);
256 BOOST_TEST(myRawData[1] == 130495);
257 BOOST_TEST(myRawData[2] == 67305985);
258 BOOST_TEST(myRawData[3] == 5112008);
259 BOOST_TEST(myRawData[4] == -197269459);
263 BOOST_TEST(myMixedData[0][0] == -24673);
264 BOOST_TEST(myMixedData[1][0] == -13724);
265 BOOST_TEST(myMixedData[2][0] == 130495);
266 BOOST_TEST(myMixedData[3][0] == 513);
267 BOOST_TEST(myMixedData[4][0] == 1027);
268 BOOST_TEST(myMixedData[5][0] == -56);
269 BOOST_TEST(myMixedData[6][0] == 78);
270 BOOST_TEST(myMixedData[7][0] == 45);
271 BOOST_TEST(myMixedData[8][0] == -24);
272 BOOST_TEST(myMixedData[9][0] == 61);
273 BOOST_TEST(myMixedData[10][0] == -12);
276 BOOST_DATA_TEST_CASE(testNumberOfSequencesDetected, boost::unit_test::data::make({AREA_PARAMS, NEW_AREA_PARAMS})) {
279 BackendFactory::getInstance().setDMapFilePath(sample.dmapFile);
290 BackendFactory::getInstance().setDMapFilePath(sample.dmapFile);
296 const size_t nWordsPerBlock = 44 /
sizeof(int32_t);
301 "APP0/DAQ0_BAM.MULTIPLEXED_RAW", 300 * nWordsPerBlock, 42 * nWordsPerBlock, {AccessMode::raw});
305 BOOST_TEST(myMixedData[0].size() == 300);
308 myMixedData[0][i] = -24673;
309 myMixedData[1][i] = -13724;
310 myMixedData[2][i] = 130495;
311 myMixedData[3][i] = 513;
312 myMixedData[4][i] = 1027;
313 myMixedData[5][i] = -56.4;
314 myMixedData[6][i] = 78;
315 myMixedData[7][i] = 45.2;
316 myMixedData[8][i] = -23.9;
317 myMixedData[9][i] = 61.3;
318 myMixedData[10][i] = -12;
323 BOOST_TEST(myRawData[0 + i * nWordsPerBlock] == -899375201);
324 BOOST_TEST(myRawData[1 + i * nWordsPerBlock] == 130495);
325 BOOST_TEST(myRawData[2 + i * nWordsPerBlock] == 67305985);
326 BOOST_TEST(myRawData[3 + i * nWordsPerBlock] == 5112008);
327 BOOST_TEST(myRawData[4 + i * nWordsPerBlock] == -197269459);
331 BOOST_TEST(myMixedData[0][i] == -24673);
332 BOOST_TEST(myMixedData[1][i] == -13724);
333 BOOST_TEST(myMixedData[2][i] == 130495);
334 BOOST_TEST(myMixedData[3][i] == 513);
335 BOOST_TEST(myMixedData[4][i] == 1027);
336 BOOST_TEST(myMixedData[5][i] == -56);
337 BOOST_TEST(myMixedData[6][i] == 78);
338 BOOST_TEST(myMixedData[7][i] == 45);
339 BOOST_TEST(myMixedData[8][i] == -24);
340 BOOST_TEST(myMixedData[9][i] == 61);
341 BOOST_TEST(myMixedData[10][i] == -12);
343 myMixedData[0][i] = i;
344 myMixedData[1][i] = 0;
345 myMixedData[2][i] = 0;
346 myMixedData[3][i] = 0;
347 myMixedData[4][i] = 0;
348 myMixedData[5][i] = 0;
349 myMixedData[6][i] = 0;
350 myMixedData[7][i] = 0;
351 myMixedData[8][i] = 0;
352 myMixedData[9][i] = 0;
353 myMixedData[10][i] = 0;
358 BOOST_TEST(myRawData[0 + i * nWordsPerBlock] ==
static_cast<int>(i));
359 BOOST_TEST(myRawData[1 + i * nWordsPerBlock] == 0);
360 BOOST_TEST(myRawData[2 + i * nWordsPerBlock] == 0);
361 BOOST_TEST(myRawData[3 + i * nWordsPerBlock] == 0);
362 BOOST_TEST(myRawData[4 + i * nWordsPerBlock] == 0);
366 BOOST_TEST(myMixedData[0][i] == i);
367 BOOST_TEST(myMixedData[1][i] == 0);
368 BOOST_TEST(myMixedData[2][i] == 0);
369 BOOST_TEST(myMixedData[3][i] == 0);
370 BOOST_TEST(myMixedData[4][i] == 0);
371 BOOST_TEST(myMixedData[5][i] == 0);
372 BOOST_TEST(myMixedData[6][i] == 0);
373 BOOST_TEST(myMixedData[7][i] == 0);
374 BOOST_TEST(myMixedData[8][i] == 0);
375 BOOST_TEST(myMixedData[9][i] == 0);
376 BOOST_TEST(myMixedData[10][i] == 0);
382 BackendFactory::getInstance().setDMapFilePath(sample.dmapFile);
386 const size_t nWordsPerBlock = 44 /
sizeof(int32_t);
393 BOOST_TEST(myMixedData[0].size() == 120);
396 myMixedData[0][i] = -24673;
397 myMixedData[1][i] = -13724;
398 myMixedData[2][i] = 130495;
399 myMixedData[3][i] = 513;
400 myMixedData[4][i] = 1027;
401 myMixedData[5][i] = -56.4;
402 myMixedData[6][i] = 78;
403 myMixedData[7][i] = 45.2;
404 myMixedData[8][i] = -23.9;
405 myMixedData[9][i] = 61.3;
406 myMixedData[10][i] = -12;
411 BOOST_TEST(myRawData[0 + i * nWordsPerBlock] == -899375201);
412 BOOST_TEST(myRawData[1 + i * nWordsPerBlock] == 130495);
413 BOOST_TEST(myRawData[2 + i * nWordsPerBlock] == 67305985);
414 BOOST_TEST(myRawData[3 + i * nWordsPerBlock] == 5112008);
415 BOOST_TEST(myRawData[4 + i * nWordsPerBlock] == -197269459);
419 BOOST_TEST(myMixedData[0][i] == -24673);
420 BOOST_TEST(myMixedData[1][i] == -13724);
421 BOOST_TEST(myMixedData[2][i] == 130495);
422 BOOST_TEST(myMixedData[3][i] == 513);
423 BOOST_TEST(myMixedData[4][i] == 1027);
424 BOOST_TEST(myMixedData[5][i] == -56);
425 BOOST_TEST(myMixedData[6][i] == 78);
426 BOOST_TEST(myMixedData[7][i] == 45);
427 BOOST_TEST(myMixedData[8][i] == -24);
428 BOOST_TEST(myMixedData[9][i] == 61);
429 BOOST_TEST(myMixedData[10][i] == -12);
431 myMixedData[0][i] = i;
432 myMixedData[1][i] = 0;
433 myMixedData[2][i] = 0;
434 myMixedData[3][i] = 0;
435 myMixedData[4][i] = 0;
436 myMixedData[5][i] = 0;
437 myMixedData[6][i] = 0;
438 myMixedData[7][i] = 0;
439 myMixedData[8][i] = 0;
440 myMixedData[9][i] = 0;
441 myMixedData[10][i] = 0;
446 BOOST_TEST(myRawData[0 + i * nWordsPerBlock] == (
int)i);
447 BOOST_TEST(myRawData[1 + i * nWordsPerBlock] == 0);
448 BOOST_TEST(myRawData[2 + i * nWordsPerBlock] == 0);
449 BOOST_TEST(myRawData[3 + i * nWordsPerBlock] == 0);
450 BOOST_TEST(myRawData[4 + i * nWordsPerBlock] == 0);
454 BOOST_TEST(myMixedData[0][i] == i);
455 BOOST_TEST(myMixedData[1][i] == 0);
456 BOOST_TEST(myMixedData[2][i] == 0);
457 BOOST_TEST(myMixedData[3][i] == 0);
458 BOOST_TEST(myMixedData[4][i] == 0);
459 BOOST_TEST(myMixedData[5][i] == 0);
460 BOOST_TEST(myMixedData[6][i] == 0);
461 BOOST_TEST(myMixedData[7][i] == 0);
462 BOOST_TEST(myMixedData[8][i] == 0);
463 BOOST_TEST(myMixedData[9][i] == 0);
464 BOOST_TEST(myMixedData[10][i] == 0);
468 BOOST_AUTO_TEST_SUITE_END()