2025-05-28 11:05:10 +02:00
|
|
|
// Copyright 2022, 2025 Peter Dimov.
|
2022-10-30 02:47:10 +03:00
|
|
|
// Distributed under the Boost Software License, Version 1.0.
|
|
|
|
|
// https://www.boost.org/LICENSE_1_0.txt
|
|
|
|
|
|
|
|
|
|
#include <boost/container_hash/hash.hpp>
|
2025-05-28 11:05:10 +02:00
|
|
|
#include <boost/container_hash/hash_is_avalanching.hpp>
|
2022-10-30 02:47:10 +03:00
|
|
|
#include <boost/core/lightweight_test_trait.hpp>
|
2022-11-01 02:35:51 +02:00
|
|
|
#include <boost/config.hpp>
|
2022-10-30 02:47:10 +03:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
enum my_char { min = 0, max = 255 };
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
2025-05-28 11:05:10 +02:00
|
|
|
using boost::hash_is_avalanching;
|
2022-10-30 02:47:10 +03:00
|
|
|
|
|
|
|
|
BOOST_TEST_TRAIT_TRUE(( hash_is_avalanching< boost::hash<std::string> > ));
|
|
|
|
|
BOOST_TEST_TRAIT_TRUE(( hash_is_avalanching< boost::hash<std::wstring> > ));
|
|
|
|
|
|
|
|
|
|
#if !defined(BOOST_NO_CXX11_CHAR16_T)
|
|
|
|
|
|
|
|
|
|
BOOST_TEST_TRAIT_TRUE(( hash_is_avalanching< boost::hash<std::u16string> > ));
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if !defined(BOOST_NO_CXX11_CHAR32_T)
|
|
|
|
|
|
|
|
|
|
BOOST_TEST_TRAIT_TRUE(( hash_is_avalanching< boost::hash<std::u32string> > ));
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L
|
|
|
|
|
|
2022-10-30 03:01:05 +02:00
|
|
|
BOOST_TEST_TRAIT_TRUE(( hash_is_avalanching< boost::hash< std::basic_string<char8_t> > > ));
|
2022-10-30 02:47:10 +03:00
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-06-28 11:12:42 -05:00
|
|
|
#if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION >= 160000
|
|
|
|
|
// std::char_traits<Ch> is deprecated for non-char types
|
|
|
|
|
#else
|
2022-10-30 02:47:10 +03:00
|
|
|
BOOST_TEST_TRAIT_FALSE(( hash_is_avalanching< boost::hash<std::basic_string<my_char> > > ));
|
2023-06-28 11:12:42 -05:00
|
|
|
#endif
|
2022-10-30 02:47:10 +03:00
|
|
|
|
|
|
|
|
return boost::report_errors();
|
|
|
|
|
}
|