-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathunitest.cpp
41 lines (30 loc) · 924 Bytes
/
unitest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "unitest.h"
#include <functional>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include "websocket/WSProtocol.h"
using namespace ws;
void decFrameCallback(unsigned char* data, int len, void* context)
{
std::cout << "decframe,data=" << data << "len=" << len << std::endl;
}
WSProtocol decProto;
void encFrameCallback(unsigned char* data, int len, void* context)
{
decProto.decodeFrame(data, len, context, decFrameCallback);
}
void test_protocol()
{
//prepare for test data
unsigned char chardata[100];
memset(chardata, 2, 100);
unsigned char shortdata[460];
memset(shortdata, 3, 460);
unsigned char slicedata[2048];
memset(slicedata, 4, 2048);
WSProtocol proto;
proto.encodeFrame(chardata, 100, eTextFrame, NULL, encFrameCallback);
proto.encodeFrame(shortdata, 460, eTextFrame, NULL, encFrameCallback);
proto.encodeFrame(slicedata, 2048, eTextFrame, NULL, encFrameCallback);
}