Back to home page

EIC code displayed by LXR

 
 

    


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

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::HashedStringLiteral;
0017 
0018 namespace Acts::Test {
0019 
0020 BOOST_AUTO_TEST_CASE(string_hashes) {
0021   // compile time checks
0022   static_assert(hashString("abc") == 440920331, "Invalid with func");
0023   static_assert("abc"_hash == 440920331, "Invalid with literal");
0024   static_assert("abc"_hash == hashString("abc"), "Invalid");
0025 
0026   // runtime checks
0027   BOOST_CHECK_EQUAL(hashString("abc"), 440920331);
0028   BOOST_CHECK_EQUAL("abc"_hash, 440920331);
0029 
0030   std::string s = "abc";
0031   BOOST_CHECK_EQUAL(hashStringDynamic(s), 440920331);
0032   constexpr std::string_view sv{"abc"};
0033   BOOST_CHECK_EQUAL(hashString(sv), 440920331);
0034   static_assert(hashString(sv) == 440920331, "Invalid");
0035 }
0036 
0037 }  // namespace Acts::Test