19 #define BOOST_TEST_DYN_LINK
20 #define BOOST_TEST_MODULE TransferElementTest
21 #include <boost/test/unit_test.hpp>
22 using namespace boost::unit_test_framework;
29 #include <boost/make_shared.hpp>
44 ret = accessor.readNonBlocking();
45 BOOST_CHECK(ret ==
true);
47 accessor.resetCounters();
48 ret = accessor.readLatest();
49 BOOST_CHECK(ret ==
true);
63 std::atomic<bool> readCompleted{
false};
69 BOOST_CHECK(!readCompleted);
86 BOOST_CHECK(accessor.readNonBlocking() ==
false);
88 BOOST_CHECK(accessor.readNonBlocking() ==
true);
89 BOOST_CHECK(accessor.readNonBlocking() ==
false);
92 BOOST_CHECK(accessor.readNonBlocking() ==
true);
93 BOOST_CHECK(accessor.readNonBlocking() ==
true);
94 BOOST_CHECK(accessor.readNonBlocking() ==
false);
113 ret = accessor.readLatest();
114 BOOST_CHECK(ret ==
true);
115 BOOST_CHECK_EQUAL(accessor._readTransfer_counter, 1);
116 BOOST_CHECK_EQUAL(accessor._postRead_counter, 1);
119 asyncAccessor.resetCounters();
120 ret = asyncAccessor.readLatest();
121 BOOST_CHECK(ret ==
false);
122 BOOST_CHECK_EQUAL(asyncAccessor._postRead_counter, 1);
124 asyncAccessor.resetCounters();
125 asyncAccessor.push();
126 ret = asyncAccessor.readLatest();
127 BOOST_CHECK(ret ==
true);
128 BOOST_CHECK_EQUAL(asyncAccessor._postRead_counter, 2);
130 asyncAccessor.resetCounters();
131 ret = asyncAccessor.readLatest();
132 BOOST_CHECK(ret ==
false);
133 BOOST_CHECK_EQUAL(asyncAccessor._postRead_counter, 1);
135 asyncAccessor.resetCounters();
136 while(asyncAccessor.push())
continue;
137 ret = asyncAccessor.readLatest();
138 BOOST_CHECK(ret ==
true);
139 BOOST_CHECK_EQUAL(asyncAccessor._postRead_counter, 4);
141 asyncAccessor.resetCounters();
142 ret = asyncAccessor.readLatest();
143 BOOST_CHECK(ret ==
false);
144 BOOST_CHECK_EQUAL(asyncAccessor._postRead_counter, 1);
152 #define TEST_TRANSFER_SEQUENCE(transferElement, expectedType, expectTransferExecution) \
153 assert(expectedType != TransferType::readLatest); \
156 if((expectedType == TransferType::read || expectedType == TransferType::readNonBlocking)) { \
157 BOOST_CHECK_EQUAL(transferElement._preRead_counter, 1); \
158 if(expectTransferExecution) { \
159 BOOST_CHECK_EQUAL(transferElement._readTransfer_counter, 1); \
162 BOOST_CHECK_EQUAL(transferElement._readTransfer_counter, 0); \
164 BOOST_CHECK_EQUAL(transferElement._postRead_counter, 1); \
168 if(expectedType == TransferType::write) { \
169 BOOST_CHECK_EQUAL(transferElement._preWrite_counter, 1); \
170 if(expectTransferExecution) { \
171 BOOST_CHECK_EQUAL(transferElement._writeTransfer_counter, 1); \
174 BOOST_CHECK_EQUAL(transferElement._writeTransfer_counter, 0); \
176 BOOST_CHECK_EQUAL(transferElement._postWrite_counter, 1); \
180 if(expectedType == TransferType::writeDestructively) { \
181 BOOST_CHECK_EQUAL(transferElement._preWrite_counter, 1); \
182 if(expectTransferExecution) { \
183 BOOST_CHECK_EQUAL(transferElement._writeTransferDestructively_counter, 1); \
186 BOOST_CHECK_EQUAL(transferElement._writeTransferDestructively_counter, 0); \
188 BOOST_CHECK_EQUAL(transferElement._postWrite_counter, 1); \
192 BOOST_CHECK_EQUAL(transferElement._preIndex, 0); \
193 if(expectTransferExecution) { \
194 BOOST_CHECK_EQUAL(transferElement._transferIndex, 1); \
195 BOOST_CHECK_EQUAL(transferElement._postIndex, 2); \
198 BOOST_CHECK_EQUAL(transferElement._postIndex, 1); \
202 BOOST_CHECK(transferElement._transferType_pre == expectedType); \
203 BOOST_CHECK(transferElement._transferType_post == expectedType)
219 accessor.resetCounters();
220 accessor.readNonBlocking();
222 accessor.resetCounters();
227 accessor.resetCounters();
231 accessor.resetCounters();
232 accessor.writeDestructively();
235 accessor.resetCounters();
236 accessor.writeDestructively();
248 accessor.resetCounters();
249 accessor.readNonBlocking();
264 accessor.preRead(TransferType::read);
265 BOOST_CHECK_EQUAL(accessor._preRead_counter, 1);
266 BOOST_CHECK(accessor._transferType_pre == TransferType::read);
267 accessor.readTransfer();
268 accessor.postRead(TransferType::read,
true);
270 accessor.resetCounters();
271 accessor.preRead(TransferType::readNonBlocking);
272 BOOST_CHECK_EQUAL(accessor._preRead_counter, 1);
273 BOOST_CHECK(accessor._transferType_pre == TransferType::readNonBlocking);
274 accessor.readTransfer();
275 accessor.postRead(TransferType::readNonBlocking,
true);
278 accessor.resetCounters();
279 accessor.preWrite(TransferType::write, v);
280 BOOST_CHECK_EQUAL(accessor._preWrite_counter, 1);
281 BOOST_CHECK(accessor._transferType_pre == TransferType::write);
282 BOOST_CHECK(accessor._preWrite_version == v);
283 accessor.writeTransfer(v);
284 accessor.postWrite(TransferType::write, v);
287 accessor.resetCounters();
288 accessor.preWrite(TransferType::writeDestructively, v);
289 BOOST_CHECK_EQUAL(accessor._preWrite_counter, 1);
290 BOOST_CHECK(accessor._transferType_pre == TransferType::writeDestructively);
291 BOOST_CHECK(accessor._preWrite_version == v);
292 accessor.writeTransfer(v);
293 accessor.postWrite(TransferType::writeDestructively, v);
307 accessor.preRead(TransferType::read);
308 std::atomic<bool> readCompleted{
false};
310 accessor.readTransfer();
311 readCompleted =
true;
314 BOOST_CHECK(!readCompleted);
317 accessor.postRead(TransferType::read,
true);
323 accessor.preRead(TransferType::read);
324 BOOST_CHECK_EQUAL(accessor._readTransfer_counter, 0);
325 accessor.readTransfer();
326 BOOST_CHECK_EQUAL(accessor._readTransfer_counter, 1);
327 accessor.postRead(TransferType::read,
true);
342 accessor.preRead(TransferType::readNonBlocking);
343 BOOST_CHECK(accessor.readTransferNonBlocking() ==
false);
344 accessor.postRead(TransferType::readNonBlocking,
true);
346 accessor.resetCounters();
348 accessor.preRead(TransferType::readNonBlocking);
349 BOOST_CHECK(accessor.readTransferNonBlocking() ==
true);
350 accessor.postRead(TransferType::readNonBlocking,
true);
356 accessor.preRead(TransferType::readNonBlocking);
357 BOOST_CHECK_EQUAL(accessor._readTransfer_counter, 0);
358 BOOST_CHECK(accessor.readTransferNonBlocking() ==
true);
359 BOOST_CHECK_EQUAL(accessor._readTransfer_counter, 1);
360 accessor.postRead(TransferType::readNonBlocking,
true);
374 accessor.resetCounters();
376 accessor.preWrite(TransferType::write, v);
377 BOOST_CHECK_EQUAL(accessor._writeTransfer_counter, 0);
378 accessor.writeTransfer(v);
379 BOOST_CHECK_EQUAL(accessor._writeTransfer_counter, 1);
380 BOOST_CHECK(accessor._writeTransfer_version == v);
381 accessor.postWrite(TransferType::write, v);
383 accessor.resetCounters();
385 accessor.preWrite(TransferType::writeDestructively, v);
386 BOOST_CHECK_EQUAL(accessor._writeTransferDestructively_counter, 0);
387 accessor.writeTransferDestructively(v);
388 BOOST_CHECK_EQUAL(accessor._writeTransferDestructively_counter, 1);
389 BOOST_CHECK(accessor._writeTransfer_version == v);
390 accessor.postWrite(TransferType::writeDestructively, v);
403 accessor.preRead(TransferType::read);
404 accessor.readTransfer();
405 BOOST_CHECK_EQUAL(accessor._postRead_counter, 0);
406 accessor.postRead(TransferType::read,
true);
407 BOOST_CHECK_EQUAL(accessor._postRead_counter, 1);
408 BOOST_CHECK(accessor._transferType_post == TransferType::read);
409 BOOST_CHECK(accessor._updateDataBuffer ==
true);
411 accessor.resetCounters();
412 accessor.preRead(TransferType::read);
413 accessor.readTransfer();
414 BOOST_CHECK_EQUAL(accessor._postRead_counter, 0);
415 accessor.postRead(TransferType::read,
false);
416 BOOST_CHECK_EQUAL(accessor._postRead_counter, 1);
417 BOOST_CHECK(accessor._transferType_post == TransferType::read);
418 BOOST_CHECK(accessor._updateDataBuffer ==
false);
420 accessor.resetCounters();
421 accessor.preRead(TransferType::readNonBlocking);
422 accessor.readTransferNonBlocking();
423 BOOST_CHECK_EQUAL(accessor._postRead_counter, 0);
424 accessor.postRead(TransferType::readNonBlocking,
true);
425 BOOST_CHECK_EQUAL(accessor._postRead_counter, 1);
426 BOOST_CHECK(accessor._transferType_post == TransferType::readNonBlocking);
427 BOOST_CHECK(accessor._updateDataBuffer ==
true);
429 accessor.resetCounters();
430 accessor.preRead(TransferType::readNonBlocking);
431 accessor.readTransferNonBlocking();
432 BOOST_CHECK_EQUAL(accessor._postRead_counter, 0);
433 accessor.postRead(TransferType::readNonBlocking,
false);
434 BOOST_CHECK_EQUAL(accessor._postRead_counter, 1);
435 BOOST_CHECK(accessor._transferType_post == TransferType::readNonBlocking);
436 BOOST_CHECK(accessor._updateDataBuffer ==
false);
450 accessor.preWrite(TransferType::write, v1);
451 accessor.writeTransfer(v1);
452 BOOST_CHECK(accessor.getVersionNumber() ==
VersionNumber(
nullptr));
453 accessor.postWrite(TransferType::write, v1);
454 BOOST_CHECK(accessor.getVersionNumber() == v1);
469 accessor._throwLogicErr =
true;
471 BOOST_CHECK_EQUAL(accessor._preRead_counter, 1);
472 BOOST_CHECK_EQUAL(accessor._postRead_counter, 1);
474 accessor.resetCounters();
475 accessor._throwRuntimeErrInPre =
true;
477 BOOST_CHECK_EQUAL(accessor._preRead_counter, 1);
478 BOOST_CHECK_EQUAL(accessor._postRead_counter, 1);
480 accessor.resetCounters();
481 accessor._throwRuntimeErrInTransfer =
true;
483 BOOST_CHECK_EQUAL(accessor._preRead_counter, 1);
484 BOOST_CHECK_EQUAL(accessor._postRead_counter, 1);
487 accessor.resetCounters();
488 accessor._throwLogicErr =
true;
490 BOOST_CHECK_EQUAL(accessor._preRead_counter, 1);
491 BOOST_CHECK_EQUAL(accessor._postRead_counter, 1);
493 accessor.resetCounters();
494 accessor._throwRuntimeErrInPre =
true;
496 BOOST_CHECK_EQUAL(accessor._preRead_counter, 1);
497 BOOST_CHECK_EQUAL(accessor._postRead_counter, 1);
499 accessor.resetCounters();
500 accessor._throwRuntimeErrInTransfer =
true;
502 BOOST_CHECK_EQUAL(accessor._preRead_counter, 1);
503 BOOST_CHECK_EQUAL(accessor._postRead_counter, 1);
506 accessor.resetCounters();
507 accessor._throwLogicErr =
true;
509 BOOST_CHECK_EQUAL(accessor._preWrite_counter, 1);
510 BOOST_CHECK_EQUAL(accessor._postWrite_counter, 1);
512 accessor.resetCounters();
513 accessor._throwRuntimeErrInPre =
true;
515 BOOST_CHECK_EQUAL(accessor._preWrite_counter, 1);
516 BOOST_CHECK_EQUAL(accessor._postWrite_counter, 1);
518 accessor.resetCounters();
519 accessor._throwRuntimeErrInTransfer =
true;
521 BOOST_CHECK_EQUAL(accessor._preWrite_counter, 1);
522 BOOST_CHECK_EQUAL(accessor._postWrite_counter, 1);
525 accessor.resetCounters();
526 accessor._throwLogicErr =
true;
528 BOOST_CHECK_EQUAL(accessor._preWrite_counter, 1);
529 BOOST_CHECK_EQUAL(accessor._postWrite_counter, 1);
531 accessor.resetCounters();
532 accessor._throwRuntimeErrInPre =
true;
534 BOOST_CHECK_EQUAL(accessor._preWrite_counter, 1);
535 BOOST_CHECK_EQUAL(accessor._postWrite_counter, 1);
537 accessor.resetCounters();
538 accessor._throwRuntimeErrInTransfer =
true;
540 BOOST_CHECK_EQUAL(accessor._preWrite_counter, 1);
541 BOOST_CHECK_EQUAL(accessor._postWrite_counter, 1);
549 accessor._throwLogicErr =
true;
551 BOOST_CHECK_EQUAL(accessor._preRead_counter, 1);
552 BOOST_CHECK_EQUAL(accessor._postRead_counter, 1);
554 accessor.resetCounters();
555 accessor._throwRuntimeErrInPre =
true;
557 BOOST_CHECK_EQUAL(accessor._preRead_counter, 1);
558 BOOST_CHECK_EQUAL(accessor._postRead_counter, 1);
560 accessor.resetCounters();
561 accessor.putRuntimeErrorOnQueue();
563 BOOST_CHECK_EQUAL(accessor._preRead_counter, 1);
564 BOOST_CHECK_EQUAL(accessor._postRead_counter, 1);
567 accessor.resetCounters();
568 accessor._throwLogicErr =
true;
570 BOOST_CHECK_EQUAL(accessor._preRead_counter, 1);
571 BOOST_CHECK_EQUAL(accessor._postRead_counter, 1);
573 accessor.resetCounters();
574 accessor._throwRuntimeErrInPre =
true;
576 BOOST_CHECK_EQUAL(accessor._preRead_counter, 1);
577 BOOST_CHECK_EQUAL(accessor._postRead_counter, 1);
579 accessor.resetCounters();
580 accessor.putRuntimeErrorOnQueue();
582 BOOST_CHECK_EQUAL(accessor._preRead_counter, 1);
583 BOOST_CHECK_EQUAL(accessor._postRead_counter, 1);
598 accessor.preRead(TransferType::read);
599 accessor.preRead(TransferType::read);
600 accessor.preRead(TransferType::read);
601 accessor.readTransfer();
602 accessor.postRead(TransferType::read,
true);
603 accessor.postRead(TransferType::read,
true);
604 accessor.postRead(TransferType::read,
true);
605 BOOST_CHECK_EQUAL(accessor._preRead_counter, 1);
606 BOOST_CHECK_EQUAL(accessor._postRead_counter, 1);
609 accessor.resetCounters();
611 accessor.preWrite(TransferType::write, v);
612 accessor.preWrite(TransferType::write, v);
613 accessor.preWrite(TransferType::write, v);
614 accessor.writeTransfer(v);
615 accessor.postWrite(TransferType::write, v);
616 accessor.postWrite(TransferType::write, v);
617 accessor.postWrite(TransferType::write, v);
618 BOOST_CHECK_EQUAL(accessor._preWrite_counter, 1);
619 BOOST_CHECK_EQUAL(accessor._postWrite_counter, 1);
636 accessor._throwLogicErr =
true;
638 BOOST_CHECK_EQUAL(accessor._readTransfer_counter, 0);
640 accessor.resetCounters();
641 accessor._throwRuntimeErrInPre =
true;
643 BOOST_CHECK_EQUAL(accessor._readTransfer_counter, 0);
646 accessor.resetCounters();
647 accessor._throwLogicErr =
true;
649 BOOST_CHECK_EQUAL(accessor._readTransfer_counter, 0);
651 accessor.resetCounters();
652 accessor._throwRuntimeErrInPre =
true;
654 BOOST_CHECK_EQUAL(accessor._readTransfer_counter, 0);
657 accessor.resetCounters();
658 accessor._throwLogicErr =
true;
660 BOOST_CHECK_EQUAL(accessor._writeTransfer_counter, 0);
662 accessor.resetCounters();
663 accessor._throwRuntimeErrInPre =
true;
665 BOOST_CHECK_EQUAL(accessor._writeTransfer_counter, 0);
668 accessor.resetCounters();
669 accessor._throwLogicErr =
true;
671 BOOST_CHECK_EQUAL(accessor._writeTransferDestructively_counter, 0);
673 accessor.resetCounters();
674 accessor._throwRuntimeErrInPre =
true;
676 BOOST_CHECK_EQUAL(accessor._writeTransferDestructively_counter, 0);
684 assert(accessor._readQueue.read_available() == 1);
687 accessor.resetCounters();
688 accessor._throwLogicErr =
true;
690 BOOST_CHECK_EQUAL(accessor._readQueue.read_available(), 1);
692 accessor.resetCounters();
693 accessor._throwRuntimeErrInPre =
true;
695 BOOST_CHECK_EQUAL(accessor._readQueue.read_available(), 1);
698 accessor.resetCounters();
699 accessor._throwLogicErr =
true;
701 BOOST_CHECK_EQUAL(accessor._readQueue.read_available(), 1);
703 accessor.resetCounters();
704 accessor._throwRuntimeErrInPre =
true;
706 BOOST_CHECK_EQUAL(accessor._readQueue.read_available(), 1);
718 std::exception_ptr myException;
732 accessor.resetCounters();
733 accessor._throwRuntimeErrInPre =
true;
735 accessor.postRead(TransferType::read,
false);
739 accessor.resetCounters();
740 accessor._throwRuntimeErrInPre =
true;
742 accessor.postWrite(TransferType::write, {});
746 accessor.resetCounters();
747 accessor._throwRuntimeErrInTransfer =
true;
750 accessor.preRead(TransferType::read);
754 myException = std::exception_ptr{
nullptr};
756 accessor.readTransfer();
757 BOOST_ERROR(
"readTransfer() must throw a ChimeraTK::runtime_error");
760 myException = std::current_exception();
764 accessor.postRead(TransferType::read,
false);
768 accessor.resetCounters();
769 accessor._throwRuntimeErrInTransfer =
true;
772 accessor.preRead(TransferType::readNonBlocking);
776 myException = std::exception_ptr{
nullptr};
778 accessor.readTransferNonBlocking();
779 BOOST_ERROR(
"readTransferNonBlocking() must throw a ChimeraTK::runtime_error");
782 myException = std::current_exception();
786 accessor.postRead(TransferType::readNonBlocking,
false);
790 accessor.resetCounters();
791 accessor._throwRuntimeErrInTransfer =
true;
795 accessor.preWrite(TransferType::write, v);
799 accessor.writeTransfer(v);
800 BOOST_ERROR(
"writeTransfer() must throw a ChimeraTK::runtime_error");
803 myException = std::current_exception();
807 accessor.postWrite(TransferType::write, v);
811 accessor.resetCounters();
812 accessor._throwRuntimeErrInTransfer =
true;
816 accessor.preWrite(TransferType::writeDestructively, v);
820 accessor.writeTransferDestructively(v);
821 BOOST_ERROR(
"writeTransferDestructively() must throw a ChimeraTK::runtime_error");
824 myException = std::current_exception();
828 accessor.postWrite(TransferType::writeDestructively, v);
843 accessor.resetCounters();
845 accessor._previousDataLost =
false;
846 accessor.preWrite(TransferType::write, v);
847 ret = accessor.writeTransfer(v);
848 BOOST_CHECK(ret ==
false);
849 accessor.postWrite(TransferType::write, v);
851 accessor.resetCounters();
853 accessor._previousDataLost =
true;
854 accessor.preWrite(TransferType::write, v);
855 ret = accessor.writeTransfer(v);
856 BOOST_CHECK(ret ==
true);
857 accessor.postWrite(TransferType::write, v);
859 accessor.resetCounters();
861 accessor._previousDataLost =
false;
862 accessor.preWrite(TransferType::writeDestructively, v);
863 ret = accessor.writeTransferDestructively(v);
864 BOOST_CHECK(ret ==
false);
865 accessor.postWrite(TransferType::writeDestructively, v);
867 accessor.resetCounters();
869 accessor._previousDataLost =
true;
870 accessor.preWrite(TransferType::writeDestructively, v);
871 ret = accessor.writeTransferDestructively(v);
872 BOOST_CHECK(ret ==
true);
873 accessor.postWrite(TransferType::writeDestructively, v);
889 BOOST_CHECK(accessor._updateDataBuffer ==
true);
891 accessor.resetCounters();
892 accessor.readNonBlocking();
893 BOOST_CHECK(accessor._updateDataBuffer ==
true);
901 BOOST_CHECK(accessor._updateDataBuffer ==
true);
903 accessor.resetCounters();
905 accessor.readNonBlocking();
906 BOOST_CHECK(accessor._updateDataBuffer ==
true);
908 accessor.resetCounters();
909 accessor.readNonBlocking();
910 BOOST_CHECK(accessor._updateDataBuffer ==
false);
926 accessor._throwLogicErr =
true;
928 BOOST_CHECK(accessor._updateDataBuffer ==
false);
931 accessor.resetCounters();
932 accessor._throwRuntimeErrInPre =
true;
934 BOOST_CHECK(accessor._updateDataBuffer ==
false);
937 accessor.resetCounters();
938 accessor._throwRuntimeErrInTransfer =
true;
940 BOOST_CHECK(accessor._updateDataBuffer ==
false);
943 accessor.resetCounters();
944 accessor._throwRuntimeErrInTransfer =
true;
946 BOOST_CHECK(accessor._updateDataBuffer ==
false);
953 accessor.putRuntimeErrorOnQueue();
955 BOOST_CHECK(accessor._updateDataBuffer ==
false);
958 accessor.resetCounters();
959 accessor.putRuntimeErrorOnQueue();
961 BOOST_CHECK(accessor._updateDataBuffer ==
false);
980 accessor.preRead(TransferType::readNonBlocking);
981 BOOST_CHECK_EQUAL(accessor._readQueue.read_available(), 1);
982 accessor.readTransferNonBlocking();
983 BOOST_CHECK_EQUAL(accessor._readQueue.read_available(), 0);
984 accessor.postRead(TransferType::readNonBlocking,
true);
987 accessor.resetCounters();
989 accessor.preRead(TransferType::read);
990 BOOST_CHECK_EQUAL(accessor._readQueue.read_available(), 1);
991 accessor.readTransfer();
992 BOOST_CHECK_EQUAL(accessor._readQueue.read_available(), 0);
993 accessor.postRead(TransferType::read,
true);
1008 accessor.putDiscardValueOnQueue();
1009 ret = accessor.readNonBlocking();
1010 BOOST_CHECK(ret ==
false);
1011 BOOST_CHECK(accessor._postRead_counter == 1);
1014 accessor.resetCounters();
1015 accessor.putDiscardValueOnQueue();
1016 std::atomic<bool> readFinished{
false};
1019 readFinished =
true;
1022 BOOST_CHECK(readFinished ==
false);
1037 class MyException {};
1042 throw MyException();
1045 accessor._readQueue.push_overwrite_exception(std::current_exception());
1047 accessor.preRead(TransferType::readNonBlocking);
1048 BOOST_CHECK_EQUAL(accessor._readQueue.read_available(), 1);
1049 BOOST_CHECK_THROW(accessor.readTransferNonBlocking(), MyException);
1050 BOOST_CHECK_EQUAL(accessor._readQueue.read_available(), 0);
1051 accessor.postRead(TransferType::readNonBlocking,
true);
1054 accessor.resetCounters();
1056 throw MyException();
1059 accessor._readQueue.push_overwrite_exception(std::current_exception());
1061 accessor.preRead(TransferType::read);
1062 BOOST_CHECK_EQUAL(accessor._readQueue.read_available(), 1);
1063 BOOST_CHECK_THROW(accessor.readTransferNonBlocking(), MyException);
1064 BOOST_CHECK_EQUAL(accessor._readQueue.read_available(), 0);
1065 accessor.postRead(TransferType::read,
true);
1077 accessor.interrupt();
1078 BOOST_CHECK_THROW(accessor._readQueue.pop(), boost::thread_interrupted);
1091 accessor.interrupt();
1092 BOOST_CHECK_THROW(accessor.read(), boost::thread_interrupted);
1094 accessor.resetCounters();
1095 accessor.interrupt();
1096 BOOST_CHECK_THROW(accessor.readNonBlocking(), boost::thread_interrupted);
1098 accessor.resetCounters();
1101 accessor.interrupt();
1102 BOOST_CHECK_NO_THROW(accessor.read());
1103 BOOST_CHECK_NO_THROW(accessor.read());
1104 BOOST_CHECK_THROW(accessor.read(), boost::thread_interrupted);
1106 accessor.resetCounters();
1109 accessor.interrupt();
1110 BOOST_CHECK_NO_THROW(accessor.readNonBlocking());
1111 BOOST_CHECK_NO_THROW(accessor.readNonBlocking());
1112 BOOST_CHECK_THROW(accessor.readNonBlocking(), boost::thread_interrupted);
1114 accessor.resetCounters();
1117 accessor.interrupt();
1118 BOOST_CHECK_THROW(accessor.readLatest(), boost::thread_interrupted);
1119 BOOST_CHECK_EQUAL(accessor._readQueue.read_available(), 0);
1132 accessor.interrupt();
1133 BOOST_CHECK_THROW(accessor.read(), boost::thread_interrupted);
1134 BOOST_CHECK_EQUAL(accessor._preRead_counter, 1);
1135 BOOST_CHECK_EQUAL(accessor._postRead_counter, 1);
1137 accessor.resetCounters();
1138 accessor.interrupt();
1139 BOOST_CHECK_THROW(accessor.readNonBlocking(), boost::thread_interrupted);
1140 BOOST_CHECK_EQUAL(accessor._preRead_counter, 1);
1141 BOOST_CHECK_EQUAL(accessor._postRead_counter, 1);
1154 accessor.interrupt();
1155 BOOST_CHECK_THROW(accessor.read(), boost::thread_interrupted);
1157 accessor.resetCounters();
1159 BOOST_CHECK_NO_THROW(accessor.read());
1161 accessor.resetCounters();
1162 accessor.interrupt();
1163 BOOST_CHECK_THROW(accessor.readNonBlocking(), boost::thread_interrupted);
1165 accessor.resetCounters();
1167 BOOST_CHECK_NO_THROW(accessor.readNonBlocking());
1181 accessor.resetCounters();
1183 BOOST_CHECK(accessor.getVersionNumber() != v);
1185 BOOST_CHECK(accessor.getVersionNumber() == v);
1187 accessor.resetCounters();
1189 accessor._setPostReadVersion = v;
1191 BOOST_CHECK(accessor.getVersionNumber() == v);
1196 asyncAccessor.resetCounters();
1198 asyncAccessor.push();
1199 asyncAccessor._setPostReadVersion = v;
1200 asyncAccessor.read();
1201 BOOST_CHECK(asyncAccessor.getVersionNumber() == v);
1215 accessor.resetCounters();
1217 accessor.resetCounters();
1232 accessor.resetCounters();
1234 BOOST_CHECK(accessor._preWrite_version == v);
1235 BOOST_CHECK(accessor._writeTransfer_version == v);
1236 BOOST_CHECK(accessor._postWrite_version == v);
1239 accessor.resetCounters();
1240 accessor.writeDestructively(v);
1241 BOOST_CHECK(accessor._preWrite_version == v);
1242 BOOST_CHECK(accessor._writeTransfer_version == v);
1243 BOOST_CHECK(accessor._postWrite_version == v);
1258 accessor.resetCounters();
1262 accessor.resetCounters();
1264 accessor._throwLogicErr =
true;
1266 BOOST_CHECK(accessor.getVersionNumber() == v1);
1269 accessor.resetCounters();
1271 accessor._throwRuntimeErrInPre =
true;
1273 BOOST_CHECK(accessor.getVersionNumber() == v1);
1276 accessor.resetCounters();
1278 accessor._throwRuntimeErrInTransfer =
true;
1280 BOOST_CHECK(accessor.getVersionNumber() == v1);
1283 accessor.resetCounters();
1285 accessor._throwRuntimeErrInTransfer =
true;
1287 BOOST_CHECK(accessor.getVersionNumber() == v1);
1301 BOOST_CHECK(accessor.getVersionNumber() ==
VersionNumber{nullptr});
1316 accessor._accessModeFlags =
AccessModeFlags({AccessMode::wait_for_new_data});
1317 BOOST_CHECK(accessor.getAccessModeFlags() ==
AccessModeFlags({AccessMode::wait_for_new_data}));
1320 BOOST_CHECK(accessor.getAccessModeFlags() ==
AccessModeFlags({AccessMode::raw}));
1322 accessor._accessModeFlags =
AccessModeFlags({AccessMode::wait_for_new_data, AccessMode::raw});
1323 BOOST_CHECK(accessor.getAccessModeFlags() ==
AccessModeFlags({AccessMode::wait_for_new_data, AccessMode::raw}));
1339 BOOST_CHECK(accessor._accessModeFlags ==
AccessModeFlags({AccessMode::wait_for_new_data}));
1343 BOOST_CHECK(accessor._accessModeFlags ==
AccessModeFlags({AccessMode::raw}));
1347 BOOST_CHECK(accessor._accessModeFlags ==
AccessModeFlags({AccessMode::wait_for_new_data, AccessMode::raw}));
1358 BOOST_CHECK(std::is_default_constructible<TransferElement>::value ==
false);
1373 accessor._throwLogicErr =
true;
1375 BOOST_CHECK(accessor._seenActiveException == accessor._thrownException);
1378 accessor.resetCounters();
1379 accessor._throwRuntimeErrInPre =
true;
1381 BOOST_CHECK(accessor._seenActiveException == accessor._thrownException);
1384 accessor.resetCounters();
1385 accessor._throwRuntimeErrInTransfer =
true;
1387 BOOST_CHECK(accessor._seenActiveException == accessor._thrownException);
1390 accessor.resetCounters();
1391 accessor._throwRuntimeErrInTransfer =
true;
1393 BOOST_CHECK(accessor._seenActiveException == accessor._thrownException);
1396 asyncAccessor.resetCounters();
1397 asyncAccessor.putRuntimeErrorOnQueue();
1399 BOOST_CHECK(asyncAccessor._seenActiveException == asyncAccessor._thrownException);
1402 asyncAccessor.resetCounters();
1403 asyncAccessor.putRuntimeErrorOnQueue();
1405 BOOST_CHECK(asyncAccessor._seenActiveException == asyncAccessor._thrownException);
1410 accessor.resetCounters();
1411 accessor._throwLogicErr =
true;
1413 BOOST_CHECK(accessor._seenActiveException == accessor._thrownException);
1416 accessor.resetCounters();
1417 accessor._throwRuntimeErrInPre =
true;
1419 BOOST_CHECK(accessor._seenActiveException == accessor._thrownException);
1422 accessor.resetCounters();
1423 accessor._throwRuntimeErrInTransfer =
true;
1425 BOOST_CHECK(accessor._seenActiveException == accessor._thrownException);
1428 accessor.resetCounters();
1429 accessor._throwRuntimeErrInTransfer =
true;
1431 BOOST_CHECK(accessor._seenActiveException == accessor._thrownException);
1444 class MySpecialException {};
1447 accessor.preRead(TransferType::read);
1448 accessor.readTransfer();
1451 throw MySpecialException();
1454 auto myException = std::current_exception();
1455 auto myException_copy = myException;
1456 accessor.setActiveException(myException);
1459 BOOST_CHECK_EQUAL(accessor._postRead_counter, 0);
1460 BOOST_CHECK_THROW(accessor.postRead(TransferType::read,
false), MySpecialException);
1461 BOOST_CHECK_EQUAL(accessor._postRead_counter, 1);
1465 accessor.preWrite(TransferType::write, v);
1466 accessor.writeTransfer(v);
1469 throw MySpecialException();
1472 auto myException = std::current_exception();
1473 auto myException_copy = myException;
1474 accessor.setActiveException(myException);
1477 BOOST_CHECK_EQUAL(accessor._postWrite_counter, 0);
1478 BOOST_CHECK_THROW(accessor.postWrite(TransferType::write, v), MySpecialException);
1479 BOOST_CHECK_EQUAL(accessor._postWrite_counter, 1);
1492 class MySpecialException {};
1495 throw MySpecialException();
1498 auto myException = std::current_exception();
1499 auto myException_copy = myException;
1500 accessor.setActiveException(myException);
1501 BOOST_CHECK(myException ==
nullptr);
1502 BOOST_CHECK(accessor._activeException == myException_copy);