Skip to content

Instantly share code, notes, and snippets.

@silentbicycle
Created July 25, 2012 15:14
Show Gist options
  • Save silentbicycle/3176702 to your computer and use it in GitHub Desktop.
Save silentbicycle/3176702 to your computer and use it in GitHub Desktop.
tests for 0-escaping
function test_encoding_two_zeroes()
-- this should be {0, 2, 0}, not {0, 0, 0, 0}, to keep
-- encoding from filling up with too many escapes.
local ints = {0, 0}
local res = rle.encode(ints)
local expected = {0, 2, 0}
for i=1,#expected do
assert_equal(expected[i], res[i])
end
end
function test_encoding_000122()
-- previously, the 1 after the 0s was dropped.
local ints = {0, 0, 0, 1, 2, 2}
local res = rle.encode(ints)
local expected = {0, 3, 0, 1, 2, 2}
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