comparison spec/net_websocket_frames_spec.lua @ 11200:bf8f2da84007

Merge 0.11->trunk
author Kim Alvefur <zash@zash.se>
date Thu, 05 Nov 2020 22:31:25 +0100
parents 51e5149ed0ad
children
comparison
equal deleted inserted replaced
11199:6c7c50a4de32 11200:bf8f2da84007
50 ["MASK"] = true; 50 ["MASK"] = true;
51 ["RSV1"] = false; 51 ["RSV1"] = false;
52 ["RSV2"] = false; 52 ["RSV2"] = false;
53 ["RSV3"] = false; 53 ["RSV3"] = false;
54 }; 54 };
55 ping = {
56 ["opcode"] = 0x9;
57 ["length"] = 4;
58 ["data"] = "ping";
59 ["FIN"] = true;
60 ["MASK"] = false;
61 ["RSV1"] = false;
62 ["RSV2"] = false;
63 ["RSV3"] = false;
64 };
65 pong = {
66 ["opcode"] = 0xa;
67 ["length"] = 4;
68 ["data"] = "pong";
69 ["FIN"] = true;
70 ["MASK"] = false;
71 ["RSV1"] = false;
72 ["RSV2"] = false;
73 ["RSV3"] = false;
74 };
55 } 75 }
56 76
57 describe("build", function () 77 describe("build", function ()
58 local build = nwf.build; 78 local build = nwf.build;
59 it("works", function () 79 it("works", function ()
60 assert.equal("\0\0", build(test_frames.simple_empty)); 80 assert.equal("\0\0", build(test_frames.simple_empty));
61 assert.equal("\0\5hello", build(test_frames.simple_data)); 81 assert.equal("\0\5hello", build(test_frames.simple_data));
62 assert.equal("\128\0", build(test_frames.simple_fin)); 82 assert.equal("\128\0", build(test_frames.simple_fin));
63 assert.equal("\128\133 \0 \0HeLlO", build(test_frames.with_mask)) 83 assert.equal("\128\133 \0 \0HeLlO", build(test_frames.with_mask))
64 assert.equal("\128\128 \0 \0", build(test_frames.empty_with_mask)) 84 assert.equal("\128\128 \0 \0", build(test_frames.empty_with_mask))
85 assert.equal("\137\4ping", build(test_frames.ping));
86 assert.equal("\138\4pong", build(test_frames.pong));
65 end); 87 end);
66 end); 88 end);
67 89
68 describe("parse", function () 90 describe("parse", function ()
69 local parse = nwf.parse; 91 local parse = nwf.parse;
70 it("works", function () 92 it("works", function ()
71 assert.same(test_frames.simple_empty, parse("\0\0")); 93 assert.same(test_frames.simple_empty, parse("\0\0"));
72 assert.same(test_frames.simple_data, parse("\0\5hello")); 94 assert.same(test_frames.simple_data, parse("\0\5hello"));
73 assert.same(test_frames.simple_fin, parse("\128\0")); 95 assert.same(test_frames.simple_fin, parse("\128\0"));
74 assert.same(test_frames.with_mask, parse("\128\133 \0 \0HeLlO")); 96 assert.same(test_frames.with_mask, parse("\128\133 \0 \0HeLlO"));
97 assert.same(test_frames.ping, parse("\137\4ping"));
98 assert.same(test_frames.pong, parse("\138\4pong"));
75 end); 99 end);
76 end); 100 end);
77 101
78 end); 102 end);
79 103