tests: Add minimal test for util.random that checks that it returns the number of...
authorKim Alvefur <zash@zash.se>
Sun, 21 Feb 2016 17:05:54 +0000 (18:05 +0100)
committerKim Alvefur <zash@zash.se>
Sun, 21 Feb 2016 17:05:54 +0000 (18:05 +0100)
tests/test.lua
tests/test_util_random.lua [new file with mode: 0644]

index 4863c4e70aa18b68aafc2aa4b6d1812fc37ccad4..0fcc49073983eb96c96411ccee835ee9d4128d68 100644 (file)
@@ -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 (file)
index 0000000..79572ef
--- /dev/null
@@ -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