mirror of
https://github.com/boostorg/beast.git
synced 2025-08-01 05:44:38 +02:00
Increase ostream test coverage
This commit is contained in:
@@ -54,10 +54,7 @@ operator<<(std::ostream& os,
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template<
|
||||
class DynamicBuffer,
|
||||
class CharT,
|
||||
class Traits
|
||||
>
|
||||
class DynamicBuffer, class CharT, class Traits>
|
||||
class ostream_buffer
|
||||
: public std::basic_streambuf<CharT, Traits>
|
||||
{
|
||||
@@ -115,7 +112,7 @@ ostream_buffer<DynamicBuffer, CharT, Traits>::
|
||||
overflow(int_type ch) ->
|
||||
int_type
|
||||
{
|
||||
if(ch != traits_type::eof())
|
||||
if(! Traits::eq_int_type(ch, Traits::eof()))
|
||||
{
|
||||
Traits::assign(*this->pptr(), ch);
|
||||
flush(1);
|
||||
|
@@ -18,12 +18,33 @@ namespace beast {
|
||||
class ostream_test : public beast::unit_test::suite
|
||||
{
|
||||
public:
|
||||
void run() override
|
||||
void
|
||||
run() override
|
||||
{
|
||||
multi_buffer b;
|
||||
ostream(b) << "Hello, world!\n";
|
||||
BEAST_EXPECT(boost::lexical_cast<std::string>(
|
||||
buffers(b.data())) == "Hello, world!\n");
|
||||
{
|
||||
multi_buffer b;
|
||||
auto os = ostream(b);
|
||||
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