# HG changeset patch # User Kim Alvefur # Date 1456074354 -3600 # Node ID 32b74ad54432ac4d57501fe356122518c3e56460 # Parent fb37aece32528c484b40420b76a6010718ef3ccd tests: Add minimal test for util.random that checks that it returns the number of bytes requested diff -r fb37aece3252 -r 32b74ad54432 tests/test.lua --- a/tests/test.lua Sun Feb 21 14:53:19 2016 +0100 +++ b/tests/test.lua Sun Feb 21 18:05:54 2016 +0100 @@ -23,6 +23,7 @@ dotest "util.cache" dotest "util.throttle" dotest "util.uuid" + dotest "util.random" dosingletest("test_sasl.lua", "latin1toutf8"); dosingletest("test_utf8.lua", "valid"); diff -r fb37aece3252 -r 32b74ad54432 tests/test_util_random.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test_util_random.lua Sun Feb 21 18:05:54 2016 +0100 @@ -0,0 +1,10 @@ +-- Makes no attempt at testing how random the bytes are, +-- just that it returns the number of bytes requested + +function bytes(bytes) + assert_is(bytes(16)); + + for i = 1, 255 do + assert_equal(i, #bytes(i)); + end +end