aboutsummaryrefslogtreecommitdiffstats
path: root/spec/util_random_spec.lua
blob: e847d92e44fa9fe7fa1366e57ba7bd61a5fd2856 (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, 255 do
				assert.are.equal(i, #random.bytes(i));
			end
		end);
	end);
end);