mirror of
https://github.com/boostorg/uuid.git
synced 2026-01-19 04:42:16 +00:00
Add test_string_generator_cx.cpp
This commit is contained in:
@@ -82,5 +82,6 @@ boost_test(TYPE run SOURCES test_detail_random_provider.cpp LINK_LIBRARIES Boost
|
||||
boost_test(TYPE run SOURCES test_serialization.cpp LINK_LIBRARIES Boost::serialization)
|
||||
|
||||
boost_test(TYPE compile SOURCES test_uuid_cx.cpp)
|
||||
boost_test(TYPE run SOURCES test_string_generator_cx.cpp)
|
||||
|
||||
boost_test(TYPE run SOURCES quick.cpp)
|
||||
|
||||
@@ -206,6 +206,7 @@ run test_detail_random_provider.cpp
|
||||
# constexpr tests
|
||||
|
||||
compile test_uuid_cx.cpp ;
|
||||
run test_string_generator_cx.cpp ;
|
||||
|
||||
# 'quick' test for CI
|
||||
|
||||
|
||||
46
test/test_string_generator_cx.cpp
Normal file
46
test/test_string_generator_cx.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
// Copyright 2025 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/uuid/string_generator.hpp>
|
||||
#include <boost/uuid/uuid_io.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX14_CONSTEXPR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("Skipping test because BOOST_NO_CXX14_CONSTEXPR is defined")
|
||||
int main() {}
|
||||
|
||||
#elif defined(BOOST_GCC) && BOOST_GCC < 60000
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("Skipping test because BOOST_GCC < 60000")
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
constexpr boost::uuids::string_generator gen;
|
||||
|
||||
constexpr auto u1 = gen( "00000000-0000-0000-0000-000000000000" );
|
||||
constexpr auto u2 = gen( "0123456789abcdef0123456789ABCDEF" );
|
||||
constexpr auto u3 = gen( "{0123456789abcdef0123456789ABCDEF}" );
|
||||
constexpr auto u4 = gen( "01234567-89AB-CDEF-0123-456789abcdef" );
|
||||
constexpr auto u5 = gen( "{01234567-89AB-CDEF-0123-456789abcdef}" );
|
||||
|
||||
int main()
|
||||
{
|
||||
boost::uuids::uuid const exp1 = {{}};
|
||||
boost::uuids::uuid const exp2 = {{ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef }};
|
||||
|
||||
BOOST_TEST_EQ( u1, exp1 );
|
||||
|
||||
BOOST_TEST_EQ( u2, exp2 );
|
||||
BOOST_TEST_EQ( u3, exp2 );
|
||||
BOOST_TEST_EQ( u4, exp2 );
|
||||
BOOST_TEST_EQ( u5, exp2 );
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user