From 7c238f0426acd85a71697a003c01832e9e191e18 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 21 Feb 2016 18:05:54 +0100 Subject: tests: Add minimal test for util.random that checks that it returns the number of bytes requested --- tests/test.lua | 1 + tests/test_util_random.lua | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 tests/test_util_random.lua (limited to 'tests') diff --git a/tests/test.lua b/tests/test.lua index 4863c4e7..0fcc4907 100644 --- a/tests/test.lua +++ b/tests/test.lua @@ -23,6 +23,7 @@ function run_all_tests() dotest "util.cache" dotest "util.throttle" dotest "util.uuid" + dotest "util.random" dosingletest("test_sasl.lua", "latin1toutf8"); dosingletest("test_utf8.lua", "valid"); diff --git a/tests/test_util_random.lua b/tests/test_util_random.lua new file mode 100644 index 00000000..79572ef8 --- /dev/null +++ b/tests/test_util_random.lua @@ -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 -- cgit v1.2.3