Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:25:20

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 using namespace Acts;
0019 
0020 namespace ActsTests {
0021 
0022 template <typename T>
0023 bool testPointer(const T /*ptr*/) {
0024   BOOST_TEST_MESSAGE("Object of " << typeid(T).name()
0025                                   << " does not pass the pointer concept ");
0026   return false;
0027 }
0028 
0029 template <PointerConcept T>
0030 bool testPointer(const T /*ptr*/) {
0031   BOOST_TEST_MESSAGE("Object of " << typeid(T).name()
0032                                   << " passes the pointer concept ");
0033   return true;
0034 }
0035 
0036 BOOST_AUTO_TEST_SUITE(UtilitiesSuite)
0037 
0038 BOOST_AUTO_TEST_CASE(testConceptPass) {
0039   int* raw_ptr{nullptr};
0040   BOOST_CHECK(testPointer(raw_ptr));
0041   int raw_val{0};
0042   BOOST_CHECK(!testPointer(raw_val));
0043 
0044   BOOST_CHECK(testPointer(std::unique_ptr<int>{nullptr}));
0045   BOOST_CHECK(testPointer(std::unique_ptr<const int>{nullptr}));
0046 
0047   BOOST_CHECK(testPointer(std::shared_ptr<int>{nullptr}));
0048   BOOST_CHECK(testPointer(std::shared_ptr<const int>{nullptr}));
0049 
0050   BOOST_CHECK(testPointer(detail_lt::TransitiveConstPointer<int>{nullptr}));
0051   BOOST_CHECK(
0052       testPointer(detail_lt::TransitiveConstPointer<const int>{nullptr}));
0053   // Class with partial pointer-like behavior
0054   struct PartialPointerLike {
0055     int* ptr = nullptr;
0056     int* operator->() const { return ptr; }
0057     // Missing operator*() and operator bool()
0058   };
0059   BOOST_CHECK(!testPointer(PartialPointerLike{}));
0060 
0061   /** Ensure that the remove_pointer_t trait is doing what's supposed to do */
0062   static_assert(std::is_same_v<RemovePointer_t<std::unique_ptr<int>>, int>);
0063   static_assert(std::is_same_v<RemovePointer_t<std::shared_ptr<int>>, int>);
0064   static_assert(std::is_same_v<RemovePointer_t<int>, int>);
0065   static_assert(std::is_same_v<RemovePointer_t<int*>, int>);
0066 }
0067 BOOST_AUTO_TEST_SUITE_END()
0068 
0069 }  // namespace ActsTests