1 #include "artdaq-core/Data/Fragment.hh"
3 #define BOOST_TEST_MODULE(Fragment_t)
5 #include "cetlib/quiet_unit_test.hpp"
7 #include "boost/test/auto_unit_test.hpp"
28 BOOST_AUTO_TEST_SUITE(Fragment_test)
30 BOOST_AUTO_TEST_CASE(Construct)
36 BOOST_REQUIRE_EQUAL(f1.dataSize(), (size_t) 0);
37 BOOST_REQUIRE_EQUAL(f1.size(), (size_t) 3);
38 BOOST_REQUIRE_EQUAL(f1.version(), (artdaq::Fragment::version_t) 0);
39 BOOST_REQUIRE_EQUAL(f1.type(), (artdaq::Fragment::type_t) 0);
40 BOOST_REQUIRE_EQUAL(f1.sequenceID(), (artdaq::Fragment::sequence_id_t) 0);
41 BOOST_REQUIRE_EQUAL(f1.fragmentID(), (artdaq::Fragment::fragment_id_t) 0);
42 BOOST_REQUIRE_EQUAL(f1.hasMetadata(),
false);
45 BOOST_REQUIRE_EQUAL(f2.dataSize(), (size_t) 7);
46 BOOST_REQUIRE_EQUAL(f2.size(), (size_t) 10);
47 BOOST_REQUIRE_EQUAL(f2.version(), (artdaq::Fragment::version_t) 0);
48 BOOST_REQUIRE(f2.type() == artdaq::Fragment::InvalidFragmentType);
49 BOOST_REQUIRE(f2.sequenceID() == artdaq::Fragment::InvalidSequenceID);
50 BOOST_REQUIRE(f2.fragmentID() == artdaq::Fragment::InvalidFragmentID);
51 BOOST_REQUIRE_EQUAL(f2.hasMetadata(),
false);
54 BOOST_REQUIRE_EQUAL(f3.dataSize(), (size_t) 0);
55 BOOST_REQUIRE_EQUAL(f3.size(), (size_t) 3);
56 BOOST_REQUIRE_EQUAL(f3.version(), (artdaq::Fragment::version_t) 0);
57 BOOST_REQUIRE(f3.type() == artdaq::Fragment::DataFragmentType);
58 BOOST_REQUIRE_EQUAL(f3.sequenceID(), (artdaq::Fragment::sequence_id_t) 101);
59 BOOST_REQUIRE_EQUAL(f3.fragmentID(), (artdaq::Fragment::fragment_id_t) 202);
60 BOOST_REQUIRE_EQUAL(f3.hasMetadata(),
false);
66 BOOST_REQUIRE(0 &&
"Should have thrown exception");
68 catch (cet::exception
const & excpt) {
71 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
76 BOOST_REQUIRE(0 &&
"Should have thrown exception");
78 catch (cet::exception
const & excpt) {
81 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
86 BOOST_REQUIRE(0 &&
"Should have thrown exception");
88 catch (cet::exception
const & excpt) {
91 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
96 BOOST_REQUIRE(0 &&
"Should have thrown exception");
98 catch (cet::exception
const & excpt) {
101 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
106 frag(101, 202, artdaq::detail::RawFragmentHeader::FIRST_SYSTEM_TYPE);
107 BOOST_REQUIRE(0 &&
"Should have thrown exception");
109 catch (cet::exception
const & excpt) {
112 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
117 frag(101, 202, artdaq::detail::RawFragmentHeader::LAST_SYSTEM_TYPE);
118 BOOST_REQUIRE(0 &&
"Should have thrown exception");
120 catch (cet::exception
const & excpt) {
123 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
128 fragA(101, 202, artdaq::detail::RawFragmentHeader::FIRST_USER_TYPE);
130 fragB(101, 202, artdaq::detail::RawFragmentHeader::LAST_USER_TYPE);
139 BOOST_REQUIRE(0 &&
"Should not have thrown exception");
143 BOOST_AUTO_TEST_CASE(FragmentType)
150 BOOST_REQUIRE(0 &&
"Should have thrown exception");
152 catch (cet::exception
const & excpt) {
155 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
159 frag.setUserType(225);
160 BOOST_REQUIRE(0 &&
"Should have thrown exception");
162 catch (cet::exception
const & excpt) {
165 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
169 frag.setUserType(255);
170 BOOST_REQUIRE(0 &&
"Should have thrown exception");
172 catch (cet::exception
const & excpt) {
175 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
179 frag.setUserType(artdaq::Fragment::InvalidFragmentType);
180 BOOST_REQUIRE(0 &&
"Should have thrown exception");
182 catch (cet::exception
const & excpt) {
185 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
189 frag.setUserType(artdaq::detail::RawFragmentHeader::FIRST_SYSTEM_TYPE);
190 BOOST_REQUIRE(0 &&
"Should have thrown exception");
192 catch (cet::exception
const & excpt) {
195 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
199 frag.setUserType(artdaq::detail::RawFragmentHeader::LAST_SYSTEM_TYPE);
200 BOOST_REQUIRE(0 &&
"Should have thrown exception");
202 catch (cet::exception
const & excpt) {
205 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
209 frag.setUserType(artdaq::detail::RawFragmentHeader::FIRST_USER_TYPE);
210 frag.setUserType(artdaq::detail::RawFragmentHeader::LAST_USER_TYPE);
211 frag.setUserType( 1);
212 frag.setUserType( 2);
213 frag.setUserType( 3);
214 frag.setUserType(100);
215 frag.setUserType(200);
216 frag.setUserType(224);
219 BOOST_REQUIRE(0 &&
"Should not have thrown exception");
224 frag.setSystemType(0);
225 BOOST_REQUIRE(0 &&
"Should have thrown exception");
227 catch (cet::exception
const & excpt) {
230 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
234 frag.setSystemType(1);
235 BOOST_REQUIRE(0 &&
"Should have thrown exception");
237 catch (cet::exception
const & excpt) {
240 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
244 frag.setSystemType(224);
245 BOOST_REQUIRE(0 &&
"Should have thrown exception");
247 catch (cet::exception
const & excpt) {
250 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
254 frag.setSystemType(artdaq::Fragment::InvalidFragmentType);
255 BOOST_REQUIRE(0 &&
"Should have thrown exception");
257 catch (cet::exception
const & excpt) {
260 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
264 frag.setSystemType(artdaq::detail::RawFragmentHeader::FIRST_USER_TYPE);
265 BOOST_REQUIRE(0 &&
"Should have thrown exception");
267 catch (cet::exception
const & excpt) {
270 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
274 frag.setSystemType(artdaq::detail::RawFragmentHeader::LAST_USER_TYPE);
275 BOOST_REQUIRE(0 &&
"Should have thrown exception");
277 catch (cet::exception
const & excpt) {
280 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
284 frag.setSystemType(artdaq::detail::RawFragmentHeader::FIRST_SYSTEM_TYPE);
285 frag.setSystemType(artdaq::detail::RawFragmentHeader::LAST_SYSTEM_TYPE);
286 frag.setSystemType(225);
287 frag.setSystemType(230);
288 frag.setSystemType(240);
289 frag.setSystemType(250);
290 frag.setSystemType(255);
293 BOOST_REQUIRE(0 &&
"Should not have thrown exception");
297 BOOST_AUTO_TEST_CASE(SequenceID)
301 BOOST_REQUIRE_EQUAL(f1.sequenceID(), (uint64_t)0);
303 BOOST_REQUIRE_EQUAL(f1.sequenceID(), (uint64_t)1);
304 f1.setSequenceID(0xffff);
305 BOOST_REQUIRE_EQUAL(f1.sequenceID(), (uint64_t)0xffff);
306 f1.setSequenceID(0x0000ffffffffffff);
307 BOOST_REQUIRE_EQUAL(f1.sequenceID(), (uint64_t)0x0000ffffffffffff);
310 BOOST_REQUIRE_EQUAL(f2.sequenceID(), (uint64_t)0x12345);
313 BOOST_REQUIRE_EQUAL(f3.sequenceID(), (uint64_t)0x0000567812345678);
316 BOOST_AUTO_TEST_CASE(FragmentID)
320 BOOST_REQUIRE_EQUAL(f1.fragmentID(), (uint16_t)0);
322 BOOST_REQUIRE_EQUAL(f1.fragmentID(), (uint16_t)1);
323 f1.setFragmentID(0xffff);
324 BOOST_REQUIRE_EQUAL(f1.fragmentID(), (uint16_t)0xffff);
327 BOOST_REQUIRE_EQUAL(f2.fragmentID(), (uint16_t)0xab);
330 BOOST_REQUIRE_EQUAL(f3.fragmentID(), (uint16_t)0xffff);
333 BOOST_AUTO_TEST_CASE(Resize)
338 BOOST_REQUIRE_EQUAL(f1.dataSize(), (size_t) 1234);
339 BOOST_REQUIRE_EQUAL(f1.size(), (size_t) 1234 +
340 artdaq::detail::RawFragmentHeader::num_words());
346 BOOST_REQUIRE_EQUAL(f2.dataSize(), (size_t) 129);
347 BOOST_REQUIRE_EQUAL(f2.size(), (size_t) 129 + 2 +
348 artdaq::detail::RawFragmentHeader::num_words());
351 BOOST_AUTO_TEST_CASE(Empty)
354 BOOST_REQUIRE_EQUAL(f1.empty(),
true);
356 BOOST_REQUIRE_EQUAL(f1.empty(),
false);
360 BOOST_REQUIRE_EQUAL(f2.empty(),
false);
362 BOOST_REQUIRE_EQUAL(f2.empty(),
false);
364 BOOST_REQUIRE_EQUAL(f2.empty(),
true);
365 BOOST_REQUIRE_EQUAL(f2.dataSize(), (size_t) 0);
366 BOOST_REQUIRE_EQUAL(f2.size(), (size_t) 2 +
367 artdaq::detail::RawFragmentHeader::num_words());
370 BOOST_REQUIRE_EQUAL(f3.empty(),
true);
371 f3.setMetadata(mdOneA);
372 BOOST_REQUIRE_EQUAL(f3.empty(),
true);
375 BOOST_REQUIRE_EQUAL(f4.empty(),
false);
376 f4.setMetadata(mdOneA);
377 BOOST_REQUIRE_EQUAL(f4.empty(),
false);
380 BOOST_AUTO_TEST_CASE(Clear)
383 BOOST_REQUIRE_EQUAL(f1.empty(),
true);
385 BOOST_REQUIRE_EQUAL(f1.empty(),
false);
387 BOOST_REQUIRE_EQUAL(f1.empty(),
true);
391 BOOST_REQUIRE_EQUAL(f2.empty(),
false);
393 BOOST_REQUIRE_EQUAL(f2.empty(),
false);
395 BOOST_REQUIRE_EQUAL(f2.empty(),
true);
396 BOOST_REQUIRE_EQUAL(f2.dataSize(), (size_t) 0);
397 BOOST_REQUIRE_EQUAL(f2.size(), (size_t) 2 +
398 artdaq::detail::RawFragmentHeader::num_words());
401 BOOST_REQUIRE_EQUAL(f3.empty(),
true);
402 BOOST_REQUIRE_EQUAL(f3.hasMetadata(),
false);
403 f3.setMetadata(mdOneA);
404 BOOST_REQUIRE_EQUAL(f3.empty(),
true);
405 BOOST_REQUIRE_EQUAL(f3.hasMetadata(),
true);
407 BOOST_REQUIRE_EQUAL(f3.empty(),
true);
408 BOOST_REQUIRE_EQUAL(f3.hasMetadata(),
true);
411 BOOST_REQUIRE_EQUAL(f4.empty(),
false);
412 BOOST_REQUIRE_EQUAL(f4.hasMetadata(),
false);
413 f4.setMetadata(mdOneA);
414 BOOST_REQUIRE_EQUAL(f4.empty(),
false);
415 BOOST_REQUIRE_EQUAL(f4.hasMetadata(),
true);
417 BOOST_REQUIRE_EQUAL(f4.empty(),
true);
418 BOOST_REQUIRE_EQUAL(f4.hasMetadata(),
true);
421 BOOST_AUTO_TEST_CASE(Addresses)
425 BOOST_REQUIRE_EQUAL(f1.dataSize(), (size_t) 200);
426 BOOST_REQUIRE_EQUAL(f1.size(), (size_t) 200 +
427 artdaq::detail::RawFragmentHeader::num_words());
428 artdaq::RawDataType* haddr = f1.headerAddress();
429 artdaq::RawDataType* daddr = f1.dataAddress();
430 BOOST_REQUIRE_EQUAL(daddr,
431 (haddr + artdaq::detail::RawFragmentHeader::num_words()));
433 f1.metadataAddress();
434 BOOST_REQUIRE(0 &&
"Should have thrown exception");
436 catch (cet::exception
const & excpt) {
439 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
441 BOOST_REQUIRE_EQUAL(haddr, &(*(f1.headerBegin())));
442 BOOST_REQUIRE_EQUAL(daddr, &(*(f1.dataBegin())));
443 BOOST_REQUIRE_EQUAL(daddr+200, &(*(f1.dataEnd())));
448 BOOST_REQUIRE_EQUAL(f2.dataSize(), (size_t) 135);
449 BOOST_REQUIRE_EQUAL(f2.size(), (size_t) 135 + 2 +
450 artdaq::detail::RawFragmentHeader::num_words());
451 haddr = f2.headerAddress();
452 daddr = f2.dataAddress();
453 artdaq::RawDataType* maddr = f2.metadataAddress();
454 BOOST_REQUIRE_EQUAL(maddr, haddr +
455 artdaq::detail::RawFragmentHeader::num_words());
456 BOOST_REQUIRE_EQUAL(daddr, maddr + 2);
457 BOOST_REQUIRE_EQUAL(haddr, &(*(f2.headerBegin())));
458 BOOST_REQUIRE_EQUAL(daddr, &(*(f2.dataBegin())));
459 BOOST_REQUIRE_EQUAL(daddr+135, &(*(f2.dataEnd())));
464 BOOST_REQUIRE_EQUAL(f3.dataSize(), (size_t) 77);
465 BOOST_REQUIRE_EQUAL(f3.size(), (size_t) 77 + 4 +
466 artdaq::detail::RawFragmentHeader::num_words());
467 haddr = f3.headerAddress();
468 daddr = f3.dataAddress();
469 maddr = f3.metadataAddress();
470 BOOST_REQUIRE_EQUAL(maddr, haddr +
471 artdaq::detail::RawFragmentHeader::num_words());
472 BOOST_REQUIRE_EQUAL(daddr, maddr + 4);
473 BOOST_REQUIRE_EQUAL(haddr, &(*(f3.headerBegin())));
474 BOOST_REQUIRE_EQUAL(daddr, &(*(f3.dataBegin())));
475 BOOST_REQUIRE_EQUAL(daddr+77, &(*(f3.dataEnd())));
478 BOOST_AUTO_TEST_CASE(Metadata)
481 BOOST_REQUIRE_EQUAL(f1.hasMetadata(),
false);
484 BOOST_REQUIRE(0 &&
"Should have thrown exception");
486 catch (cet::exception
const & excpt) {
489 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
498 f1.updateMetadata(mdOneA);
499 BOOST_REQUIRE(0 &&
"Should have thrown exception");
501 catch (cet::exception
const & excpt) {
504 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
508 f1.setMetadata(mdOneA);
510 BOOST_REQUIRE_EQUAL(mdOnePtr->field1, (uint64_t) 5);
511 BOOST_REQUIRE_EQUAL(mdOnePtr->field2, (uint32_t)10);
512 BOOST_REQUIRE_EQUAL(mdOnePtr->field3, (uint32_t)15);
516 f1.setMetadata(mdOneB);
517 BOOST_REQUIRE(0 &&
"Should have thrown exception");
519 catch (cet::exception
const & excpt) {
522 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
525 f1.updateMetadata( *mdOnePtr );
535 f1.updateMetadata(mdTwoA);
536 BOOST_REQUIRE(0 &&
"Should have thrown exception");
538 catch (cet::exception
const & excpt) {
541 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
546 BOOST_REQUIRE_EQUAL(mdTwoPtr->field1, (uint64_t)10);
547 BOOST_REQUIRE_EQUAL(mdTwoPtr->field2, (uint32_t)20);
548 BOOST_REQUIRE_EQUAL(mdTwoPtr->field3, (uint32_t)30);
549 BOOST_REQUIRE_EQUAL(mdTwoPtr->field4, (uint32_t)40);
550 BOOST_REQUIRE_EQUAL(mdTwoPtr->field5, (uint32_t)50);
553 BOOST_REQUIRE_EQUAL(f3.sequenceID(), (uint32_t)0xabcdef);
554 BOOST_REQUIRE_EQUAL(f3.fragmentID(), (uint16_t)0xc3a5);
555 BOOST_REQUIRE_EQUAL(f3.type(), (uint16_t)123);
557 BOOST_REQUIRE_EQUAL(f3.sequenceID(), (uint32_t)0xabcdef);
558 BOOST_REQUIRE_EQUAL(f3.fragmentID(), (uint16_t)0xc3a5);
559 BOOST_REQUIRE_EQUAL(f3.type(), (uint8_t) 123);
560 artdaq::RawDataType * dataPtr = f3.dataAddress();
561 dataPtr[0] = 0x12345678;
563 dataPtr[2] = 0x456789ab;
564 dataPtr[3] = 0x3c3c3c3c;
565 dataPtr[4] = 0x5a5a5a5a;
566 BOOST_REQUIRE_EQUAL(dataPtr[0], (uint64_t)0x12345678);
567 BOOST_REQUIRE_EQUAL(dataPtr[1], (uint64_t)0xabcd);
568 BOOST_REQUIRE_EQUAL(dataPtr[2], (uint64_t)0x456789ab);
569 BOOST_REQUIRE_EQUAL(dataPtr[3], (uint64_t)0x3c3c3c3c);
570 BOOST_REQUIRE_EQUAL(dataPtr[4], (uint64_t)0x5a5a5a5a);
571 BOOST_REQUIRE_EQUAL(f3.sequenceID(), (uint32_t)0xabcdef);
572 BOOST_REQUIRE_EQUAL(f3.fragmentID(), (uint16_t)0xc3a5);
573 BOOST_REQUIRE_EQUAL(f3.type(), (uint8_t) 123);
578 f3.setMetadata(mdOneC);
580 BOOST_REQUIRE_EQUAL(mdOnePtr->field1, (uint64_t)505);
581 BOOST_REQUIRE_EQUAL(mdOnePtr->field2, (uint32_t)510);
582 BOOST_REQUIRE_EQUAL(mdOnePtr->field3, (uint32_t)515);
583 BOOST_REQUIRE_EQUAL(f3.sequenceID(), (uint32_t)0xabcdef);
584 BOOST_REQUIRE_EQUAL(f3.fragmentID(), (uint16_t)0xc3a5);
585 BOOST_REQUIRE_EQUAL(f3.type(), (uint8_t) 123);
586 dataPtr = f3.dataAddress();
587 dataPtr[0] = 0x12345678;
589 dataPtr[2] = 0x456789ab;
590 dataPtr[3] = 0x3c3c3c3c;
591 dataPtr[4] = 0x5a5a5a5a;
592 BOOST_REQUIRE_EQUAL(dataPtr[0], (uint64_t)0x12345678);
593 BOOST_REQUIRE_EQUAL(dataPtr[1], (uint64_t)0xabcd);
594 BOOST_REQUIRE_EQUAL(dataPtr[2], (uint64_t)0x456789ab);
595 BOOST_REQUIRE_EQUAL(dataPtr[3], (uint64_t)0x3c3c3c3c);
596 BOOST_REQUIRE_EQUAL(dataPtr[4], (uint64_t)0x5a5a5a5a);
600 BOOST_REQUIRE_EQUAL(f4.hasMetadata(),
false);
602 f4.setMetadata(mdHuge);
603 BOOST_REQUIRE(0 &&
"Should have thrown exception");
605 catch (cet::exception
const & excpt) {
608 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
613 BOOST_REQUIRE(0 &&
"Should have thrown exception");
615 catch (cet::exception
const & excpt) {
618 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
626 BOOST_AUTO_TEST_CASE(Bytes) {
628 std::size_t payload_size = 5;
631 artdaq::Fragment::sequence_id_t seqID = 1;
632 artdaq::Fragment::fragment_id_t fragID = 1;
633 artdaq::Fragment::type_t type = 3;
644 Metadata theMetadata;
646 BOOST_REQUIRE(
sizeof( artdaq::Fragment::byte_t) == 1);
649 BOOST_REQUIRE(
sizeof( artdaq::RawDataType) == 8);
657 std::unique_ptr<artdaq::Fragment> f1_factory(artdaq::Fragment::FragmentBytes(
658 payload_size *
sizeof( artdaq::RawDataType ) ) );
660 BOOST_REQUIRE( f1->size() == f1_factory->size() );
661 BOOST_REQUIRE( f1->sizeBytes() == f1_factory->sizeBytes() );
663 std::unique_ptr<artdaq::Fragment> f2(
new artdaq::Fragment( payload_size, seqID, fragID, type, theMetadata) );
664 std::unique_ptr<artdaq::Fragment> f2_factory( artdaq::Fragment::FragmentBytes(
665 payload_size *
sizeof( artdaq::RawDataType ),
667 type, theMetadata) );
669 BOOST_REQUIRE( f2->size() == f2_factory->size() );
670 BOOST_REQUIRE( f2->sizeBytes() == f2_factory->sizeBytes() );
675 std::size_t offset = 3;
676 std::unique_ptr<artdaq::Fragment> f3_factory( artdaq::Fragment::FragmentBytes(
677 payload_size *
sizeof( artdaq::RawDataType ) - offset,
679 type, theMetadata) );
681 BOOST_REQUIRE( f3_factory->size() == f2->size() );
682 BOOST_REQUIRE( f3_factory->sizeBytes() == f2->sizeBytes() );
688 artdaq::Fragment::byte_t* ptr1 =
reinterpret_cast<artdaq::Fragment::byte_t*
>(
689 &*f3_factory->dataBegin());
691 artdaq::Fragment::byte_t* ptr2 = f3_factory->dataBeginBytes();
693 artdaq::Fragment::byte_t* ptr3 =
reinterpret_cast<artdaq::Fragment::byte_t*
>( f3_factory->dataAddress() );
695 BOOST_REQUIRE_EQUAL( ptr1, ptr2 );
696 BOOST_REQUIRE_EQUAL( ptr2, ptr3 );
700 BOOST_REQUIRE( f3_factory->dataBeginBytes() -
701 reinterpret_cast<artdaq::Fragment::byte_t*
>(
702 &*f3_factory->headerBegin() )
703 == 4 *
sizeof(artdaq::RawDataType) );
706 BOOST_REQUIRE( static_cast<std::size_t>( f3_factory->dataEndBytes() - f3_factory->dataBeginBytes() ) == f3_factory->dataSizeBytes() );
710 BOOST_REQUIRE_EQUAL( f4.dataSize(), payload_size );
711 BOOST_REQUIRE_EQUAL( f4.dataSizeBytes(), (payload_size *
sizeof(artdaq::RawDataType)) );
712 f4.resize( payload_size + 1 );
713 BOOST_REQUIRE_EQUAL( f4.dataSize(), (payload_size + 1) );
714 BOOST_REQUIRE_EQUAL( f4.dataSizeBytes(), ((payload_size + 1) *
sizeof(artdaq::RawDataType)) );
715 f4.resizeBytes( f4.dataSizeBytes() + 2 );
716 BOOST_REQUIRE_EQUAL( f4.dataSize(), (payload_size + 2) );
717 BOOST_REQUIRE_EQUAL( f4.dataSizeBytes(), ((payload_size + 2) *
sizeof(artdaq::RawDataType)) );
718 f4.resizeBytes( f4.dataSizeBytes() + 1 );
719 BOOST_REQUIRE_EQUAL( f4.dataSize(), (payload_size + 3) );
720 BOOST_REQUIRE_EQUAL( f4.dataSizeBytes(), ((payload_size + 3) *
sizeof(artdaq::RawDataType)) );
721 f4.resizeBytes( f4.dataSizeBytes() + 1 );
722 BOOST_REQUIRE_EQUAL( f4.dataSize(), (payload_size + 4) );
723 BOOST_REQUIRE_EQUAL( f4.dataSizeBytes(), ((payload_size + 4) *
sizeof(artdaq::RawDataType)) );
725 size_t targetSize = (payload_size + 4) *
sizeof(artdaq::RawDataType);
727 f4.resizeBytes( targetSize );
728 BOOST_REQUIRE_EQUAL( f4.dataSize(), (payload_size + 5) );
729 BOOST_REQUIRE_EQUAL( f4.dataSizeBytes(), ((payload_size + 5) *
sizeof(artdaq::RawDataType)) );
731 f4.resizeBytes( targetSize );
732 BOOST_REQUIRE_EQUAL( f4.dataSize(), (payload_size + 5) );
733 BOOST_REQUIRE_EQUAL( f4.dataSizeBytes(), ((payload_size + 5) *
sizeof(artdaq::RawDataType)) );
735 f4.resizeBytes( targetSize );
736 BOOST_REQUIRE_EQUAL( f4.dataSize(), (payload_size + 5) );
737 BOOST_REQUIRE_EQUAL( f4.dataSizeBytes(), ((payload_size + 5) *
sizeof(artdaq::RawDataType)) );
739 f4.resizeBytes( targetSize );
740 BOOST_REQUIRE_EQUAL( f4.dataSize(), (payload_size + 5) );
741 BOOST_REQUIRE_EQUAL( f4.dataSizeBytes(), ((payload_size + 5) *
sizeof(artdaq::RawDataType)) );
743 f4.resizeBytes( targetSize );
744 BOOST_REQUIRE_EQUAL( f4.dataSize(), (payload_size + 5) );
745 BOOST_REQUIRE_EQUAL( f4.dataSizeBytes(), ((payload_size + 5) *
sizeof(artdaq::RawDataType)) );
747 f4.resizeBytes( targetSize );
748 BOOST_REQUIRE_EQUAL( f4.dataSize(), (payload_size + 5) );
749 BOOST_REQUIRE_EQUAL( f4.dataSizeBytes(), ((payload_size + 5) *
sizeof(artdaq::RawDataType)) );
751 f4.resizeBytes( targetSize );
752 BOOST_REQUIRE_EQUAL( f4.dataSize(), (payload_size + 5) );
753 BOOST_REQUIRE_EQUAL( f4.dataSizeBytes(), ((payload_size + 5) *
sizeof(artdaq::RawDataType)) );
755 f4.resizeBytes( targetSize );
756 BOOST_REQUIRE_EQUAL( f4.dataSize(), (payload_size + 5) );
757 BOOST_REQUIRE_EQUAL( f4.dataSizeBytes(), ((payload_size + 5) *
sizeof(artdaq::RawDataType)) );
759 f4.resizeBytes( targetSize );
760 BOOST_REQUIRE_EQUAL( f4.dataSize(), (payload_size + 6) );
761 BOOST_REQUIRE_EQUAL( f4.dataSizeBytes(), ((payload_size + 6) *
sizeof(artdaq::RawDataType)) );
765 BOOST_REQUIRE_EQUAL( f5.size(), (payload_size + artdaq::detail::RawFragmentHeader::num_words()) );
766 BOOST_REQUIRE_EQUAL( f5.sizeBytes(), ((payload_size + artdaq::detail::RawFragmentHeader::num_words()) *
sizeof(artdaq::RawDataType)));
767 f5.setMetadata(theMetadata);
768 BOOST_REQUIRE_EQUAL( f5.dataSize(), payload_size );
769 BOOST_REQUIRE_EQUAL( f5.dataSizeBytes(), (payload_size *
sizeof(artdaq::RawDataType)) );
770 BOOST_REQUIRE_EQUAL( f5.size(), (payload_size + 1 + artdaq::detail::RawFragmentHeader::num_words()) );
771 BOOST_REQUIRE_EQUAL( f5.sizeBytes(), ((payload_size + 1 + artdaq::detail::RawFragmentHeader::num_words()) *
sizeof(artdaq::RawDataType)));
774 BOOST_AUTO_TEST_SUITE_END()