Add write_frames unit test

This commit is contained in:
Vinnie Falco
2017-04-14 12:32:36 -07:00
parent f8b0c22501
commit 6ec2e10c77
2 changed files with 33 additions and 2 deletions

View File

@ -3,6 +3,7 @@
* Require Visual Studio 2015 Update 3 or later
* Use fwrite return value in file_body
* Add decorator unit test
* Add write_frames unit test
--------------------------------------------------------------------------------

View File

@ -805,6 +805,32 @@ public:
}
#endif
/*
https://github.com/vinniefalco/Beast/issues/300
Write a message as two individual frames
*/
void
testWriteFrames(endpoint_type const& ep)
{
error_code ec;
socket_type sock{ios_};
sock.connect(ep, ec);
if(! BEAST_EXPECTS(! ec, ec.message()))
return;
stream<socket_type&> ws{sock};
ws.handshake("localhost", "/", ec);
if(! BEAST_EXPECTS(! ec, ec.message()))
return;
ws.write_frame(false, sbuf("u"));
ws.write_frame(true, sbuf("v"));
streambuf sb;
opcode op;
ws.read(op, sb, ec);
if(! BEAST_EXPECTS(! ec, ec.message()))
return;
}
void
testAsyncWriteFrame(endpoint_type const& ep)
{
@ -1281,9 +1307,14 @@ public:
testBadHandshakes();
testBadResponses();
permessage_deflate pmd;
pmd.client_enable = false;
pmd.server_enable = false;
{
error_code ec;
::websocket::sync_echo_server server{nullptr};
server.set_option(pmd);
server.open(any, ec);
BEAST_EXPECTS(! ec, ec.message());
auto const ep = server.local_endpoint();
@ -1293,6 +1324,7 @@ public:
testInvokable3(ep);
testInvokable4(ep);
//testInvokable5(ep);
testWriteFrames(ep);
testAsyncWriteFrame(ep);
}
@ -1340,8 +1372,6 @@ public:
}
};
permessage_deflate pmd;
pmd.client_enable = false;
pmd.server_enable = false;
doClientTests(pmd);