diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 8d86a3f..524b781 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -105,7 +105,9 @@ run test_uuid_clock.cpp ; # test generators run test_nil_generator.cpp ; + run test_string_generator.cpp ; +run test_string_generator_2.cpp ; run test_random_generator.cpp : : : /boost/random//boost_random /boost/predef//boost_predef ; diff --git a/test/test_string_generator_2.cpp b/test/test_string_generator_2.cpp new file mode 100644 index 0000000..ada3743 --- /dev/null +++ b/test/test_string_generator_2.cpp @@ -0,0 +1,47 @@ +// Copyright 2025 Peter Dimov +// Distributed under the Boost Software License, Version 1.0. +// https://www.boost.org/LICENSE_1_0.txt + +#include +#include +#include +#include +#include + +using namespace boost::uuids; + +template void test( uuid const& expected, Ch const* str ) +{ + BOOST_TEST_EQ( string_generator()( str ), expected ); +} + +int main() +{ + uuid const exp = {{ 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef, 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef }}; + + test( exp, "12345678-90AB-CDEF-1234-567890abcdef" ); + test( exp, L"12345678-90AB-CDEF-1234-567890abcdef" ); + test( exp, u"12345678-90AB-CDEF-1234-567890abcdef" ); + test( exp, U"12345678-90AB-CDEF-1234-567890abcdef" ); + test( exp, u8"12345678-90AB-CDEF-1234-567890abcdef" ); + + test( exp, "{12345678-90AB-CDEF-1234-567890abcdef}" ); + test( exp, L"{12345678-90AB-CDEF-1234-567890abcdef}" ); + test( exp, u"{12345678-90AB-CDEF-1234-567890abcdef}" ); + test( exp, U"{12345678-90AB-CDEF-1234-567890abcdef}" ); + test( exp, u8"{12345678-90AB-CDEF-1234-567890abcdef}" ); + + test( exp, "1234567890ABCDEF1234567890abcdef" ); + test( exp, L"1234567890ABCDEF1234567890abcdef" ); + test( exp, u"1234567890ABCDEF1234567890abcdef" ); + test( exp, U"1234567890ABCDEF1234567890abcdef" ); + test( exp, u8"1234567890ABCDEF1234567890abcdef" ); + + test( exp, "{1234567890ABCDEF1234567890abcdef}" ); + test( exp, L"{1234567890ABCDEF1234567890abcdef}" ); + test( exp, u"{1234567890ABCDEF1234567890abcdef}" ); + test( exp, U"{1234567890ABCDEF1234567890abcdef}" ); + test( exp, u8"{1234567890ABCDEF1234567890abcdef}" ); + + return boost::report_errors(); +}