Skip to content

Instantly share code, notes, and snippets.

@silentbicycle
Created July 25, 2012 15:09
Show Gist options
  • Save silentbicycle/3176672 to your computer and use it in GitHub Desktop.
Save silentbicycle/3176672 to your computer and use it in GitHub Desktop.
tests for known input
function test_basic_encoding_for_known_case()
local ints = {1, 0, 2, 2, 2, 2, 2, 2, 3, 3, 3, 4}
local res = rle.encode(ints)
local expected = {1, 0, 0, 0, 6, 2, 3, 3, 3, 4}
for i=1,#expected do
assert_equal(expected[i], res[i])
end
end
function test_basic_decoding_for_known_case()
local packed = {1, 0, 0, 0, 6, 2, 3, 3, 3, 4}
local expected = {1, 0, 2, 2, 2, 2, 2, 2, 3, 3, 3, 4}
local res = rle.decode(packed)
for i=1,#expected do
assert_equal(expected[i], res[i])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment