Comparison

spec/util_dbuffer_spec.lua @ 11044:7b720a815519

util.dbuffer: Add failing test case involving :sub after :discard
author Kim Alvefur <zash@zash.se>
date Mon, 24 Aug 2020 17:07:37 +0200
parent 11028:d7a403060946
child 11045:8c6bace13229
comparison
equal deleted inserted replaced
11043:d105e787f5ed 11044:7b720a815519
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 ()
71 local b = dbuffer.new(256);
72 assert.truthy(b:write("foo"));
73 assert.truthy(b:write("bar"));
74 assert.equals("foobar", b:sub(1, 6));
75 assert.truthy(b:discard(3)) -- until the space
76 assert.equals("bar", b:sub(1, 3));
77 end);
78
70 it("supports optional end parameter", function () 79 it("supports optional end parameter", function ()
71 local b = dbuffer.new(); 80 local b = dbuffer.new();
72 assert.truthy(b:write("hello world")); 81 assert.truthy(b:write("hello world"));
73 assert.equals("hello world", b:sub(1)); 82 assert.equals("hello world", b:sub(1));
74 assert.equals("world", b:sub(-5)); 83 assert.equals("world", b:sub(-5));