31 lines
774 B
C++
31 lines
774 B
C++
#include "precompiled_unittests_core.h"
|
|
|
|
#include "core/HttpServer/WebSocket/WebSocketTextMessage.h"
|
|
#include "mongoose/custom/mongoose.h"
|
|
|
|
namespace ITF
|
|
{
|
|
|
|
TEST(WebSocketTextMessage, test_construction_from_MgConnection)
|
|
{
|
|
const char* msgText = "Hello world";
|
|
|
|
mg_connection conn;
|
|
conn.content = const_cast<char*>(msgText);
|
|
conn.content_len = strlen(msgText);
|
|
conn.is_websocket = 1;
|
|
conn.wsbits = 0x80 | WEBSOCKET_OPCODE_TEXT;
|
|
|
|
WebSocketTextMessage msg(conn);
|
|
EXPECT_STREQ(msgText, msg.getContent());
|
|
}
|
|
|
|
TEST(WebSocketTextMessage, test_construction_from_String8)
|
|
{
|
|
String8 content("Hello world");
|
|
|
|
WebSocketTextMessage msg(content.cStr (), content.getLen ());
|
|
EXPECT_STREQ(content.cStr(), msg.getContent());
|
|
}
|
|
|
|
} // namespace ITF
|