Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:09:57

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
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 /*ptr*/) {
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 /*ptr*/) {
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   // Class with partial pointer-like behavior
0052   struct PartialPointerLike {
0053     int* ptr = nullptr;
0054     int* operator->() const { return ptr; }
0055     // Missing operator*() and operator bool()
0056   };
0057   BOOST_CHECK(!testPointer(PartialPointerLike{}));
0058 
0059   /** Ensure that the remove_pointer_t trait is doing what's supposed to do */
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 }  // namespace Acts::Test