JD2022-TU1/main/unittests/core/HttpServer/WebSocket/WebSocketBinaryMessage.cpp

24 lines
659 B
C++

#include "precompiled_unittests_core.h"
#include "core/HttpServer/WebSocket/WebSocketBinaryMessage.h"
#include "mongoose/custom/mongoose.h"
namespace ITF
{
TEST(WebSocketBinaryMessage, test_construction)
{
u8 msgBin[] = { 0x11, 0x22, 0x56, 0xf3, 0x4a, 0xbf };
mg_connection conn;
conn.content = reinterpret_cast<char*>(msgBin);
conn.content_len = ITF_ARRAY_SIZE(msgBin);
conn.is_websocket = 1;
conn.wsbits = 0x80 | WEBSOCKET_OPCODE_BINARY;
WebSocketBinaryMessage msg(conn);
ASSERT_EQ(conn.content_len, msg.getContentLen());
EXPECT_EQ(0, memcmp(conn.content, msg.getContent(), conn.content_len));
}
} // namespace ITF