Comparison

spec/util_dbuffer_spec.lua @ 11045:8c6bace13229

util.dbuffer: Fix :sub() not working with partially-consumed chunks (thanks Zash for test case) This also appears to fix some bugs with chunk-encoded streams in net.http.parser.
author Matthew Wild <mwild1@gmail.com>
date Mon, 24 Aug 2020 16:18:13 +0100
parent 11044:7b720a815519
child 11046:64713f21ff0e
comparison
equal deleted inserted replaced
11044:7b720a815519 11045:8c6bace13229
65 local b = dbuffer.new(); 65 local b = dbuffer.new();
66 assert.truthy(b:write("hello world")); 66 assert.truthy(b:write("hello world"));
67 assert.equals("hello", b:sub(1, 5)); 67 assert.equals("hello", b:sub(1, 5));
68 end); 68 end);
69 69
70 pending("works after discard", function () 70 it("works after discard", function ()
71 local b = dbuffer.new(256); 71 local b = dbuffer.new(256);
72 assert.truthy(b:write("foo")); 72 assert.truthy(b:write("foo"));
73 assert.truthy(b:write("bar")); 73 assert.truthy(b:write("bar"));
74 assert.equals("foobar", b:sub(1, 6)); 74 assert.equals("foobar", b:sub(1, 6));
75 assert.truthy(b:discard(3)) -- until the space 75 assert.truthy(b:discard(3)) -- until the space