Comparison

spec/util_dbuffer_spec.lua @ 11046:64713f21ff0e

util.dbuffer: Simplify test case An earlier theory involved the bug being related to collapsing multiple items, so it exercised that too. Also correct the comment, it referred to the space in "hello world" in an earlier version before the test string was changed to "foobar", which was what was tested in a REPL
author Kim Alvefur <zash@zash.se>
date Mon, 24 Aug 2020 17:28:48 +0200
parent 11045:8c6bace13229
child 11114:6a608ecb3471
comparison
equal deleted inserted replaced
11045:8c6bace13229 11046:64713f21ff0e
67 assert.equals("hello", b:sub(1, 5)); 67 assert.equals("hello", b:sub(1, 5));
68 end); 68 end);
69 69
70 it("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("foobar"));
73 assert.truthy(b:write("bar"));
74 assert.equals("foobar", b:sub(1, 6)); 73 assert.equals("foobar", b:sub(1, 6));
75 assert.truthy(b:discard(3)) -- until the space 74 assert.truthy(b:discard(3)); -- consume "foo"
76 assert.equals("bar", b:sub(1, 3)); 75 assert.equals("bar", b:sub(1, 3));
77 end); 76 end);
78 77
79 it("supports optional end parameter", function () 78 it("supports optional end parameter", function ()
80 local b = dbuffer.new(); 79 local b = dbuffer.new();