mirror of
https://github.com/boostorg/uuid.git
synced 2026-01-19 04:42:16 +00:00
Add test_random_generator_2.cpp. Refs #174.
This commit is contained in:
@@ -39,6 +39,7 @@ boost_test(TYPE run SOURCES test_uuid_clock.cpp)
|
||||
boost_test(TYPE run SOURCES test_nil_generator.cpp)
|
||||
boost_test(TYPE run SOURCES test_string_generator.cpp)
|
||||
boost_test(TYPE run SOURCES test_random_generator.cpp LINK_LIBRARIES Boost::random Boost::predef)
|
||||
boost_test(TYPE run SOURCES test_random_generator_2.cpp)
|
||||
|
||||
boost_test(TYPE run SOURCES test_name_generator.cpp LINK_LIBRARIES Boost::predef)
|
||||
boost_test(TYPE run SOURCES test_namespaces.cpp)
|
||||
|
||||
@@ -102,8 +102,10 @@ run test_uuid_clock.cpp ;
|
||||
|
||||
run test_nil_generator.cpp ;
|
||||
run test_string_generator.cpp ;
|
||||
|
||||
run test_random_generator.cpp
|
||||
: : : <library>/boost/random//boost_random <library>/boost/predef//boost_predef ;
|
||||
run test_random_generator_2.cpp ;
|
||||
|
||||
run test_name_generator.cpp
|
||||
: : : <library>/boost/predef//boost_predef ;
|
||||
|
||||
35
test/test_random_generator_2.cpp
Normal file
35
test/test_random_generator_2.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/uuid/random_generator.hpp>
|
||||
#include <boost/uuid/string_generator.hpp>
|
||||
#include <boost/uuid/uuid.hpp>
|
||||
#include <boost/uuid/uuid_io.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <random>
|
||||
|
||||
using namespace boost::uuids;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::mt19937 rng( 0 );
|
||||
basic_random_generator<std::mt19937> gen( rng );
|
||||
|
||||
uuid expected = string_generator()( "ac0a7f8c-2faa-4497-b5a6-16b7c0cc21d8" );
|
||||
|
||||
BOOST_TEST_EQ( gen(), expected );
|
||||
}
|
||||
|
||||
{
|
||||
std::mt19937_64 rng( 0 );
|
||||
basic_random_generator<std::mt19937_64> gen( rng );
|
||||
|
||||
uuid expected = string_generator()( "3edc41cb-c537-4828-8bf9-403e7c3afdfd" );
|
||||
|
||||
BOOST_TEST_EQ( gen(), expected );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
Reference in New Issue
Block a user