2
0
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:
Peter Dimov
2025-06-28 19:03:49 +03:00
parent 894d0821b0
commit 575469e5f6
3 changed files with 38 additions and 0 deletions

View File

@@ -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)

View File

@@ -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 ;

View 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();
}