mirror of
https://github.com/boostorg/beast.git
synced 2025-08-03 14:54:32 +02:00
Increase ostream test coverage
This commit is contained in:
@@ -54,10 +54,7 @@ operator<<(std::ostream& os,
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
template<
|
template<
|
||||||
class DynamicBuffer,
|
class DynamicBuffer, class CharT, class Traits>
|
||||||
class CharT,
|
|
||||||
class Traits
|
|
||||||
>
|
|
||||||
class ostream_buffer
|
class ostream_buffer
|
||||||
: public std::basic_streambuf<CharT, Traits>
|
: public std::basic_streambuf<CharT, Traits>
|
||||||
{
|
{
|
||||||
@@ -115,7 +112,7 @@ ostream_buffer<DynamicBuffer, CharT, Traits>::
|
|||||||
overflow(int_type ch) ->
|
overflow(int_type ch) ->
|
||||||
int_type
|
int_type
|
||||||
{
|
{
|
||||||
if(ch != traits_type::eof())
|
if(! Traits::eq_int_type(ch, Traits::eof()))
|
||||||
{
|
{
|
||||||
Traits::assign(*this->pptr(), ch);
|
Traits::assign(*this->pptr(), ch);
|
||||||
flush(1);
|
flush(1);
|
||||||
|
@@ -18,12 +18,33 @@ namespace beast {
|
|||||||
class ostream_test : public beast::unit_test::suite
|
class ostream_test : public beast::unit_test::suite
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void run() override
|
void
|
||||||
|
run() override
|
||||||
{
|
{
|
||||||
multi_buffer b;
|
{
|
||||||
ostream(b) << "Hello, world!\n";
|
multi_buffer b;
|
||||||
BEAST_EXPECT(boost::lexical_cast<std::string>(
|
auto os = ostream(b);
|
||||||
buffers(b.data())) == "Hello, world!\n");
|
os << "Hello, world!\n";
|
||||||
|
os.flush();
|
||||||
|
BEAST_EXPECT(boost::lexical_cast<std::string>(
|
||||||
|
buffers(b.data())) == "Hello, world!\n");
|
||||||
|
auto os2 = std::move(os);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
auto const s =
|
||||||
|
"0123456789abcdef" "0123456789abcdef" "0123456789abcdef" "0123456789abcdef"
|
||||||
|
"0123456789abcdef" "0123456789abcdef" "0123456789abcdef" "0123456789abcdef"
|
||||||
|
"0123456789abcdef" "0123456789abcdef" "0123456789abcdef" "0123456789abcdef"
|
||||||
|
"0123456789abcdef" "0123456789abcdef" "0123456789abcdef" "0123456789abcdef"
|
||||||
|
"0123456789abcdef" "0123456789abcdef" "0123456789abcdef" "0123456789abcdef"
|
||||||
|
"0123456789abcdef" "0123456789abcdef" "0123456789abcdef" "0123456789abcdef"
|
||||||
|
"0123456789abcdef" "0123456789abcdef" "0123456789abcdef" "0123456789abcdef"
|
||||||
|
"0123456789abcdef" "0123456789abcdef" "0123456789abcdef" "0123456789abcdef";
|
||||||
|
multi_buffer b(512);
|
||||||
|
ostream(b) << s;
|
||||||
|
BEAST_EXPECT(boost::lexical_cast<std::string>(
|
||||||
|
buffers(b.data())) == s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user