File

spec/util_random_spec.lua @ 13070:be9ac41f1619

mod_csi: Remove module status, doesn't work because of mod_smacks This was meant to warn in case you had only mod_csi without a logic handling module like mod_csi_simple by checking if anything hooked this event, however mod_smacks also hooks this event and so this isn't really a useful way of detecting this condition.
author Kim Alvefur <zash@zash.se>
date Mon, 10 Apr 2023 13:50:09 +0200
parent 8450:3a9a3d90c44c
line wrap: on
line source


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);