From 6b0dc88eefdc3d79118aaba1ff8fd9a4e595c2ef Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 13 Jan 2026 15:44:22 +0200 Subject: [PATCH] Add test_to_chars_3.cpp --- test/Jamfile.v2 | 2 ++ test/test_to_chars_3.cpp | 49 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 test/test_to_chars_3.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index f2aa304..28fb0b8 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -120,6 +120,8 @@ run test_to_chars.cpp : : : BOOST_UUID_NO_SIMD : test_to_chars_no_simd ; run test_to_chars_2.cpp ; run test_to_chars_2.cpp : : : BOOST_UUID_NO_SIMD : test_to_chars_2_no_simd ; +run test_to_chars_3.cpp ; + run test_from_chars.cpp ; run test_from_chars.cpp : : : BOOST_UUID_NO_SIMD : test_from_chars_no_simd ; run test_from_chars_2.cpp ; diff --git a/test/test_to_chars_3.cpp b/test/test_to_chars_3.cpp new file mode 100644 index 0000000..ee5df7c --- /dev/null +++ b/test/test_to_chars_3.cpp @@ -0,0 +1,49 @@ +// Copyright 2026 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& u, Ch const* expected ) +{ + std::basic_string str; + + to_chars( u, std::back_inserter( str ) ); + + BOOST_TEST( str == expected ); +} + +int main() +{ + uuid const u1 = {{ 0 }}; + uuid const u2 = {{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }}; + uuid const u3 = {{ 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef, 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef }}; + + test( u1, "00000000-0000-0000-0000-000000000000" ); + test( u2, "00010203-0405-0607-0809-0a0b0c0d0e0f" ); + test( u3, "12345678-90ab-cdef-1234-567890abcdef" ); + + test( u1, L"00000000-0000-0000-0000-000000000000" ); + test( u2, L"00010203-0405-0607-0809-0a0b0c0d0e0f" ); + test( u3, L"12345678-90ab-cdef-1234-567890abcdef" ); + + test( u1, u"00000000-0000-0000-0000-000000000000" ); + test( u2, u"00010203-0405-0607-0809-0a0b0c0d0e0f" ); + test( u3, u"12345678-90ab-cdef-1234-567890abcdef" ); + + test( u1, U"00000000-0000-0000-0000-000000000000" ); + test( u2, U"00010203-0405-0607-0809-0a0b0c0d0e0f" ); + test( u3, U"12345678-90ab-cdef-1234-567890abcdef" ); + + test( u1, u8"00000000-0000-0000-0000-000000000000" ); + test( u2, u8"00010203-0405-0607-0809-0a0b0c0d0e0f" ); + test( u3, u8"12345678-90ab-cdef-1234-567890abcdef" ); + + return boost::report_errors(); +}