mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-24 11:54:49 +00:00
Add tests for mg_ws_wrap() and messages > 128 bytes
This commit is contained in:
1 parent
6b3d9d9baf
commit
3b5a9e2d4b
2 files changed
+13
-2
No files matched your search
+12
-1
@@ -1709,7 +1709,12 @@ static void test_check_ip_acl(void) {
|
||||
static void w3(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
|
||||
// MG_INFO(("ev %d", ev));
|
||||
if (ev == MG_EV_WS_OPEN) {
|
||||
char buf[8192];
|
||||
memset(buf, 'A', sizeof(buf));
|
||||
mg_ws_send(c, "hi there!", 9, WEBSOCKET_OP_TEXT);
|
||||
mg_printf(c, "%s", "boo");
|
||||
mg_ws_wrap(c, 3, WEBSOCKET_OP_TEXT),
|
||||
mg_ws_send(c, buf, sizeof(buf), WEBSOCKET_OP_TEXT);
|
||||
} else if (ev == MG_EV_WS_MSG) {
|
||||
struct mg_ws_message *wm = (struct mg_ws_message *) ev_data;
|
||||
ASSERT(mg_strcmp(wm->data, mg_str("lebowski")) == 0);
|
||||
@@ -1742,7 +1747,13 @@ static void w2(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
|
||||
}
|
||||
} else if (ev == MG_EV_WS_MSG) {
|
||||
struct mg_ws_message *wm = (struct mg_ws_message *) ev_data;
|
||||
ASSERT(mg_strcmp(wm->data, mg_str("hi there!")) == 0);
|
||||
if (wm->data.len == 9) {
|
||||
ASSERT(mg_strcmp(wm->data, mg_str("hi there!")) == 0);
|
||||
} else if (wm->data.len == 3) {
|
||||
ASSERT(mg_strcmp(wm->data, mg_str("boo")) == 0);
|
||||
} else {
|
||||
ASSERT(wm->data.len == 8192);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user