Skip to content

Instantly share code, notes, and snippets.

@ynezz
Created May 17, 2019
Embed
What would you like to do?
Lua number parsing test cases
local test_cases = {
{ 0x7fffffff, "2147483647" },
{ 2147483647, "2147483647" },
{ 0xffffffff, "4294967295" },
{ 4294967295, "4294967295" },
{ 0x7fffffffffffffff, "9.2233720368548e+18" },
{ 9223372036854775807, "9.2233720368548e+18" },
{ 0xffffffffffffffff, "1.844674407371e+19" },
{ 18446744073709551615, "1.844674407371e+19" },
{ 0x100000000, "4294967296" },
{ 4294967296, "4294967296" },
{ 0x100000000000, "17592186044416" },
{ 17592186044416, "17592186044416" },
{ 0x80000000, "2147483648" },
{ 2147483648, "2147483648" },
{ 0x800000000000, "1.4073748835533e+14" },
{ 140737488355328, "1.4073748835533e+14" },
}
for _, test in pairs(test_cases) do
assert(tostring(test[1]) == test[2], test[2])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment