1 #include "artdaq-core/Data/Fragment.hh"
3 #define BOOST_TEST_MODULE(Fragment_t)
4 #include "cetlib/quiet_unit_test.hpp"
24 BOOST_AUTO_TEST_SUITE(Fragment_test)
26 BOOST_AUTO_TEST_CASE(Construct)
32 BOOST_REQUIRE_EQUAL(f1.dataSize(), (size_t) 0);
33 BOOST_REQUIRE_EQUAL(f1.size(), (size_t) 3);
34 BOOST_REQUIRE_EQUAL(f1.version(), (artdaq::Fragment::version_t) 0);
35 BOOST_REQUIRE_EQUAL(f1.type(), (artdaq::Fragment::type_t) 0);
36 BOOST_REQUIRE_EQUAL(f1.sequenceID(), (artdaq::Fragment::sequence_id_t) 0);
37 BOOST_REQUIRE_EQUAL(f1.fragmentID(), (artdaq::Fragment::fragment_id_t) 0);
38 BOOST_REQUIRE_EQUAL(f1.hasMetadata(),
false);
41 BOOST_REQUIRE_EQUAL(f2.dataSize(), (size_t) 7);
42 BOOST_REQUIRE_EQUAL(f2.size(), (size_t) 10);
43 BOOST_REQUIRE_EQUAL(f2.version(), (artdaq::Fragment::version_t) 0);
44 BOOST_REQUIRE(f2.type() == artdaq::Fragment::InvalidFragmentType);
45 BOOST_REQUIRE(f2.sequenceID() == artdaq::Fragment::InvalidSequenceID);
46 BOOST_REQUIRE(f2.fragmentID() == artdaq::Fragment::InvalidFragmentID);
47 BOOST_REQUIRE_EQUAL(f2.hasMetadata(),
false);
50 BOOST_REQUIRE_EQUAL(f3.dataSize(), (size_t) 0);
51 BOOST_REQUIRE_EQUAL(f3.size(), (size_t) 3);
52 BOOST_REQUIRE_EQUAL(f3.version(), (artdaq::Fragment::version_t) 0);
53 BOOST_REQUIRE(f3.type() == artdaq::Fragment::DataFragmentType);
54 BOOST_REQUIRE_EQUAL(f3.sequenceID(), (artdaq::Fragment::sequence_id_t) 101);
55 BOOST_REQUIRE_EQUAL(f3.fragmentID(), (artdaq::Fragment::fragment_id_t) 202);
56 BOOST_REQUIRE_EQUAL(f3.hasMetadata(),
false);
62 BOOST_REQUIRE(0 &&
"Should have thrown exception");
64 catch (cet::exception
const & excpt) {
67 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
72 BOOST_REQUIRE(0 &&
"Should have thrown exception");
74 catch (cet::exception
const & excpt) {
77 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
82 BOOST_REQUIRE(0 &&
"Should have thrown exception");
84 catch (cet::exception
const & excpt) {
87 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
92 BOOST_REQUIRE(0 &&
"Should have thrown exception");
94 catch (cet::exception
const & excpt) {
97 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
102 frag(101, 202, artdaq::detail::RawFragmentHeader::FIRST_SYSTEM_TYPE);
103 BOOST_REQUIRE(0 &&
"Should have thrown exception");
105 catch (cet::exception
const & excpt) {
108 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
113 frag(101, 202, artdaq::detail::RawFragmentHeader::LAST_SYSTEM_TYPE);
114 BOOST_REQUIRE(0 &&
"Should have thrown exception");
116 catch (cet::exception
const & excpt) {
119 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
124 fragA(101, 202, artdaq::detail::RawFragmentHeader::FIRST_USER_TYPE);
126 fragB(101, 202, artdaq::detail::RawFragmentHeader::LAST_USER_TYPE);
135 BOOST_REQUIRE(0 &&
"Should not have thrown exception");
139 BOOST_AUTO_TEST_CASE(FragmentType)
146 BOOST_REQUIRE(0 &&
"Should have thrown exception");
148 catch (cet::exception
const & excpt) {
151 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
155 frag.setUserType(225);
156 BOOST_REQUIRE(0 &&
"Should have thrown exception");
158 catch (cet::exception
const & excpt) {
161 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
165 frag.setUserType(255);
166 BOOST_REQUIRE(0 &&
"Should have thrown exception");
168 catch (cet::exception
const & excpt) {
171 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
175 frag.setUserType(artdaq::Fragment::InvalidFragmentType);
176 BOOST_REQUIRE(0 &&
"Should have thrown exception");
178 catch (cet::exception
const & excpt) {
181 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
185 frag.setUserType(artdaq::detail::RawFragmentHeader::FIRST_SYSTEM_TYPE);
186 BOOST_REQUIRE(0 &&
"Should have thrown exception");
188 catch (cet::exception
const & excpt) {
191 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
195 frag.setUserType(artdaq::detail::RawFragmentHeader::LAST_SYSTEM_TYPE);
196 BOOST_REQUIRE(0 &&
"Should have thrown exception");
198 catch (cet::exception
const & excpt) {
201 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
205 frag.setUserType(artdaq::detail::RawFragmentHeader::FIRST_USER_TYPE);
206 frag.setUserType(artdaq::detail::RawFragmentHeader::LAST_USER_TYPE);
207 frag.setUserType( 1);
208 frag.setUserType( 2);
209 frag.setUserType( 3);
210 frag.setUserType(100);
211 frag.setUserType(200);
212 frag.setUserType(224);
215 BOOST_REQUIRE(0 &&
"Should not have thrown exception");
220 frag.setSystemType(0);
221 BOOST_REQUIRE(0 &&
"Should have thrown exception");
223 catch (cet::exception
const & excpt) {
226 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
230 frag.setSystemType(1);
231 BOOST_REQUIRE(0 &&
"Should have thrown exception");
233 catch (cet::exception
const & excpt) {
236 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
240 frag.setSystemType(224);
241 BOOST_REQUIRE(0 &&
"Should have thrown exception");
243 catch (cet::exception
const & excpt) {
246 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
250 frag.setSystemType(artdaq::Fragment::InvalidFragmentType);
251 BOOST_REQUIRE(0 &&
"Should have thrown exception");
253 catch (cet::exception
const & excpt) {
256 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
260 frag.setSystemType(artdaq::detail::RawFragmentHeader::FIRST_USER_TYPE);
261 BOOST_REQUIRE(0 &&
"Should have thrown exception");
263 catch (cet::exception
const & excpt) {
266 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
270 frag.setSystemType(artdaq::detail::RawFragmentHeader::LAST_USER_TYPE);
271 BOOST_REQUIRE(0 &&
"Should have thrown exception");
273 catch (cet::exception
const & excpt) {
276 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
280 frag.setSystemType(artdaq::detail::RawFragmentHeader::FIRST_SYSTEM_TYPE);
281 frag.setSystemType(artdaq::detail::RawFragmentHeader::LAST_SYSTEM_TYPE);
282 frag.setSystemType(225);
283 frag.setSystemType(230);
284 frag.setSystemType(240);
285 frag.setSystemType(250);
286 frag.setSystemType(255);
289 BOOST_REQUIRE(0 &&
"Should not have thrown exception");
293 BOOST_AUTO_TEST_CASE(SequenceID)
297 BOOST_REQUIRE_EQUAL(f1.sequenceID(), (uint64_t)0);
299 BOOST_REQUIRE_EQUAL(f1.sequenceID(), (uint64_t)1);
300 f1.setSequenceID(0xffff);
301 BOOST_REQUIRE_EQUAL(f1.sequenceID(), (uint64_t)0xffff);
302 f1.setSequenceID(0x0000ffffffffffff);
303 BOOST_REQUIRE_EQUAL(f1.sequenceID(), (uint64_t)0x0000ffffffffffff);
306 BOOST_REQUIRE_EQUAL(f2.sequenceID(), (uint64_t)0x12345);
309 BOOST_REQUIRE_EQUAL(f3.sequenceID(), (uint64_t)0x0000567812345678);
312 BOOST_AUTO_TEST_CASE(FragmentID)
316 BOOST_REQUIRE_EQUAL(f1.fragmentID(), (uint16_t)0);
318 BOOST_REQUIRE_EQUAL(f1.fragmentID(), (uint16_t)1);
319 f1.setFragmentID(0xffff);
320 BOOST_REQUIRE_EQUAL(f1.fragmentID(), (uint16_t)0xffff);
323 BOOST_REQUIRE_EQUAL(f2.fragmentID(), (uint16_t)0xab);
326 BOOST_REQUIRE_EQUAL(f3.fragmentID(), (uint16_t)0xffff);
329 BOOST_AUTO_TEST_CASE(Resize)
334 BOOST_REQUIRE_EQUAL(f1.dataSize(), (size_t) 1234);
335 BOOST_REQUIRE_EQUAL(f1.size(), (size_t) 1234 +
336 artdaq::detail::RawFragmentHeader::num_words());
342 BOOST_REQUIRE_EQUAL(f2.dataSize(), (size_t) 129);
343 BOOST_REQUIRE_EQUAL(f2.size(), (size_t) 129 + 2 +
344 artdaq::detail::RawFragmentHeader::num_words());
347 BOOST_AUTO_TEST_CASE(Empty)
350 BOOST_REQUIRE_EQUAL(f1.empty(),
true);
352 BOOST_REQUIRE_EQUAL(f1.empty(),
false);
356 BOOST_REQUIRE_EQUAL(f2.empty(),
false);
358 BOOST_REQUIRE_EQUAL(f2.empty(),
false);
360 BOOST_REQUIRE_EQUAL(f2.empty(),
true);
361 BOOST_REQUIRE_EQUAL(f2.dataSize(), (size_t) 0);
362 BOOST_REQUIRE_EQUAL(f2.size(), (size_t) 2 +
363 artdaq::detail::RawFragmentHeader::num_words());
366 BOOST_REQUIRE_EQUAL(f3.empty(),
true);
367 f3.setMetadata(mdOneA);
368 BOOST_REQUIRE_EQUAL(f3.empty(),
true);
371 BOOST_REQUIRE_EQUAL(f4.empty(),
false);
372 f4.setMetadata(mdOneA);
373 BOOST_REQUIRE_EQUAL(f4.empty(),
false);
376 BOOST_AUTO_TEST_CASE(Clear)
379 BOOST_REQUIRE_EQUAL(f1.empty(),
true);
381 BOOST_REQUIRE_EQUAL(f1.empty(),
false);
383 BOOST_REQUIRE_EQUAL(f1.empty(),
true);
387 BOOST_REQUIRE_EQUAL(f2.empty(),
false);
389 BOOST_REQUIRE_EQUAL(f2.empty(),
false);
391 BOOST_REQUIRE_EQUAL(f2.empty(),
true);
392 BOOST_REQUIRE_EQUAL(f2.dataSize(), (size_t) 0);
393 BOOST_REQUIRE_EQUAL(f2.size(), (size_t) 2 +
394 artdaq::detail::RawFragmentHeader::num_words());
397 BOOST_REQUIRE_EQUAL(f3.empty(),
true);
398 BOOST_REQUIRE_EQUAL(f3.hasMetadata(),
false);
399 f3.setMetadata(mdOneA);
400 BOOST_REQUIRE_EQUAL(f3.empty(),
true);
401 BOOST_REQUIRE_EQUAL(f3.hasMetadata(),
true);
403 BOOST_REQUIRE_EQUAL(f3.empty(),
true);
404 BOOST_REQUIRE_EQUAL(f3.hasMetadata(),
true);
407 BOOST_REQUIRE_EQUAL(f4.empty(),
false);
408 BOOST_REQUIRE_EQUAL(f4.hasMetadata(),
false);
409 f4.setMetadata(mdOneA);
410 BOOST_REQUIRE_EQUAL(f4.empty(),
false);
411 BOOST_REQUIRE_EQUAL(f4.hasMetadata(),
true);
413 BOOST_REQUIRE_EQUAL(f4.empty(),
true);
414 BOOST_REQUIRE_EQUAL(f4.hasMetadata(),
true);
417 BOOST_AUTO_TEST_CASE(Addresses)
421 BOOST_REQUIRE_EQUAL(f1.dataSize(), (size_t) 200);
422 BOOST_REQUIRE_EQUAL(f1.size(), (size_t) 200 +
423 artdaq::detail::RawFragmentHeader::num_words());
424 artdaq::RawDataType* haddr = f1.headerAddress();
425 artdaq::RawDataType* daddr = f1.dataAddress();
426 BOOST_REQUIRE_EQUAL(daddr,
427 (haddr + artdaq::detail::RawFragmentHeader::num_words()));
429 f1.metadataAddress();
430 BOOST_REQUIRE(0 &&
"Should have thrown exception");
432 catch (cet::exception
const & excpt) {
435 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
437 BOOST_REQUIRE_EQUAL(haddr, &(*(f1.headerBegin())));
438 BOOST_REQUIRE_EQUAL(daddr, &(*(f1.dataBegin())));
439 BOOST_REQUIRE_EQUAL(daddr+200, &(*(f1.dataEnd())));
444 BOOST_REQUIRE_EQUAL(f2.dataSize(), (size_t) 135);
445 BOOST_REQUIRE_EQUAL(f2.size(), (size_t) 135 + 2 +
446 artdaq::detail::RawFragmentHeader::num_words());
447 haddr = f2.headerAddress();
448 daddr = f2.dataAddress();
449 artdaq::RawDataType* maddr = f2.metadataAddress();
450 BOOST_REQUIRE_EQUAL(maddr, haddr +
451 artdaq::detail::RawFragmentHeader::num_words());
452 BOOST_REQUIRE_EQUAL(daddr, maddr + 2);
453 BOOST_REQUIRE_EQUAL(haddr, &(*(f2.headerBegin())));
454 BOOST_REQUIRE_EQUAL(daddr, &(*(f2.dataBegin())));
455 BOOST_REQUIRE_EQUAL(daddr+135, &(*(f2.dataEnd())));
460 BOOST_REQUIRE_EQUAL(f3.dataSize(), (size_t) 77);
461 BOOST_REQUIRE_EQUAL(f3.size(), (size_t) 77 + 4 +
462 artdaq::detail::RawFragmentHeader::num_words());
463 haddr = f3.headerAddress();
464 daddr = f3.dataAddress();
465 maddr = f3.metadataAddress();
466 BOOST_REQUIRE_EQUAL(maddr, haddr +
467 artdaq::detail::RawFragmentHeader::num_words());
468 BOOST_REQUIRE_EQUAL(daddr, maddr + 4);
469 BOOST_REQUIRE_EQUAL(haddr, &(*(f3.headerBegin())));
470 BOOST_REQUIRE_EQUAL(daddr, &(*(f3.dataBegin())));
471 BOOST_REQUIRE_EQUAL(daddr+77, &(*(f3.dataEnd())));
474 BOOST_AUTO_TEST_CASE(Metadata)
477 BOOST_REQUIRE_EQUAL(f1.hasMetadata(),
false);
480 BOOST_REQUIRE(0 &&
"Should have thrown exception");
482 catch (cet::exception
const & excpt) {
485 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
494 f1.updateMetadata(mdOneA);
495 BOOST_REQUIRE(0 &&
"Should have thrown exception");
497 catch (cet::exception
const & excpt) {
500 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
504 f1.setMetadata(mdOneA);
506 BOOST_REQUIRE_EQUAL(mdOnePtr->field1, (uint64_t) 5);
507 BOOST_REQUIRE_EQUAL(mdOnePtr->field2, (uint32_t)10);
508 BOOST_REQUIRE_EQUAL(mdOnePtr->field3, (uint32_t)15);
512 f1.setMetadata(mdOneB);
513 BOOST_REQUIRE(0 &&
"Should have thrown exception");
515 catch (cet::exception
const & excpt) {
518 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
521 f1.updateMetadata( *mdOnePtr );
531 f1.updateMetadata(mdTwoA);
532 BOOST_REQUIRE(0 &&
"Should have thrown exception");
534 catch (cet::exception
const & excpt) {
537 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
542 BOOST_REQUIRE_EQUAL(mdTwoPtr->field1, (uint64_t)10);
543 BOOST_REQUIRE_EQUAL(mdTwoPtr->field2, (uint32_t)20);
544 BOOST_REQUIRE_EQUAL(mdTwoPtr->field3, (uint32_t)30);
545 BOOST_REQUIRE_EQUAL(mdTwoPtr->field4, (uint32_t)40);
546 BOOST_REQUIRE_EQUAL(mdTwoPtr->field5, (uint32_t)50);
549 BOOST_REQUIRE_EQUAL(f3.sequenceID(), (uint32_t)0xabcdef);
550 BOOST_REQUIRE_EQUAL(f3.fragmentID(), (uint16_t)0xc3a5);
551 BOOST_REQUIRE_EQUAL(f3.type(), (uint16_t)123);
553 BOOST_REQUIRE_EQUAL(f3.sequenceID(), (uint32_t)0xabcdef);
554 BOOST_REQUIRE_EQUAL(f3.fragmentID(), (uint16_t)0xc3a5);
555 BOOST_REQUIRE_EQUAL(f3.type(), (uint8_t) 123);
556 artdaq::RawDataType * dataPtr = f3.dataAddress();
557 dataPtr[0] = 0x12345678;
559 dataPtr[2] = 0x456789ab;
560 dataPtr[3] = 0x3c3c3c3c;
561 dataPtr[4] = 0x5a5a5a5a;
562 BOOST_REQUIRE_EQUAL(dataPtr[0], (uint64_t)0x12345678);
563 BOOST_REQUIRE_EQUAL(dataPtr[1], (uint64_t)0xabcd);
564 BOOST_REQUIRE_EQUAL(dataPtr[2], (uint64_t)0x456789ab);
565 BOOST_REQUIRE_EQUAL(dataPtr[3], (uint64_t)0x3c3c3c3c);
566 BOOST_REQUIRE_EQUAL(dataPtr[4], (uint64_t)0x5a5a5a5a);
567 BOOST_REQUIRE_EQUAL(f3.sequenceID(), (uint32_t)0xabcdef);
568 BOOST_REQUIRE_EQUAL(f3.fragmentID(), (uint16_t)0xc3a5);
569 BOOST_REQUIRE_EQUAL(f3.type(), (uint8_t) 123);
574 f3.setMetadata(mdOneC);
576 BOOST_REQUIRE_EQUAL(mdOnePtr->field1, (uint64_t)505);
577 BOOST_REQUIRE_EQUAL(mdOnePtr->field2, (uint32_t)510);
578 BOOST_REQUIRE_EQUAL(mdOnePtr->field3, (uint32_t)515);
579 BOOST_REQUIRE_EQUAL(f3.sequenceID(), (uint32_t)0xabcdef);
580 BOOST_REQUIRE_EQUAL(f3.fragmentID(), (uint16_t)0xc3a5);
581 BOOST_REQUIRE_EQUAL(f3.type(), (uint8_t) 123);
582 dataPtr = f3.dataAddress();
583 dataPtr[0] = 0x12345678;
585 dataPtr[2] = 0x456789ab;
586 dataPtr[3] = 0x3c3c3c3c;
587 dataPtr[4] = 0x5a5a5a5a;
588 BOOST_REQUIRE_EQUAL(dataPtr[0], (uint64_t)0x12345678);
589 BOOST_REQUIRE_EQUAL(dataPtr[1], (uint64_t)0xabcd);
590 BOOST_REQUIRE_EQUAL(dataPtr[2], (uint64_t)0x456789ab);
591 BOOST_REQUIRE_EQUAL(dataPtr[3], (uint64_t)0x3c3c3c3c);
592 BOOST_REQUIRE_EQUAL(dataPtr[4], (uint64_t)0x5a5a5a5a);
596 BOOST_REQUIRE_EQUAL(f4.hasMetadata(),
false);
598 f4.setMetadata(mdHuge);
599 BOOST_REQUIRE(0 &&
"Should have thrown exception");
601 catch (cet::exception
const & excpt) {
604 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
609 BOOST_REQUIRE(0 &&
"Should have thrown exception");
611 catch (cet::exception
const & excpt) {
614 BOOST_REQUIRE(0 &&
"Should have thrown cet::exception");
622 BOOST_AUTO_TEST_CASE(Bytes) {
624 std::size_t payload_size = 5;
627 artdaq::Fragment::sequence_id_t seqID = 1;
628 artdaq::Fragment::fragment_id_t fragID = 1;
629 artdaq::Fragment::type_t type = 3;
640 Metadata theMetadata;
642 BOOST_REQUIRE(
sizeof( artdaq::Fragment::byte_t) == 1);
645 BOOST_REQUIRE(
sizeof( artdaq::RawDataType) == 8);
653 std::unique_ptr<artdaq::Fragment> f1_factory(artdaq::Fragment::FragmentBytes(
654 payload_size *
sizeof( artdaq::RawDataType ) ) );
656 BOOST_REQUIRE( f1->size() == f1_factory->size() );
657 BOOST_REQUIRE( f1->sizeBytes() == f1_factory->sizeBytes() );
659 std::unique_ptr<artdaq::Fragment> f2(
new artdaq::Fragment( payload_size, seqID, fragID, type, theMetadata) );
660 std::unique_ptr<artdaq::Fragment> f2_factory( artdaq::Fragment::FragmentBytes(
661 payload_size *
sizeof( artdaq::RawDataType ),
663 type, theMetadata) );
665 BOOST_REQUIRE( f2->size() == f2_factory->size() );
666 BOOST_REQUIRE( f2->sizeBytes() == f2_factory->sizeBytes() );
671 std::size_t offset = 3;
672 std::unique_ptr<artdaq::Fragment> f3_factory( artdaq::Fragment::FragmentBytes(
673 payload_size *
sizeof( artdaq::RawDataType ) - offset,
675 type, theMetadata) );
677 BOOST_REQUIRE( f3_factory->size() == f2->size() );
678 BOOST_REQUIRE( f3_factory->sizeBytes() == f2->sizeBytes() );
684 artdaq::Fragment::byte_t* ptr1 =
reinterpret_cast<artdaq::Fragment::byte_t*
>(
685 &*f3_factory->dataBegin());
687 artdaq::Fragment::byte_t* ptr2 = f3_factory->dataBeginBytes();
689 artdaq::Fragment::byte_t* ptr3 =
reinterpret_cast<artdaq::Fragment::byte_t*
>( f3_factory->dataAddress() );
691 BOOST_REQUIRE_EQUAL( ptr1, ptr2 );
692 BOOST_REQUIRE_EQUAL( ptr2, ptr3 );
696 BOOST_REQUIRE( f3_factory->dataBeginBytes() -
697 reinterpret_cast<artdaq::Fragment::byte_t*
>(
698 &*f3_factory->headerBegin() )
699 == 4 *
sizeof(artdaq::RawDataType) );
702 BOOST_REQUIRE( static_cast<std::size_t>( f3_factory->dataEndBytes() - f3_factory->dataBeginBytes() ) == f3_factory->dataSizeBytes() );
706 BOOST_REQUIRE_EQUAL( f4.dataSize(), payload_size );
707 BOOST_REQUIRE_EQUAL( f4.dataSizeBytes(), (payload_size *
sizeof(artdaq::RawDataType)) );
708 f4.resize( payload_size + 1 );
709 BOOST_REQUIRE_EQUAL( f4.dataSize(), (payload_size + 1) );
710 BOOST_REQUIRE_EQUAL( f4.dataSizeBytes(), ((payload_size + 1) *
sizeof(artdaq::RawDataType)) );
711 f4.resizeBytes( f4.dataSizeBytes() + 2 );
712 BOOST_REQUIRE_EQUAL( f4.dataSize(), (payload_size + 2) );
713 BOOST_REQUIRE_EQUAL( f4.dataSizeBytes(), ((payload_size + 2) *
sizeof(artdaq::RawDataType)) );
714 f4.resizeBytes( f4.dataSizeBytes() + 1 );
715 BOOST_REQUIRE_EQUAL( f4.dataSize(), (payload_size + 3) );
716 BOOST_REQUIRE_EQUAL( f4.dataSizeBytes(), ((payload_size + 3) *
sizeof(artdaq::RawDataType)) );
717 f4.resizeBytes( f4.dataSizeBytes() + 1 );
718 BOOST_REQUIRE_EQUAL( f4.dataSize(), (payload_size + 4) );
719 BOOST_REQUIRE_EQUAL( f4.dataSizeBytes(), ((payload_size + 4) *
sizeof(artdaq::RawDataType)) );
721 size_t targetSize = (payload_size + 4) *
sizeof(artdaq::RawDataType);
723 f4.resizeBytes( targetSize );
724 BOOST_REQUIRE_EQUAL( f4.dataSize(), (payload_size + 5) );
725 BOOST_REQUIRE_EQUAL( f4.dataSizeBytes(), ((payload_size + 5) *
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 + 6) );
757 BOOST_REQUIRE_EQUAL( f4.dataSizeBytes(), ((payload_size + 6) *
sizeof(artdaq::RawDataType)) );
761 BOOST_REQUIRE_EQUAL( f5.size(), (payload_size + artdaq::detail::RawFragmentHeader::num_words()) );
762 BOOST_REQUIRE_EQUAL( f5.sizeBytes(), ((payload_size + artdaq::detail::RawFragmentHeader::num_words()) *
sizeof(artdaq::RawDataType)));
763 f5.setMetadata(theMetadata);
764 BOOST_REQUIRE_EQUAL( f5.dataSize(), payload_size );
765 BOOST_REQUIRE_EQUAL( f5.dataSizeBytes(), (payload_size *
sizeof(artdaq::RawDataType)) );
766 BOOST_REQUIRE_EQUAL( f5.size(), (payload_size + 1 + artdaq::detail::RawFragmentHeader::num_words()) );
767 BOOST_REQUIRE_EQUAL( f5.sizeBytes(), ((payload_size + 1 + artdaq::detail::RawFragmentHeader::num_words()) *
sizeof(artdaq::RawDataType)));
770 BOOST_AUTO_TEST_SUITE_END()