Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-12 07:53:03

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/unit_test.hpp>
0010 
0011 #include "Acts/EventData/SeedContainer2.hpp"
0012 
0013 using namespace Acts;
0014 using namespace Acts::Experimental;
0015 
0016 BOOST_AUTO_TEST_SUITE(EventDataSeedContainer2)
0017 
0018 BOOST_AUTO_TEST_CASE(Empty) {
0019   SeedContainer2 container;
0020 
0021   BOOST_CHECK(container.empty());
0022   BOOST_CHECK_EQUAL(container.size(), 0u);
0023 
0024   for ([[maybe_unused]] auto _ : container) {
0025     BOOST_FAIL("Container should be empty, no space points should be iterated");
0026   }
0027 }
0028 
0029 BOOST_AUTO_TEST_CASE(Create) {
0030   SeedContainer2 container;
0031   container.reserve(1);
0032 
0033   {
0034     auto seed = container.createSeed(std::array<SpacePointIndex2, 3>{0, 1, 2});
0035     seed.quality() = 1.0f;
0036     seed.vertexZ() = 3.0f;
0037   }
0038 
0039   BOOST_CHECK(!container.empty());
0040   BOOST_CHECK_EQUAL(container.size(), 1u);
0041 
0042   auto seed = container.at(0);
0043   BOOST_CHECK_EQUAL(seed.size(), 3u);
0044   BOOST_CHECK_EQUAL(seed.spacePointIndices()[0], 0u);
0045   BOOST_CHECK_EQUAL(seed.spacePointIndices()[1], 1u);
0046   BOOST_CHECK_EQUAL(seed.spacePointIndices()[2], 2u);
0047   BOOST_CHECK_EQUAL(seed.quality(), 1.0f);
0048   BOOST_CHECK_EQUAL(seed.vertexZ(), 3.0f);
0049 }
0050 
0051 BOOST_AUTO_TEST_CASE(Iterate) {
0052   SeedContainer2 container;
0053   container.reserve(1);
0054 
0055   {
0056     auto seed = container.createSeed(std::array<SpacePointIndex2, 3>{0, 1, 2});
0057     seed.quality() = 1.0f;
0058     seed.vertexZ() = 3.0f;
0059   }
0060 
0061   auto it = container.begin();
0062   BOOST_CHECK(it != container.end());
0063   BOOST_CHECK_EQUAL((*it).quality(), 1.0f);
0064   ++it;
0065   BOOST_CHECK(it == container.end());
0066 }
0067 
0068 BOOST_AUTO_TEST_CASE(CopyAndMove) {
0069   SeedContainer2 container;
0070   container.reserve(1);
0071 
0072   {
0073     auto seed = container.createSeed(std::array<SpacePointIndex2, 3>{0, 1, 2});
0074     seed.quality() = 1.0f;
0075     seed.vertexZ() = 3.0f;
0076   }
0077 
0078   SeedContainer2 containerCopy = container;
0079   BOOST_CHECK(!containerCopy.empty());
0080   BOOST_CHECK_EQUAL(containerCopy.size(), 1u);
0081 
0082   SeedContainer2 containerMove = std::move(container);
0083   BOOST_CHECK(!containerMove.empty());
0084   BOOST_CHECK_EQUAL(containerMove.size(), 1u);
0085   // original should be empty after move
0086   BOOST_CHECK(container.empty());
0087   BOOST_CHECK_EQUAL(container.size(), 0u);
0088   // copy should be unchanged
0089   BOOST_CHECK(!containerCopy.empty());
0090   BOOST_CHECK_EQUAL(containerCopy.size(), 1u);
0091 }
0092 
0093 BOOST_AUTO_TEST_CASE(Clear) {
0094   SeedContainer2 container;
0095   container.reserve(1);
0096 
0097   {
0098     auto seed = container.createSeed(std::array<SpacePointIndex2, 3>{0, 1, 2});
0099     seed.quality() = 1.0f;
0100     seed.vertexZ() = 3.0f;
0101   }
0102 
0103   container.clear();
0104 
0105   BOOST_CHECK(container.empty());
0106   BOOST_CHECK_EQUAL(container.size(), 0u);
0107   for ([[maybe_unused]] auto _ : container) {
0108     BOOST_FAIL("Container should be empty, no space points should be iterated");
0109   }
0110 }
0111 
0112 BOOST_AUTO_TEST_SUITE_END()