mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-11-05 01:26:20 +00:00
Test various time locales exist
Not clear if we can really test their behaviour too much.
See 69b211b4fb
.
This commit is contained in:
parent
ba976f9a16
commit
b28c1ac8e0
@ -117,6 +117,19 @@ describe("The os library", function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
describe("os.time", function()
|
describe("os.time", function()
|
||||||
|
it("supports in-game time", function()
|
||||||
|
expect(os.time("ingame")):equal(os.time())
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("supports local and utc time", function()
|
||||||
|
os.time("utc")
|
||||||
|
os.time("local")
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("fails on other times", function()
|
||||||
|
expect.error(os.time, "unknown"):eq("Unsupported operation")
|
||||||
|
end)
|
||||||
|
|
||||||
it("maps directly to seconds", function()
|
it("maps directly to seconds", function()
|
||||||
local t1 = os.time { year = 2000, month = 10, day = 1, hour = 23, min = 12, sec = 17 }
|
local t1 = os.time { year = 2000, month = 10, day = 1, hour = 23, min = 12, sec = 17 }
|
||||||
local t2 = os.time { year = 2000, month = 10, day = 1, hour = 23, min = 10, sec = 19 }
|
local t2 = os.time { year = 2000, month = 10, day = 1, hour = 23, min = 10, sec = 19 }
|
||||||
@ -124,6 +137,38 @@ describe("The os library", function()
|
|||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
describe("os.day", function()
|
||||||
|
it("supports in-game time", function()
|
||||||
|
expect(os.day("ingame")):equal(os.day())
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("supports local and utc time", function()
|
||||||
|
os.day("utc")
|
||||||
|
os.day("local")
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("fails on other times", function()
|
||||||
|
expect.error(os.day, "unknown"):eq("Unsupported operation")
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
|
describe("os.epoch", function()
|
||||||
|
it("supports in-game time", function()
|
||||||
|
local in_game = os.epoch("ingame")
|
||||||
|
local default = os.epoch()
|
||||||
|
assert(math.abs(default - in_game) < 5)
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("supports local and utc time", function()
|
||||||
|
os.epoch("utc")
|
||||||
|
os.epoch("local")
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("fails on other times", function()
|
||||||
|
expect.error(os.epoch, "unknown"):eq("Unsupported operation")
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
describe("os.loadAPI", function()
|
describe("os.loadAPI", function()
|
||||||
it("validates arguments", function()
|
it("validates arguments", function()
|
||||||
expect.error(os.loadAPI, nil):eq("bad argument #1 (expected string, got nil)")
|
expect.error(os.loadAPI, nil):eq("bad argument #1 (expected string, got nil)")
|
||||||
|
Loading…
Reference in New Issue
Block a user