~rootmos/lua-hack

c1291ab58c8dffd40280ab4532d2ccd8307884e7 — Gustav Behm 2 months ago 70c14f0
Add a roundtrip-test
1 files changed, 12 insertions(+), 0 deletions(-)

M duration.test.lua
M duration.test.lua => duration.test.lua +12 -0
@@ 41,4 41,16 @@ function test_render_0()
    lu.assertEquals(D.render(0), "")
end

function test_render_parse_roundtrip()
    for i=1,1000 do
        local sec = math.random(0, 3*24*3600*10)
        lu.assertEquals(D.parse(D.render(sec)), sec)
    end

    for i=1,1000 do
        local sec = math.random(0, math.maxinteger)
        lu.assertEquals(D.parse(D.render(sec)), sec)
    end
end

os.exit(lu.LuaUnit.run())