Update sv_find_first_of_test

This commit is contained in:
Peter Dimov
2021-10-08 10:21:07 +03:00
parent c3cfe7a861
commit af3e6a667b

View File

@ -4,6 +4,7 @@
#include <boost/core/string_view.hpp>
#include <boost/core/lightweight_test.hpp>
#include <algorithm>
#include <cstddef>
int main()
@ -380,6 +381,31 @@ int main()
BOOST_TEST_EQ( sv.find_first_of( L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 12 ), npos );
}
{
char str[ 256 ];
for( int i = 0; i < 256; ++i )
{
str[ i ] = static_cast< unsigned char >( i );
}
boost::core::string_view sv( str, 256 );
for( int i = 0; i < 256; ++i )
{
std::string needle( 12, static_cast< unsigned char >( i ) );
BOOST_TEST_EQ( sv.find_first_of( needle ), i );
}
std::reverse( str, str + 256 );
for( int i = 0; i < 256; ++i )
{
std::string needle( 12, static_cast< unsigned char >( i ) );
BOOST_TEST_EQ( sv.find_first_of( needle ), 255 - i );
}
}
#if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L
{