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

Make string_generator support string-like types like uuid_from_string does

This commit is contained in:
Peter Dimov
2026-01-09 21:44:26 +02:00
parent 190ee28b1d
commit 8febad40ed
2 changed files with 25 additions and 5 deletions

View File

@@ -5,13 +5,25 @@
#include <boost/uuid/string_generator.hpp>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <boost/core/detail/string_view.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <string>
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
# include <string_view>
#endif
using namespace boost::uuids;
template<class Ch> void test( uuid const& expected, Ch const* str )
{
BOOST_TEST_EQ( string_generator()( str ), expected );
BOOST_TEST_EQ( string_generator()( std::basic_string<Ch>( str ) ), expected );
BOOST_TEST_EQ( string_generator()( boost::core::basic_string_view<Ch>( str ) ), expected );
#if !defined(BOOST_NO_CXX17_HDR_STRING_VIEW)
BOOST_TEST_EQ( string_generator()( std::basic_string_view<Ch>( str ) ), expected );
#endif
}
int main()