Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:12:49

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/Seeding/detail/UtilityFunctions.hpp"
0012 
0013 #include <iterator>
0014 #include <list>
0015 #include <set>
0016 #include <string>
0017 #include <unordered_set>
0018 #include <vector>
0019 
0020 namespace Acts::Test {
0021 
0022 BOOST_AUTO_TEST_CASE(pushBackOrInsertAtEnd_vector) {
0023   std::vector<std::size_t> coll;
0024   Acts::detail::pushBackOrInsertAtEnd(coll, 2ul);
0025   BOOST_CHECK(coll.size() == 1ul);
0026   Acts::detail::pushBackOrInsertAtEnd(coll, 5ul);
0027   BOOST_CHECK(coll.size() == 2ul);
0028   std::size_t val = 1ul;
0029   Acts::detail::pushBackOrInsertAtEnd(coll, val);
0030   BOOST_CHECK(coll.size() == 3ul);
0031 
0032   BOOST_CHECK_EQUAL(coll[0], 2ul);
0033   BOOST_CHECK_EQUAL(coll[1], 5ul);
0034   BOOST_CHECK_EQUAL(coll[2], 1ul);
0035 }
0036 
0037 BOOST_AUTO_TEST_CASE(pushBackOrInsertAtEnd_list) {
0038   std::list<std::size_t> coll;
0039   Acts::detail::pushBackOrInsertAtEnd(coll, 2ul);
0040   BOOST_CHECK(coll.size() == 1ul);
0041   Acts::detail::pushBackOrInsertAtEnd(coll, 5ul);
0042   BOOST_CHECK(coll.size() == 2ul);
0043   std::size_t val = 1ul;
0044   Acts::detail::pushBackOrInsertAtEnd(coll, val);
0045   BOOST_CHECK(coll.size() == 3ul);
0046 
0047   BOOST_CHECK_EQUAL(coll.front(), 2ul);
0048   coll.pop_front();
0049   BOOST_CHECK_EQUAL(coll.front(), 5ul);
0050   coll.pop_front();
0051   BOOST_CHECK_EQUAL(coll.front(), 1ul);
0052   coll.pop_front();
0053 }
0054 
0055 BOOST_AUTO_TEST_CASE(pushBackOrInsertAtEnd_set) {
0056   std::set<std::size_t> coll;
0057   Acts::detail::pushBackOrInsertAtEnd(coll, 2ul);
0058   BOOST_CHECK(coll.size() == 1ul);
0059   Acts::detail::pushBackOrInsertAtEnd(coll, 5ul);
0060   BOOST_CHECK(coll.size() == 2ul);
0061   std::size_t val = 1ul;
0062   Acts::detail::pushBackOrInsertAtEnd(coll, val);
0063   BOOST_CHECK(coll.size() == 3ul);
0064 
0065   BOOST_CHECK(coll.contains(2ul));
0066   BOOST_CHECK(coll.contains(5ul));
0067   BOOST_CHECK(coll.contains(1ul));
0068 }
0069 
0070 BOOST_AUTO_TEST_CASE(pushBackOrInsertAtEnd_unordered_set) {
0071   std::unordered_set<std::size_t> coll;
0072   Acts::detail::pushBackOrInsertAtEnd(coll, 2ul);
0073   BOOST_CHECK(coll.size() == 1ul);
0074   Acts::detail::pushBackOrInsertAtEnd(coll, 5ul);
0075   BOOST_CHECK(coll.size() == 2ul);
0076   std::size_t val = 1ul;
0077   Acts::detail::pushBackOrInsertAtEnd(coll, val);
0078   BOOST_CHECK(coll.size() == 3ul);
0079 
0080   BOOST_CHECK(coll.contains(2ul));
0081   BOOST_CHECK(coll.contains(5ul));
0082   BOOST_CHECK(coll.contains(1ul));
0083 }
0084 
0085 }  // namespace Acts::Test