Created
July 25, 2012 15:10
-
-
Save silentbicycle/3176678 to your computer and use it in GitHub Desktop.
Generate appropriate input for testing run-length encoding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Generate a random array of bytes, with some redundancy (via sorting). | |
function gen_int_array(limit) | |
limit = limit or 10000 | |
local ri = lunatest.random_int | |
local length = ri(1, limit) | |
local ints = {} | |
for i=1,length do | |
-- keep them small, to increase duplication | |
ints[i] = ri(0, 2^8 - 1) | |
end | |
-- group repeated values together | |
table.sort(ints) | |
return ints | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment