testOptional.cxx 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  1. #include "cm_optional.hxx"
  2. #include "cm_utility.hxx"
  3. #include <iostream>
  4. #include <type_traits>
  5. #include <utility>
  6. #include <vector>
  7. class EventLogger;
  8. class Event
  9. {
  10. public:
  11. enum EventType
  12. {
  13. DEFAULT_CONSTRUCT,
  14. COPY_CONSTRUCT,
  15. MOVE_CONSTRUCT,
  16. VALUE_CONSTRUCT,
  17. DESTRUCT,
  18. COPY_ASSIGN,
  19. MOVE_ASSIGN,
  20. VALUE_ASSIGN,
  21. REFERENCE,
  22. CONST_REFERENCE,
  23. RVALUE_REFERENCE,
  24. CONST_RVALUE_REFERENCE,
  25. SWAP,
  26. };
  27. EventType Type;
  28. const EventLogger* Logger1;
  29. const EventLogger* Logger2;
  30. int Value;
  31. bool operator==(const Event& other) const;
  32. bool operator!=(const Event& other) const;
  33. };
  34. bool Event::operator==(const Event& other) const
  35. {
  36. return this->Type == other.Type && this->Logger1 == other.Logger1 &&
  37. this->Logger2 == other.Logger2 && this->Value == other.Value;
  38. }
  39. bool Event::operator!=(const Event& other) const
  40. {
  41. return !(*this == other);
  42. }
  43. static std::vector<Event> events;
  44. class EventLogger
  45. {
  46. public:
  47. EventLogger();
  48. EventLogger(const EventLogger& other);
  49. EventLogger(EventLogger&& other);
  50. EventLogger(int value);
  51. ~EventLogger();
  52. EventLogger& operator=(const EventLogger& other);
  53. EventLogger& operator=(EventLogger&& other);
  54. EventLogger& operator=(int value);
  55. void Reference() &;
  56. void Reference() const&;
  57. void Reference() &&;
  58. void Reference() const&&;
  59. int Value = 0;
  60. };
  61. // Certain builds of GCC generate false -Wmaybe-uninitialized warnings when
  62. // doing a release build with the system version of std::optional. These
  63. // warnings do not manifest when using our own cm::optional implementation.
  64. // Silence these false warnings.
  65. #if defined(__GNUC__) && !defined(__clang__)
  66. # define BEGIN_IGNORE_UNINITIALIZED \
  67. _Pragma("GCC diagnostic push") \
  68. _Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
  69. # define END_IGNORE_UNINITIALIZED _Pragma("GCC diagnostic pop")
  70. #else
  71. # define BEGIN_IGNORE_UNINITIALIZED
  72. # define END_IGNORE_UNINITIALIZED
  73. #endif
  74. void swap(EventLogger& e1, EventLogger& e2)
  75. {
  76. BEGIN_IGNORE_UNINITIALIZED
  77. events.push_back({ Event::SWAP, &e1, &e2, e2.Value });
  78. END_IGNORE_UNINITIALIZED
  79. auto tmp = e1.Value;
  80. e1.Value = e2.Value;
  81. e2.Value = tmp;
  82. }
  83. EventLogger::EventLogger()
  84. : Value(0)
  85. {
  86. events.push_back({ Event::DEFAULT_CONSTRUCT, this, nullptr, 0 });
  87. }
  88. EventLogger::EventLogger(const EventLogger& other)
  89. : Value(other.Value)
  90. {
  91. events.push_back({ Event::COPY_CONSTRUCT, this, &other, other.Value });
  92. }
  93. BEGIN_IGNORE_UNINITIALIZED
  94. EventLogger::EventLogger(EventLogger&& other)
  95. : Value(other.Value)
  96. {
  97. events.push_back({ Event::MOVE_CONSTRUCT, this, &other, other.Value });
  98. }
  99. END_IGNORE_UNINITIALIZED
  100. EventLogger::EventLogger(int value)
  101. : Value(value)
  102. {
  103. events.push_back({ Event::VALUE_CONSTRUCT, this, nullptr, value });
  104. }
  105. EventLogger::~EventLogger()
  106. {
  107. BEGIN_IGNORE_UNINITIALIZED
  108. events.push_back({ Event::DESTRUCT, this, nullptr, this->Value });
  109. END_IGNORE_UNINITIALIZED
  110. }
  111. EventLogger& EventLogger::operator=(const EventLogger& other)
  112. {
  113. events.push_back({ Event::COPY_ASSIGN, this, &other, other.Value });
  114. this->Value = other.Value;
  115. return *this;
  116. }
  117. EventLogger& EventLogger::operator=(EventLogger&& other)
  118. {
  119. events.push_back({ Event::MOVE_ASSIGN, this, &other, other.Value });
  120. this->Value = other.Value;
  121. return *this;
  122. }
  123. EventLogger& EventLogger::operator=(int value)
  124. {
  125. events.push_back({ Event::VALUE_ASSIGN, this, nullptr, value });
  126. this->Value = value;
  127. return *this;
  128. }
  129. void EventLogger::Reference() &
  130. {
  131. events.push_back({ Event::REFERENCE, this, nullptr, this->Value });
  132. }
  133. void EventLogger::Reference() const&
  134. {
  135. events.push_back({ Event::CONST_REFERENCE, this, nullptr, this->Value });
  136. }
  137. void EventLogger::Reference() &&
  138. {
  139. events.push_back({ Event::RVALUE_REFERENCE, this, nullptr, this->Value });
  140. }
  141. void EventLogger::Reference() const&&
  142. {
  143. events.push_back(
  144. { Event::CONST_RVALUE_REFERENCE, this, nullptr, this->Value });
  145. }
  146. static bool testDefaultConstruct(std::vector<Event>& expected)
  147. {
  148. const cm::optional<EventLogger> o{};
  149. expected = {};
  150. return true;
  151. }
  152. static bool testNulloptConstruct(std::vector<Event>& expected)
  153. {
  154. const cm::optional<EventLogger> o{ cm::nullopt };
  155. expected = {};
  156. return true;
  157. }
  158. static bool testValueConstruct(std::vector<Event>& expected)
  159. {
  160. const cm::optional<EventLogger> o{ 4 };
  161. expected = {
  162. { Event::VALUE_CONSTRUCT, &*o, nullptr, 4 },
  163. { Event::DESTRUCT, &*o, nullptr, 4 },
  164. };
  165. return true;
  166. }
  167. static bool testInPlaceConstruct(std::vector<Event>& expected)
  168. {
  169. const cm::optional<EventLogger> o1{ cm::in_place, 4 };
  170. const cm::optional<EventLogger> o2{ cm::in_place_t{}, 4 };
  171. expected = {
  172. { Event::VALUE_CONSTRUCT, &*o1, nullptr, 4 },
  173. { Event::VALUE_CONSTRUCT, &*o2, nullptr, 4 },
  174. { Event::DESTRUCT, &*o2, nullptr, 4 },
  175. { Event::DESTRUCT, &*o1, nullptr, 4 },
  176. };
  177. return true;
  178. }
  179. static bool testCopyConstruct(std::vector<Event>& expected)
  180. {
  181. const cm::optional<EventLogger> o1{ 4 };
  182. const cm::optional<EventLogger> o2{ o1 };
  183. const cm::optional<EventLogger> o3{};
  184. const cm::optional<EventLogger> o4{ o3 };
  185. expected = {
  186. { Event::VALUE_CONSTRUCT, &*o1, nullptr, 4 },
  187. { Event::COPY_CONSTRUCT, &*o2, &o1.value(), 4 },
  188. { Event::DESTRUCT, &*o2, nullptr, 4 },
  189. { Event::DESTRUCT, &*o1, nullptr, 4 },
  190. };
  191. return true;
  192. }
  193. static bool testMoveConstruct(std::vector<Event>& expected)
  194. {
  195. cm::optional<EventLogger> o1{ 4 };
  196. const cm::optional<EventLogger> o2{ std::move(o1) };
  197. cm::optional<EventLogger> o3{};
  198. const cm::optional<EventLogger> o4{ std::move(o3) };
  199. expected = {
  200. { Event::VALUE_CONSTRUCT, &*o1, nullptr, 4 },
  201. { Event::MOVE_CONSTRUCT, &*o2, &o1.value(), 4 },
  202. { Event::DESTRUCT, &*o2, nullptr, 4 },
  203. { Event::DESTRUCT, &*o1, nullptr, 4 },
  204. };
  205. return true;
  206. }
  207. static bool testNulloptAssign(std::vector<Event>& expected)
  208. {
  209. cm::optional<EventLogger> o1{ 4 };
  210. o1 = cm::nullopt;
  211. cm::optional<EventLogger> o2{};
  212. o2 = cm::nullopt;
  213. expected = {
  214. { Event::VALUE_CONSTRUCT, &*o1, nullptr, 4 },
  215. { Event::DESTRUCT, &*o1, nullptr, 4 },
  216. };
  217. return true;
  218. }
  219. static bool testCopyAssign(std::vector<Event>& expected)
  220. {
  221. cm::optional<EventLogger> o1{};
  222. const cm::optional<EventLogger> o2{ 4 };
  223. o1 = o2;
  224. const cm::optional<EventLogger> o3{ 5 };
  225. o1 = o3;
  226. const cm::optional<EventLogger> o4{};
  227. o1 = o4;
  228. o1 = o4; // Intentionally duplicated to test assigning an empty optional to
  229. // an empty optional
  230. expected = {
  231. { Event::VALUE_CONSTRUCT, &*o2, nullptr, 4 },
  232. { Event::COPY_CONSTRUCT, &*o1, &*o2, 4 },
  233. { Event::VALUE_CONSTRUCT, &*o3, nullptr, 5 },
  234. { Event::COPY_ASSIGN, &*o1, &*o3, 5 },
  235. { Event::DESTRUCT, &*o1, nullptr, 5 },
  236. { Event::DESTRUCT, &o3.value(), nullptr, 5 },
  237. { Event::DESTRUCT, &o2.value(), nullptr, 4 },
  238. };
  239. return true;
  240. }
  241. static bool testMoveAssign(std::vector<Event>& expected)
  242. {
  243. cm::optional<EventLogger> o1{};
  244. cm::optional<EventLogger> o2{ 4 };
  245. o1 = std::move(o2);
  246. cm::optional<EventLogger> o3{ 5 };
  247. o1 = std::move(o3);
  248. cm::optional<EventLogger> o4{};
  249. o1 = std::move(o4);
  250. expected = {
  251. { Event::VALUE_CONSTRUCT, &*o2, nullptr, 4 },
  252. { Event::MOVE_CONSTRUCT, &*o1, &*o2, 4 },
  253. { Event::VALUE_CONSTRUCT, &*o3, nullptr, 5 },
  254. { Event::MOVE_ASSIGN, &*o1, &*o3, 5 },
  255. { Event::DESTRUCT, &*o1, nullptr, 5 },
  256. { Event::DESTRUCT, &*o3, nullptr, 5 },
  257. { Event::DESTRUCT, &*o2, nullptr, 4 },
  258. };
  259. return true;
  260. }
  261. static bool testPointer(std::vector<Event>& expected)
  262. {
  263. cm::optional<EventLogger> o1{ 4 };
  264. const cm::optional<EventLogger> o2{ 5 };
  265. o1->Reference();
  266. o2->Reference();
  267. expected = {
  268. { Event::VALUE_CONSTRUCT, &*o1, nullptr, 4 },
  269. { Event::VALUE_CONSTRUCT, &*o2, nullptr, 5 },
  270. { Event::REFERENCE, &*o1, nullptr, 4 },
  271. { Event::CONST_REFERENCE, &*o2, nullptr, 5 },
  272. { Event::DESTRUCT, &*o2, nullptr, 5 },
  273. { Event::DESTRUCT, &*o1, nullptr, 4 },
  274. };
  275. return true;
  276. }
  277. #if !__GNUC__ || __GNUC__ > 4
  278. # define ALLOW_CONST_RVALUE
  279. #endif
  280. static bool testDereference(std::vector<Event>& expected)
  281. {
  282. cm::optional<EventLogger> o1{ 4 };
  283. const cm::optional<EventLogger> o2{ 5 };
  284. (*o1).Reference();
  285. (*o2).Reference();
  286. (*std::move(o1)).Reference();
  287. #ifdef ALLOW_CONST_RVALUE
  288. (*std::move(o2)).Reference(); // Broken in GCC 4.9.0. Sigh...
  289. #endif
  290. expected = {
  291. { Event::VALUE_CONSTRUCT, &*o1, nullptr, 4 },
  292. { Event::VALUE_CONSTRUCT, &*o2, nullptr, 5 },
  293. { Event::REFERENCE, &*o1, nullptr, 4 },
  294. { Event::CONST_REFERENCE, &*o2, nullptr, 5 },
  295. { Event::RVALUE_REFERENCE, &*o1, nullptr, 4 },
  296. #ifdef ALLOW_CONST_RVALUE
  297. { Event::CONST_RVALUE_REFERENCE, &*o2, nullptr, 5 },
  298. #endif
  299. { Event::DESTRUCT, &*o2, nullptr, 5 },
  300. { Event::DESTRUCT, &*o1, nullptr, 4 },
  301. };
  302. return true;
  303. }
  304. static bool testHasValue(std::vector<Event>& expected)
  305. {
  306. bool retval = true;
  307. const cm::optional<EventLogger> o1{ 4 };
  308. const cm::optional<EventLogger> o2{};
  309. if (!o1.has_value()) {
  310. std::cout << "o1 should have a value" << std::endl;
  311. retval = false;
  312. }
  313. if (!o1) {
  314. std::cout << "(bool)o1 should be true" << std::endl;
  315. retval = false;
  316. }
  317. if (o2.has_value()) {
  318. std::cout << "o2 should not have a value" << std::endl;
  319. retval = false;
  320. }
  321. if (o2) {
  322. std::cout << "(bool)o2 should be false" << std::endl;
  323. retval = false;
  324. }
  325. expected = {
  326. { Event::VALUE_CONSTRUCT, &*o1, nullptr, 4 },
  327. { Event::DESTRUCT, &*o1, nullptr, 4 },
  328. };
  329. return retval;
  330. }
  331. static bool testValue(std::vector<Event>& expected)
  332. {
  333. bool retval = true;
  334. cm::optional<EventLogger> o1{ 4 };
  335. const cm::optional<EventLogger> o2{ 5 };
  336. cm::optional<EventLogger> o3{};
  337. const cm::optional<EventLogger> o4{};
  338. o1.value().Reference();
  339. o2.value().Reference();
  340. bool thrown = false;
  341. try {
  342. (void)o3.value();
  343. } catch (cm::bad_optional_access&) {
  344. thrown = true;
  345. }
  346. if (!thrown) {
  347. std::cout << "o3.value() did not throw" << std::endl;
  348. retval = false;
  349. }
  350. thrown = false;
  351. try {
  352. (void)o4.value();
  353. } catch (cm::bad_optional_access&) {
  354. thrown = true;
  355. }
  356. if (!thrown) {
  357. std::cout << "o4.value() did not throw" << std::endl;
  358. retval = false;
  359. }
  360. expected = {
  361. { Event::VALUE_CONSTRUCT, &*o1, nullptr, 4 },
  362. { Event::VALUE_CONSTRUCT, &*o2, nullptr, 5 },
  363. { Event::REFERENCE, &*o1, nullptr, 4 },
  364. { Event::CONST_REFERENCE, &*o2, nullptr, 5 },
  365. { Event::DESTRUCT, &*o2, nullptr, 5 },
  366. { Event::DESTRUCT, &*o1, nullptr, 4 },
  367. };
  368. return retval;
  369. }
  370. static bool testValueOr()
  371. {
  372. bool retval = true;
  373. const cm::optional<EventLogger> o1{ 4 };
  374. cm::optional<EventLogger> o2{ 5 };
  375. const cm::optional<EventLogger> o3{};
  376. cm::optional<EventLogger> o4{};
  377. EventLogger e1{ 6 };
  378. EventLogger e2{ 7 };
  379. EventLogger e3{ 8 };
  380. EventLogger e4{ 9 };
  381. EventLogger r1 = o1.value_or(e1);
  382. if (r1.Value != 4) {
  383. std::cout << "r1.Value should be 4" << std::endl;
  384. retval = false;
  385. }
  386. EventLogger r2 = std::move(o2).value_or(e2);
  387. if (r2.Value != 5) {
  388. std::cout << "r2.Value should be 5" << std::endl;
  389. retval = false;
  390. }
  391. EventLogger r3 = o3.value_or(e3);
  392. if (r3.Value != 8) {
  393. std::cout << "r3.Value should be 8" << std::endl;
  394. retval = false;
  395. }
  396. EventLogger r4 = std::move(o4).value_or(e4);
  397. if (r4.Value != 9) {
  398. std::cout << "r4.Value should be 9" << std::endl;
  399. retval = false;
  400. }
  401. return retval;
  402. }
  403. static bool testSwap(std::vector<Event>& expected)
  404. {
  405. bool retval = true;
  406. cm::optional<EventLogger> o1{ 4 };
  407. cm::optional<EventLogger> o2{};
  408. o1.swap(o2);
  409. if (o1.has_value()) {
  410. std::cout << "o1 should not have value" << std::endl;
  411. retval = false;
  412. }
  413. if (!o2.has_value()) {
  414. std::cout << "o2 should have value" << std::endl;
  415. retval = false;
  416. }
  417. if (o2.value().Value != 4) {
  418. std::cout << "value of o2 should be 4" << std::endl;
  419. retval = false;
  420. }
  421. o1.swap(o2);
  422. if (!o1.has_value()) {
  423. std::cout << "o1 should have value" << std::endl;
  424. retval = false;
  425. }
  426. if (o1.value().Value != 4) {
  427. std::cout << "value of o1 should be 4" << std::endl;
  428. retval = false;
  429. }
  430. if (o2.has_value()) {
  431. std::cout << "o2 should not have value" << std::endl;
  432. retval = false;
  433. }
  434. o2.emplace(5);
  435. o1.swap(o2);
  436. if (!o1.has_value()) {
  437. std::cout << "o1 should have value" << std::endl;
  438. retval = false;
  439. }
  440. if (o1.value().Value != 5) {
  441. std::cout << "value of o1 should be 5" << std::endl;
  442. retval = false;
  443. }
  444. if (!o2.has_value()) {
  445. std::cout << "o2 should not have value" << std::endl;
  446. retval = false;
  447. }
  448. if (o2.value().Value != 4) {
  449. std::cout << "value of o2 should be 4" << std::endl;
  450. retval = false;
  451. }
  452. o1.reset();
  453. o2.reset();
  454. o1.swap(o2);
  455. if (o1.has_value()) {
  456. std::cout << "o1 should not have value" << std::endl;
  457. retval = false;
  458. }
  459. if (o2.has_value()) {
  460. std::cout << "o2 should not have value" << std::endl;
  461. retval = false;
  462. }
  463. expected = {
  464. { Event::VALUE_CONSTRUCT, &*o1, nullptr, 4 },
  465. { Event::MOVE_CONSTRUCT, &*o2, &*o1, 4 },
  466. { Event::DESTRUCT, &*o1, nullptr, 4 },
  467. { Event::MOVE_CONSTRUCT, &*o1, &*o2, 4 },
  468. { Event::DESTRUCT, &*o2, nullptr, 4 },
  469. { Event::VALUE_CONSTRUCT, &*o2, nullptr, 5 },
  470. { Event::SWAP, &*o1, &*o2, 5 },
  471. { Event::DESTRUCT, &*o1, nullptr, 5 },
  472. { Event::DESTRUCT, &*o2, nullptr, 4 },
  473. };
  474. return retval;
  475. }
  476. static bool testReset(std::vector<Event>& expected)
  477. {
  478. bool retval = true;
  479. cm::optional<EventLogger> o{ 4 };
  480. o.reset();
  481. if (o.has_value()) {
  482. std::cout << "o should not have value" << std::endl;
  483. retval = false;
  484. }
  485. o.reset();
  486. expected = {
  487. { Event::VALUE_CONSTRUCT, &*o, nullptr, 4 },
  488. { Event::DESTRUCT, &*o, nullptr, 4 },
  489. };
  490. return retval;
  491. }
  492. static bool testEmplace(std::vector<Event>& expected)
  493. {
  494. cm::optional<EventLogger> o{ 4 };
  495. o.emplace(5);
  496. o.reset();
  497. o.emplace();
  498. expected = {
  499. { Event::VALUE_CONSTRUCT, &*o, nullptr, 4 },
  500. { Event::DESTRUCT, &*o, nullptr, 4 },
  501. { Event::VALUE_CONSTRUCT, &*o, nullptr, 5 },
  502. { Event::DESTRUCT, &*o, nullptr, 5 },
  503. { Event::DEFAULT_CONSTRUCT, &*o, nullptr, 0 },
  504. { Event::DESTRUCT, &*o, nullptr, 0 },
  505. };
  506. return true;
  507. }
  508. static bool testMakeOptional(std::vector<Event>& expected)
  509. {
  510. EventLogger e{ 4 };
  511. cm::optional<EventLogger> o1 = cm::make_optional<EventLogger>(e);
  512. cm::optional<EventLogger> o2 = cm::make_optional<EventLogger>(5);
  513. expected = {
  514. { Event::VALUE_CONSTRUCT, &e, nullptr, 4 },
  515. { Event::COPY_CONSTRUCT, &*o1, &e, 4 },
  516. { Event::VALUE_CONSTRUCT, &*o2, nullptr, 5 },
  517. { Event::DESTRUCT, &*o2, nullptr, 5 },
  518. { Event::DESTRUCT, &*o1, nullptr, 4 },
  519. { Event::DESTRUCT, &e, nullptr, 4 },
  520. };
  521. return true;
  522. }
  523. static bool testMemoryRange(std::vector<Event>& expected)
  524. {
  525. bool retval = true;
  526. cm::optional<EventLogger> o{ 4 };
  527. auto* ostart = &o;
  528. auto* oend = ostart + 1;
  529. auto* estart = &o.value();
  530. auto* eend = estart + 1;
  531. if (static_cast<void*>(estart) < static_cast<void*>(ostart) ||
  532. static_cast<void*>(eend) > static_cast<void*>(oend)) {
  533. std::cout << "value is not within memory range of optional" << std::endl;
  534. retval = false;
  535. }
  536. expected = {
  537. { Event::VALUE_CONSTRUCT, &*o, nullptr, 4 },
  538. { Event::DESTRUCT, &*o, nullptr, 4 },
  539. };
  540. return retval;
  541. }
  542. int testOptional(int /*unused*/, char* /*unused*/ [])
  543. {
  544. int retval = 0;
  545. #define DO_EVENT_TEST(name) \
  546. do { \
  547. events.clear(); \
  548. std::vector<Event> expected; \
  549. if (!name(expected)) { \
  550. std::cout << "in " #name << std::endl; \
  551. retval = 1; \
  552. } else if (expected != events) { \
  553. std::cout << #name " did not produce expected events" << std::endl; \
  554. retval = 1; \
  555. } \
  556. } while (0)
  557. #define DO_TEST(name) \
  558. do { \
  559. if (!name()) { \
  560. std::cout << "in " #name << std::endl; \
  561. retval = 1; \
  562. } \
  563. } while (0)
  564. DO_EVENT_TEST(testDefaultConstruct);
  565. DO_EVENT_TEST(testNulloptConstruct);
  566. DO_EVENT_TEST(testValueConstruct);
  567. DO_EVENT_TEST(testInPlaceConstruct);
  568. DO_EVENT_TEST(testCopyConstruct);
  569. DO_EVENT_TEST(testMoveConstruct);
  570. DO_EVENT_TEST(testNulloptAssign);
  571. DO_EVENT_TEST(testCopyAssign);
  572. DO_EVENT_TEST(testMoveAssign);
  573. DO_EVENT_TEST(testPointer);
  574. DO_EVENT_TEST(testDereference);
  575. DO_EVENT_TEST(testHasValue);
  576. DO_EVENT_TEST(testValue);
  577. DO_TEST(testValueOr);
  578. DO_EVENT_TEST(testSwap);
  579. DO_EVENT_TEST(testReset);
  580. DO_EVENT_TEST(testEmplace);
  581. DO_EVENT_TEST(testMakeOptional);
  582. DO_EVENT_TEST(testMemoryRange);
  583. return retval;
  584. }