File

spec/util_ringbuffer_spec.lua @ 10898:c6465fb3c839

util.ringbuffer: Prevent creation of zero-size buffer
author Kim Alvefur <zash@zash.se>
date Fri, 29 May 2020 18:11:42 +0200
parent 10897:37df1e757f02
child 10899:8048255ae61e
line wrap: on
line source

local rb = require "util.ringbuffer";
describe("util.ringbuffer", function ()
	describe("#new", function ()
		it("has a constructor", function ()
			assert.Function(rb.new);
		end);
		it("can be created", function ()
			assert.truthy(rb.new());
		end);
		it("won't create an empty buffer", function ()
			assert.has_error(function ()
				rb.new(0);
			end);
		end);
	end);
	describe(":write", function ()
		local b = rb.new();
		it("works", function ()
			assert.truthy(b:write("hi"));
		end);
	end);
end);