Globally change _ref to _view in file names and files. Add infrastructure for testing compliance with the TS. Add the first missing TS item, the basic_string_view typedef traits_type.

This commit is contained in:
Beman
2015-07-05 16:44:40 -04:00
parent 20b78d7667
commit 57d2173de9
10 changed files with 386 additions and 229 deletions
+29 -29
View File
@@ -5,16 +5,16 @@
* http://www.boost.org/LICENSE_1_0.txt)
*/
/*!
* \file string_ref_test_io.cpp
* \file string_view_test_io.cpp
* \author Andrey Semashev
* \date 26.05.2013
*
* \brief This header contains tests for stream operations of \c basic_string_ref.
* \brief This header contains tests for stream operations of \c basic_string_view.
*/
#define BOOST_TEST_MODULE string_ref_test_io
#define BOOST_TEST_MODULE string_view_test_io
#include <boost/utility/string_ref.hpp>
#include <boost/utility/string_view.hpp>
#include <iomanip>
#include <sstream>
@@ -60,7 +60,7 @@ struct context
context()
{
boost::string_ref str = test_strings[0];
boost::string_view str = test_strings[0];
std::copy(str.begin(), str.end(), std::back_inserter(begin));
str = test_strings[1];
@@ -72,17 +72,17 @@ struct context
};
// Test regular output
BOOST_AUTO_TEST_CASE_TEMPLATE(string_ref_output, CharT, char_types)
BOOST_AUTO_TEST_CASE_TEMPLATE(string_view_output, CharT, char_types)
{
typedef CharT char_type;
typedef std::basic_string< char_type > string_type;
typedef std::basic_ostringstream< char_type > ostream_type;
typedef boost::basic_string_ref< char_type > string_ref_type;
typedef boost::basic_string_view< char_type > string_view_type;
context< char_type > ctx;
ostream_type strm;
strm << string_ref_type(ctx.abcd);
strm << string_view_type(ctx.abcd);
BOOST_CHECK(strm.str() == ctx.abcd);
}
@@ -92,41 +92,41 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(padding, CharT, char_types)
typedef CharT char_type;
typedef std::basic_string< char_type > string_type;
typedef std::basic_ostringstream< char_type > ostream_type;
typedef boost::basic_string_ref< char_type > string_ref_type;
typedef boost::basic_string_view< char_type > string_view_type;
context< char_type > ctx;
// Test for padding
{
ostream_type strm_ref;
strm_ref << ctx.begin << std::setw(8) << string_ref_type(ctx.abcd) << ctx.end;
ostream_type strm_view;
strm_view << ctx.begin << std::setw(8) << string_view_type(ctx.abcd) << ctx.end;
ostream_type strm_correct;
strm_correct << ctx.begin << std::setw(8) << ctx.abcd << ctx.end;
BOOST_CHECK(strm_ref.str() == strm_correct.str());
BOOST_CHECK(strm_view.str() == strm_correct.str());
}
// Test for long padding
{
ostream_type strm_ref;
strm_ref << ctx.begin << std::setw(100) << string_ref_type(ctx.abcd) << ctx.end;
ostream_type strm_view;
strm_view << ctx.begin << std::setw(100) << string_view_type(ctx.abcd) << ctx.end;
ostream_type strm_correct;
strm_correct << ctx.begin << std::setw(100) << ctx.abcd << ctx.end;
BOOST_CHECK(strm_ref.str() == strm_correct.str());
BOOST_CHECK(strm_view.str() == strm_correct.str());
}
// Test that short width does not truncate the string
{
ostream_type strm_ref;
strm_ref << ctx.begin << std::setw(1) << string_ref_type(ctx.abcd) << ctx.end;
ostream_type strm_view;
strm_view << ctx.begin << std::setw(1) << string_view_type(ctx.abcd) << ctx.end;
ostream_type strm_correct;
strm_correct << ctx.begin << std::setw(1) << ctx.abcd << ctx.end;
BOOST_CHECK(strm_ref.str() == strm_correct.str());
BOOST_CHECK(strm_view.str() == strm_correct.str());
}
}
@@ -136,17 +136,17 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(padding_fill, CharT, char_types)
typedef CharT char_type;
typedef std::basic_string< char_type > string_type;
typedef std::basic_ostringstream< char_type > ostream_type;
typedef boost::basic_string_ref< char_type > string_ref_type;
typedef boost::basic_string_view< char_type > string_view_type;
context< char_type > ctx;
ostream_type strm_ref;
strm_ref << ctx.begin << std::setfill(static_cast< char_type >('x')) << std::setw(8) << string_ref_type(ctx.abcd) << ctx.end;
ostream_type strm_view;
strm_view << ctx.begin << std::setfill(static_cast< char_type >('x')) << std::setw(8) << string_view_type(ctx.abcd) << ctx.end;
ostream_type strm_correct;
strm_correct << ctx.begin << std::setfill(static_cast< char_type >('x')) << std::setw(8) << ctx.abcd << ctx.end;
BOOST_CHECK(strm_ref.str() == strm_correct.str());
BOOST_CHECK(strm_view.str() == strm_correct.str());
}
// Test support for alignment
@@ -155,29 +155,29 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(alignment, CharT, char_types)
typedef CharT char_type;
typedef std::basic_string< char_type > string_type;
typedef std::basic_ostringstream< char_type > ostream_type;
typedef boost::basic_string_ref< char_type > string_ref_type;
typedef boost::basic_string_view< char_type > string_view_type;
context< char_type > ctx;
// Left alignment
{
ostream_type strm_ref;
strm_ref << ctx.begin << std::left << std::setw(8) << string_ref_type(ctx.abcd) << ctx.end;
ostream_type strm_view;
strm_view << ctx.begin << std::left << std::setw(8) << string_view_type(ctx.abcd) << ctx.end;
ostream_type strm_correct;
strm_correct << ctx.begin << std::left << std::setw(8) << ctx.abcd << ctx.end;
BOOST_CHECK(strm_ref.str() == strm_correct.str());
BOOST_CHECK(strm_view.str() == strm_correct.str());
}
// Right alignment
{
ostream_type strm_ref;
strm_ref << ctx.begin << std::right << std::setw(8) << string_ref_type(ctx.abcd) << ctx.end;
ostream_type strm_view;
strm_view << ctx.begin << std::right << std::setw(8) << string_view_type(ctx.abcd) << ctx.end;
ostream_type strm_correct;
strm_correct << ctx.begin << std::right << std::setw(8) << ctx.abcd << ctx.end;
BOOST_CHECK(strm_ref.str() == strm_correct.str());
BOOST_CHECK(strm_view.str() == strm_correct.str());
}
}