aboutsummaryrefslogtreecommitdiffstats
path: root/spec/util_random_spec.lua
blob: c080a2c9b7c89831b3536b0230903c7894b921c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

local random = require "util.random";

describe("util.random", function()
	describe("#bytes()", function()
		it("should return a string", function()
			assert.is_string(random.bytes(16));
		end);

		it("should return the requested number of bytes", function()
			-- Makes no attempt at testing how random the bytes are,
			-- just that it returns the number of bytes requested

			for i = 1, 20 do
				assert.are.equal(2^i, #random.bytes(2^i));
			end
		end);
	end);
end);