Add hexadecimal exercise
This commit is contained in:
parent
0961258fba
commit
8c06a5172e
34
hexadecimal.lua
Normal file
34
hexadecimal.lua
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
-- Solution --------------------------------------------------------------------
|
||||||
|
function hexadecimal(x)
|
||||||
|
-- Your implementation here
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Tests -----------------------------------------------------------------------
|
||||||
|
|
||||||
|
local luaunit = require("luaunit.luaunit")
|
||||||
|
|
||||||
|
function test_hexadecimal_of_8_is_8()
|
||||||
|
luaunit.assertEquals(hexadecimal(8), "8")
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_hexadecimal_of_14_is_e()
|
||||||
|
luaunit.assertEquals(hexadecimal(14), "e")
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_hexadecimal_of_42_is_2a()
|
||||||
|
luaunit.assertEquals(hexadecimal(42), "2a")
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_hexadecimal_of_3735928559_is_deadbeef()
|
||||||
|
luaunit.assertEquals(hexadecimal(3735928559), "deadbeef")
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_hexadecimal_of_12648430_is_c0ffee()
|
||||||
|
luaunit.assertEquals(hexadecimal(12648430), "c0ffee")
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_hexadecimal_of_49374_is_c0de()
|
||||||
|
luaunit.assertEquals(hexadecimal(49374), "c0de")
|
||||||
|
end
|
||||||
|
|
||||||
|
os.exit(luaunit.LuaUnit.run())
|
Loading…
x
Reference in New Issue
Block a user