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

Add test_string_generator_cx2.cpp

This commit is contained in:
Peter Dimov
2025-12-23 04:21:49 +02:00
parent a851cf33ca
commit 83d3da399c
3 changed files with 47 additions and 1 deletions

View File

@@ -216,8 +216,12 @@ run test_constants.cpp ;
# constexpr tests
compile test_uuid_cx.cpp ;
run test_string_generator_cx.cpp ;
run test_string_generator_cx2.cpp ;
run test_constants_cx.cpp ;
run test_from_chars_cx.cpp ;
run test_from_chars_cx2.cpp ;

View File

@@ -6,7 +6,6 @@
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <boost/core/lightweight_test.hpp>
#include <string>
using namespace boost::uuids;

View File

@@ -0,0 +1,43 @@
// 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.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <boost/core/lightweight_test.hpp>
using namespace boost::uuids;
#define TEST(str) { BOOST_CXX14_CONSTEXPR auto u = string_generator()(str); BOOST_TEST_EQ(u, expected); }
int main()
{
uuid const expected = {{ 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef, 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef }};
TEST( "12345678-90AB-CDEF-1234-567890abcdef" );
TEST( L"12345678-90AB-CDEF-1234-567890abcdef" );
TEST( u"12345678-90AB-CDEF-1234-567890abcdef" );
TEST( U"12345678-90AB-CDEF-1234-567890abcdef" );
TEST( u8"12345678-90AB-CDEF-1234-567890abcdef" );
TEST( "{12345678-90AB-CDEF-1234-567890abcdef}" );
TEST( L"{12345678-90AB-CDEF-1234-567890abcdef}" );
TEST( u"{12345678-90AB-CDEF-1234-567890abcdef}" );
TEST( U"{12345678-90AB-CDEF-1234-567890abcdef}" );
TEST( u8"{12345678-90AB-CDEF-1234-567890abcdef}" );
TEST( "1234567890ABCDEF1234567890abcdef" );
TEST( L"1234567890ABCDEF1234567890abcdef" );
TEST( u"1234567890ABCDEF1234567890abcdef" );
TEST( U"1234567890ABCDEF1234567890abcdef" );
TEST( u8"1234567890ABCDEF1234567890abcdef" );
TEST( "{1234567890ABCDEF1234567890abcdef}" );
TEST( L"{1234567890ABCDEF1234567890abcdef}" );
TEST( u"{1234567890ABCDEF1234567890abcdef}" );
TEST( U"{1234567890ABCDEF1234567890abcdef}" );
TEST( u8"{1234567890ABCDEF1234567890abcdef}" );
return boost::report_errors();
}