mirror of
https://github.com/boostorg/uuid.git
synced 2026-01-19 04:42:16 +00:00
Add test_boost_unordered.cpp, test_std_unordered.cpp
This commit is contained in:
@@ -101,9 +101,14 @@ run test_tagging.cpp ;
|
||||
run test_uuid_class.cpp ;
|
||||
run test_uuid_in_map.cpp ;
|
||||
|
||||
# test hash functions
|
||||
# test hashing support
|
||||
|
||||
run test_hash.cpp ;
|
||||
run test_boost_unordered.cpp ;
|
||||
run test_std_unordered.cpp ;
|
||||
|
||||
# test hash functions
|
||||
|
||||
run test_md5.cpp ;
|
||||
run test_md5.cpp : : : <define>BOOST_UUID_COMPAT_PRE_1_71_MD5 : test_md5_pre_1_71_compat ;
|
||||
run test_sha1.cpp ;
|
||||
|
||||
42
test/test_boost_unordered.cpp
Normal file
42
test/test_boost_unordered.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright 2024 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/uuid/uuid.hpp>
|
||||
#include <boost/uuid/random_generator.hpp>
|
||||
#include <boost/unordered/unordered_flat_set.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::uuids;
|
||||
|
||||
std::size_t const N = 256;
|
||||
|
||||
{
|
||||
boost::unordered_flat_set<uuid> set;
|
||||
|
||||
random_generator gen;
|
||||
|
||||
for( std::size_t i = 0; i < N; ++i )
|
||||
{
|
||||
set.insert( gen() );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( set.size(), N );
|
||||
}
|
||||
|
||||
{
|
||||
boost::unordered_flat_set<uuid> set;
|
||||
|
||||
for( std::size_t i = 0; i < N; ++i )
|
||||
{
|
||||
uuid id = { { static_cast<std::uint8_t>( i ), 0 } };
|
||||
set.insert( id );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( set.size(), N );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
42
test/test_std_unordered.cpp
Normal file
42
test/test_std_unordered.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright 2024 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/uuid/uuid.hpp>
|
||||
#include <boost/uuid/random_generator.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <unordered_set>
|
||||
|
||||
int main()
|
||||
{
|
||||
using namespace boost::uuids;
|
||||
|
||||
std::size_t const N = 256;
|
||||
|
||||
{
|
||||
std::unordered_set<uuid> set;
|
||||
|
||||
random_generator gen;
|
||||
|
||||
for( std::size_t i = 0; i < N; ++i )
|
||||
{
|
||||
set.insert( gen() );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( set.size(), N );
|
||||
}
|
||||
|
||||
{
|
||||
std::unordered_set<uuid> set;
|
||||
|
||||
for( std::size_t i = 0; i < N; ++i )
|
||||
{
|
||||
uuid id = { { static_cast<std::uint8_t>( i ), 0 } };
|
||||
set.insert( id );
|
||||
}
|
||||
|
||||
BOOST_TEST_EQ( set.size(), N );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
Reference in New Issue
Block a user