From e21e4b2b2496ffcc5d620b04cf3e01b71e9982b1 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Tue, 29 Jun 2021 14:25:57 +0100 Subject: util.dbuffer: Fix bugs, remove multi-char support (more complex than first thought) Character sequences could be split across chunk boundaries. Would require a bunch of code to make that work reliably. Only apply front_consumed on first chunk, and adjust buffer_pos accordingly. --- spec/util_dbuffer_spec.lua | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'spec') diff --git a/spec/util_dbuffer_spec.lua b/spec/util_dbuffer_spec.lua index aa31da55..83ca1823 100644 --- a/spec/util_dbuffer_spec.lua +++ b/spec/util_dbuffer_spec.lua @@ -57,27 +57,6 @@ describe("util.dbuffer", function () assert.equal(nil, b:read_until("\n")); assert.equal("and more", b:read_chunk()); end); - - it("works with multi-character sequences", function () - local b = dbuffer.new(); - b:write("hello\r\n"); - b:write("world"); - b:write("\r\n"); - b:write("\r\n\r\n"); - b:write("stuff"); - b:write("more\r\nand more"); - - assert.equal(nil, b:read_until(".")); - assert.equal(nil, b:read_until("%")); - assert.equal("hello\r\n", b:read_until("\r\n")); - assert.equal("world\r\n", b:read_until("\r\n")); - assert.equal("\r\n", b:read_until("\r\n")); - assert.equal("\r\n", b:read_until("\r\n")); - assert.equal("stu", b:read(3)); - assert.equal("ffmore\r\n", b:read_until("\r\n")); - assert.equal(nil, b:read_until("\r\n")); - assert.equal("and more", b:read_chunk()); - end); end); describe(":discard", function () -- cgit v1.2.3