mirror of
https://github.com/boostorg/container_hash.git
synced 2026-03-07 14:34:11 +01:00
Compare commits
6 Commits
feature/up
...
feature/st
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f722383d1d | ||
|
|
21530840e1 | ||
|
|
d0c1e36fc1 | ||
|
|
e00f53a69c | ||
|
|
b0c9904414 | ||
|
|
2d557a746d |
@@ -25,10 +25,6 @@ environment:
|
||||
TOOLSET: msvc-14.1
|
||||
CXXSTD: 14,17
|
||||
ADDRMD: 32,64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
|
||||
TOOLSET: msvc-14.2
|
||||
CXXSTD: 14,17,latest
|
||||
ADDRMD: 32,64
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
TOOLSET: clang-win
|
||||
ADDRMD: 64
|
||||
|
||||
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
@@ -121,7 +121,7 @@ jobs:
|
||||
install: clang-14
|
||||
- toolset: clang
|
||||
cxxstd: "03,11,14,17,2a"
|
||||
os: macos-10.15
|
||||
os: macos-11
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
@@ -234,7 +234,7 @@ jobs:
|
||||
- os: ubuntu-18.04
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-10.15
|
||||
- os: macos-11
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
@@ -281,7 +281,7 @@ jobs:
|
||||
- os: ubuntu-18.04
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-10.15
|
||||
- os: macos-11
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
@@ -338,7 +338,7 @@ jobs:
|
||||
- os: ubuntu-18.04
|
||||
- os: ubuntu-20.04
|
||||
- os: ubuntu-22.04
|
||||
- os: macos-10.15
|
||||
- os: macos-11
|
||||
|
||||
runs-on: ${{matrix.os}}
|
||||
|
||||
|
||||
@@ -417,7 +417,7 @@ namespace boost
|
||||
return boost::hash_unordered_range( v.begin(), v.end() );
|
||||
}
|
||||
|
||||
#if defined(BOOST_MSVC) && BOOST_MSVC >= 1910 && BOOST_MSVC < 1920 && BOOST_CXX_VERSION >= 201700L
|
||||
#if defined(_MSVC_STL_VERSION) && _MSVC_STL_VERSION == 141 && BOOST_CXX_VERSION >= 201700L
|
||||
|
||||
// resolve ambiguity with unconstrained stdext::hash_value in <xhash> :-/
|
||||
|
||||
@@ -670,7 +670,7 @@ namespace boost
|
||||
}
|
||||
};
|
||||
|
||||
#if defined(BOOST_MSVC) && BOOST_MSVC >= 1910 && BOOST_MSVC < 1920 && BOOST_CXX_VERSION >= 201700L
|
||||
#if defined(_MSVC_STL_VERSION) && _MSVC_STL_VERSION == 141 && BOOST_CXX_VERSION >= 201700L
|
||||
|
||||
// msvc-14.1 has stdext::hash_value for basic_string in <xhash> :-/
|
||||
|
||||
|
||||
@@ -81,3 +81,8 @@ run hash_fs_path_test.cpp /boost//filesystem/<warnings>off : : : $(fs-path-req)
|
||||
run detail_is_range_test2.cpp : : : $(fs-path-req) ;
|
||||
|
||||
run hash_container_test.cpp ;
|
||||
|
||||
run hash_vector_test2.cpp ;
|
||||
|
||||
run hash_string_test3.cpp ;
|
||||
run hash_string_test4.cpp ;
|
||||
|
||||
42
test/hash_string_test3.cpp
Normal file
42
test/hash_string_test3.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright 2021, 2022 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/container_hash/hash.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <string>
|
||||
|
||||
void test( unsigned char ch )
|
||||
{
|
||||
typedef boost::hash<std::string> hash;
|
||||
|
||||
int const N = 32;
|
||||
|
||||
std::size_t h[ N ];
|
||||
|
||||
std::string v;
|
||||
|
||||
for( int i = 0; i < N; ++i )
|
||||
{
|
||||
h[ i ] = hash()( v );
|
||||
|
||||
BOOST_TEST_EQ( h[ i ], hash()( v ) );
|
||||
|
||||
for( int j = 0; j < i; ++j )
|
||||
{
|
||||
BOOST_TEST_NE( h[ j ], h[ i ] );
|
||||
}
|
||||
|
||||
v.push_back( static_cast<char>( ch ) );
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
for( unsigned ch = 0; ch < 256; ++ch )
|
||||
{
|
||||
test( static_cast<unsigned char>( ch ) );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
41
test/hash_string_test4.cpp
Normal file
41
test/hash_string_test4.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
// Copyright 2021, 2022 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/container_hash/hash.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <string>
|
||||
#include <cstddef>
|
||||
|
||||
void test( std::size_t n, unsigned char ch )
|
||||
{
|
||||
typedef boost::hash<std::string> hash;
|
||||
|
||||
std::string const v( n, static_cast<char>( ch ) );
|
||||
|
||||
for( std::size_t i = 0; i < n * 8; ++i )
|
||||
{
|
||||
std::string w( v );
|
||||
|
||||
unsigned char ch2 = static_cast<unsigned char>( w[ i / 8 ] );
|
||||
|
||||
ch2 = static_cast<unsigned char>( ch2 ^ ( 1 << ( i % 8 ) ) );
|
||||
|
||||
w[ i / 8 ] = static_cast<char>( ch2 );
|
||||
|
||||
BOOST_TEST_NE( hash()( v ), hash()( w ) );
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
for( unsigned ch = 0; ch < 256; ++ch )
|
||||
{
|
||||
for( std::size_t n = 1; n < 32; ++n )
|
||||
{
|
||||
test( n, static_cast<unsigned char>( ch ) );
|
||||
}
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
48
test/hash_vector_test2.cpp
Normal file
48
test/hash_vector_test2.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
// Copyright 2021, 2022 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ == 8
|
||||
# pragma GCC diagnostic ignored "-Wsign-conversion"
|
||||
#endif
|
||||
|
||||
#include <boost/container_hash/hash.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <vector>
|
||||
#include <functional> // to catch msvc-14.1 conflicts
|
||||
|
||||
template<class T> void test()
|
||||
{
|
||||
typedef std::vector<T> list;
|
||||
typedef boost::hash<list> hash;
|
||||
|
||||
int const N = 32;
|
||||
|
||||
std::size_t h[ N ];
|
||||
|
||||
list v;
|
||||
|
||||
for( int i = 0; i < N; ++i )
|
||||
{
|
||||
h[ i ] = hash()( v );
|
||||
|
||||
BOOST_TEST_EQ( h[ i ], hash()( v ) );
|
||||
|
||||
for( int j = 0; j < i; ++j )
|
||||
{
|
||||
BOOST_TEST_NE( h[ j ], h[ i ] );
|
||||
}
|
||||
|
||||
v.push_back( T() );
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test<int>();
|
||||
test<float>();
|
||||
test<double>();
|
||||
test< std::vector<int> >();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
Reference in New Issue
Block a user