Files
fs25-adsmartpickup/tests/test_adFleetNames.lua
T

34 lines
1.9 KiB
Lua

-- Kør: luajit tests/test_adFleetNames.lua (fra repo-roden)
dofile("FS25_ADSmartPickup/adFleetNames.lua")
local N = ADFleetNames
local failures = 0
local function check(name, actual, expected)
if actual == expected then print("OK " .. name) else
failures = failures + 1
print(string.format("FAIL %s: forventede %s, fik %s", name, tostring(expected), tostring(actual)))
end
end
local plan = N.plan({
{id = "b", model = "Puma 260 CVX"}, {id = "a", model = "Puma 260 CVX"}, {id = "c", model = "Fastrac 4220"},
{id = "d", model = "Cow Food", inRun = true, name = "Cow Food 1"}, {id = "e", model = "CR11", selfPropelled = true, name = "Mejetærsker"},
})
local byId = {}
for _, entry in ipairs(plan) do byId[entry.id] = entry end
check("navne: samme model nummereres (efter id)", byId.a.name, "Puma 260 CVX 1")
check("navne: anden af samme model", byId.b.name, "Puma 260 CVX 2")
check("navne: enlig model uden nummer", byId.c.name, "Fastrac 4220")
check("navne: flow-traktor beholder navn", byId.d.name, "Cow Food 1")
check("navne: selvkørende beholder navn", byId.e.name, "Mejetærsker")
check("parkering: P + navn", byId.a.parkName, "P Puma 260 CVX 1")
check("parkering: flow-traktor", byId.d.parkName, "P Cow Food 1")
check("omdøb: kun hvis ændret", byId.d.rename, false)
check("omdøb: ny navn", byId.a.rename, true)
-- R7: parkeringer omdøbes kun for maskiner der selv omdøbes, og ikke delte parkeringer
check("R7 flow-traktor: parkering røres ikke", byId.d.renamePark, false)
check("R7 selvkørende: parkering røres ikke", byId.e.renamePark, false)
check("R7 omdøbt traktor: parkering omdøbes", byId.a.renamePark, true)
local shared = N.plan({{id = "x", model = "M", park = 5}, {id = "y", model = "Q", park = 5}}, {[5] = 2})
check("R7 delt parkering røres ikke", shared[1].renamePark, false)
print(failures == 0 and "\nALLE TESTS OK" or ("\n" .. failures .. " FEJL"))
os.exit(failures == 0 and 0 or 1)