2
0
mirror of https://github.com/boostorg/uuid.git synced 2026-01-19 04:42:16 +00:00

Add test_time_generator

This commit is contained in:
Peter Dimov
2024-05-03 17:25:06 +03:00
parent ea6bed60cd
commit 009bf1c8f5
3 changed files with 36 additions and 6 deletions

View File

@@ -28,12 +28,12 @@ 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_namespaces.cpp)
boost_test(TYPE run SOURCES test_name_generator.cpp LINK_LIBRARIES Boost::predef)
boost_test(TYPE run SOURCES test_namespaces.cpp)
boost_test(TYPE run SOURCES test_random_generator.cpp LINK_LIBRARIES Boost::random Boost::predef)
boost_test(TYPE run SOURCES test_time_generator.cpp LINK_LIBRARIES $<$<CXX_COMPILER_ID:GNU>:atomic>)
boost_test(TYPE run SOURCES test_time_generator_v1.cpp LINK_LIBRARIES $<$<CXX_COMPILER_ID:GNU>:atomic>)
boost_test(TYPE run SOURCES test_time_generator_v1_2.cpp LINK_LIBRARIES $<$<CXX_COMPILER_ID:GNU>:atomic>)
boost_test(TYPE run SOURCES test_time_generator_v1_3.cpp LINK_LIBRARIES $<$<CXX_COMPILER_ID:GNU>:atomic> Threads::Threads)

View File

@@ -76,14 +76,16 @@ run test_uuid_clock.cpp ;
run test_nil_generator.cpp ;
run test_string_generator.cpp ;
run test_namespaces.cpp ;
run test_name_generator.cpp ;
run test_namespaces.cpp ;
run test_random_generator.cpp ;
lib atomic ;
run test_time_generator.cpp
: : : <toolset>gcc:<library>atomic <toolset>clang-linux:<library>atomic
<toolset>gcc-4.8,<address-model>32:<build>no ;
run test_time_generator_v1.cpp
: : : <toolset>gcc:<library>atomic <toolset>clang-linux:<library>atomic
<toolset>gcc-4.8,<address-model>32:<build>no ;

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/uuid/time_generator.hpp>
#include <boost/core/lightweight_test.hpp>
using namespace boost::uuids;
int main()
{
uuid u1 = time_generator_v1()();
BOOST_TEST_EQ( u1.variant(), uuid::variant_rfc_4122 );
BOOST_TEST_EQ( u1.version(), uuid::version_time_based );
uuid u2 = time_generator_v6()();
BOOST_TEST_EQ( u2.variant(), uuid::variant_rfc_4122 );
BOOST_TEST_EQ( u2.version(), uuid::version_time_based_v6 );
uuid u3 = time_generator_v7()();
BOOST_TEST_EQ( u3.variant(), uuid::variant_rfc_4122 );
BOOST_TEST_EQ( u3.version(), uuid::version_time_based_v7 );
return boost::report_errors();
}