Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-22 07:53:33

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/Utilities/HashedString.hpp"
0012 
0013 #include <string>
0014 #include <string_view>
0015 
0016 using namespace Acts;
0017 using namespace Acts::HashedStringLiteral;
0018 
0019 namespace ActsTests {
0020 
0021 BOOST_AUTO_TEST_SUITE(UtilitiesSuite)
0022 
0023 BOOST_AUTO_TEST_CASE(string_hashes) {
0024   // compile time checks
0025   static_assert(hashString("abc") == 440920331, "Invalid with func");
0026   static_assert("abc"_hash == 440920331, "Invalid with literal");
0027   static_assert("abc"_hash == hashString("abc"), "Invalid");
0028 
0029   // runtime checks
0030   BOOST_CHECK_EQUAL(hashString("abc"), 440920331);
0031   BOOST_CHECK_EQUAL("abc"_hash, 440920331);
0032 
0033   std::string s = "abc";
0034   BOOST_CHECK_EQUAL(hashStringDynamic(s), 440920331);
0035   constexpr std::string_view sv{"abc"};
0036   BOOST_CHECK_EQUAL(hashString(sv), 440920331);
0037   static_assert(hashString(sv) == 440920331, "Invalid");
0038 }
0039 
0040 BOOST_AUTO_TEST_SUITE_END()
0041 
0042 }  // namespace ActsTests