[spec] Add more TimeVal tests (#4672)

That should please CodeCov.
pull/4673/head
Frans de Jonge 5 years ago committed by GitHub
parent abba7ba873
commit 626d7340f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -15,6 +15,13 @@ describe("TimeVal module", function()
end
end)
it("should add", function()
local timev1 = TimeVal:new{ sec = 5, usec = 5000}
local timev2 = TimeVal:new{ sec = 10, usec = 6000}
assert.is.same({sec = 15,usec = 11000}, timev1 + timev2)
end)
it("should subtract", function()
local timev1 = TimeVal:new{ sec = 5, usec = 5000}
local timev2 = TimeVal:new{ sec = 10, usec = 6000}
@ -31,4 +38,26 @@ describe("TimeVal module", function()
assert.has.errors(function() return timev1 - timev2 end)
end)
it("should derive sec and usec from more than 1 sec worth of usec", function()
local timev1 = TimeVal:new{ sec = 5, usec = 5000000}
assert.is.same({sec = 10,usec = 0}, timev1)
end)
it("should compare", function()
local timev1 = TimeVal:new{ sec = 5, usec = 5000}
local timev2 = TimeVal:new{ sec = 10, usec = 6000}
local timev3 = TimeVal:new{ sec = 5, usec = 5000}
assert.is_true(timev2 > timev1)
assert.is_true(timev2 >= timev1)
assert.is_true(timev1 < timev2)
assert.is_true(timev1 <= timev2)
assert.is_true(timev1 == timev3)
assert.is_true(timev1 >= timev3)
assert.is_true(timev1 <= timev3)
end)
end)

Loading…
Cancel
Save