Add test with types that return void* from begin/end. Refs #36.

This commit is contained in:
Peter Dimov
2024-03-05 17:44:03 +02:00
parent 7288df8bee
commit 28cc18a4bc
3 changed files with 70 additions and 0 deletions

View File

@@ -125,3 +125,6 @@ run is_tuple_like_test.cpp ;
run hash_tuple_like_test.cpp ;
run hash_tuple_like_test2.cpp
: : : <warnings>extra ;
run is_range_test4.cpp ;
run hash_container_test2.cpp ;

View File

@@ -0,0 +1,39 @@
// Copyright 2024 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>
struct X1
{
void* begin() const { return nullptr; }
void* end() const { return nullptr; }
};
std::size_t hash_value( X1 const& )
{
return 1;
}
struct X2
{
void const* begin() const { return nullptr; }
void const* end() const { return nullptr; }
};
std::size_t hash_value( X2 const& )
{
return 2;
}
int main()
{
X1 x1;
BOOST_TEST_EQ( boost::hash<X1>()( x1 ), 1 );
X2 x2;
BOOST_TEST_EQ( boost::hash<X2>()( x2 ), 2 );
return boost::report_errors();
}

28
test/is_range_test4.cpp Normal file
View File

@@ -0,0 +1,28 @@
// Copyright 2024 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/container_hash/is_range.hpp>
#include <boost/core/lightweight_test_trait.hpp>
struct X1
{
void* begin() const;
void* end() const;
};
struct X2
{
void const* begin() const;
void const* end() const;
};
int main()
{
using boost::container_hash::is_range;
BOOST_TEST_TRAIT_FALSE((is_range<X1>));
BOOST_TEST_TRAIT_FALSE((is_range<X2>));
return boost::report_errors();
}