Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-17 09:21:46

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