File indexing completed on 2025-08-05 08:09:57
0001
0002
0003
0004
0005
0006
0007
0008
0009 #include <boost/test/data/test_case.hpp>
0010 #include <boost/test/unit_test.hpp>
0011
0012 #include "Acts/EventData/TrackStateProxy.hpp"
0013 #include "Acts/Utilities/PointerTraits.hpp"
0014
0015 #include <iostream>
0016 #include <memory>
0017
0018 namespace Acts::Test {
0019
0020 template <typename T>
0021 bool testPointer(const T ) {
0022 BOOST_TEST_MESSAGE("Object of " << typeid(T).name()
0023 << " does not pass the pointer concept ");
0024 return false;
0025 }
0026
0027 template <PointerConcept T>
0028 bool testPointer(const T ) {
0029 BOOST_TEST_MESSAGE("Object of " << typeid(T).name()
0030 << " passes the pointer concept ");
0031 return true;
0032 }
0033
0034 BOOST_AUTO_TEST_SUITE(PointerConceptTests)
0035
0036 BOOST_AUTO_TEST_CASE(testConceptPass) {
0037 int* raw_ptr{nullptr};
0038 BOOST_CHECK(testPointer(raw_ptr));
0039 int raw_val{0};
0040 BOOST_CHECK(!testPointer(raw_val));
0041
0042 BOOST_CHECK(testPointer(std::unique_ptr<int>{nullptr}));
0043 BOOST_CHECK(testPointer(std::unique_ptr<const int>{nullptr}));
0044
0045 BOOST_CHECK(testPointer(std::shared_ptr<int>{nullptr}));
0046 BOOST_CHECK(testPointer(std::shared_ptr<const int>{nullptr}));
0047
0048 BOOST_CHECK(testPointer(detail_lt::TransitiveConstPointer<int>{nullptr}));
0049 BOOST_CHECK(
0050 testPointer(detail_lt::TransitiveConstPointer<const int>{nullptr}));
0051
0052 struct PartialPointerLike {
0053 int* ptr = nullptr;
0054 int* operator->() const { return ptr; }
0055
0056 };
0057 BOOST_CHECK(!testPointer(PartialPointerLike{}));
0058
0059
0060 static_assert(std::is_same_v<RemovePointer_t<std::unique_ptr<int>>, int>);
0061 static_assert(std::is_same_v<RemovePointer_t<std::shared_ptr<int>>, int>);
0062 static_assert(std::is_same_v<RemovePointer_t<int>, int>);
0063 static_assert(std::is_same_v<RemovePointer_t<int*>, int>);
0064 }
0065 BOOST_AUTO_TEST_SUITE_END()
0066
0067 }