spec/util_format_spec.lua
author Kim Alvefur <zash@zash.se>
Thu, 04 Jun 2020 16:11:08 +0200
changeset 10903 8048255ae61e
parent 10039 386f085820e6
child 11642 5f4a657136bc
permissions -rw-r--r--
util.ringbuffer: Prevent creation of buffer with negative size Previously this would have been (unsigned)-1 which is a large positive integer.

local format = require "util.format".format;

describe("util.format", function()
	describe("#format()", function()
		it("should work", function()
			assert.equal("hello", format("%s", "hello"));
			assert.equal("<nil>", format("%s"));
			assert.equal("<nil>", format("%d"));
			assert.equal("<nil>", format("%q"));
			assert.equal(" [<nil>]", format("", nil));
			assert.equal("true", format("%s", true));
			assert.equal("[true]", format("%d", true));
			assert.equal("% [true]", format("%%", true));
			assert.equal("{ }", format("%q", { }));
			assert.equal("[1.5]", format("%d", 1.5));
			assert.equal("[7.3786976294838e+19]", format("%d", 73786976294838206464));
		end);
	end);
end);