b33f7682b4
Moddets markopgaver starter CP med eget job; HUD'en kunne stå på bunkersilo, og HUD-starten efter indlæsning gav 'CP: No silo found' (v1.60.13.0).
34 lines
1.8 KiB
Lua
34 lines
1.8 KiB
Lua
-- Kør: luajit tests/test_adCpResume.lua (fra repo-roden)
|
|
dofile("FS25_ADSmartPickup/adCpResume.lua")
|
|
local R = ADCpResume
|
|
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
|
|
-- hvem skrives ved gem: CP kører, AD styrer ikke (AD genstarter selv sine)
|
|
local ids = R.activeIds({{id = "a", cpActive = true}, {id = "b", cpActive = true, adActive = true}, {id = "c"}, {id = "d", cpActive = true}})
|
|
check("gem: CP-aktive uden AD", table.concat(ids, " "), "a d")
|
|
check("gem: tom liste", #R.activeIds({}), 0)
|
|
-- records frem og tilbage
|
|
local set = R.fromRecords({"a", "", "d", "a"})
|
|
check("indlæs: a", set.a, true)
|
|
check("indlæs: tomt id springes over", set[""], nil)
|
|
-- hvem startes ved indlæsning
|
|
local pending = {a = true, b = true, c = true, d = true}
|
|
local vehicles = {{id = "a"}, {id = "b", aiActive = true}, {id = "c", controlled = true}, {id = "d"}, {id = "e"}}
|
|
local start = R.toStart(pending, vehicles)
|
|
check("start: kun gemte, ikke allerede kørende/spiller i", table.concat(start, " "), "a d")
|
|
check("start: ingen gemt liste -> nil (gammel regel bruges)", R.toStart(nil, vehicles), nil)
|
|
|
|
-- kun når CP's HUD-job er markarbejde: moddets markopgaver starter CP med eget job, så HUD'en kan stå på fx
|
|
-- bunkersilo — HUD-start gav "CP: No silo found" efter genindlæsning (in-game 29/9)
|
|
local mixed = R.toStart({a = true, b = true, c = true}, {
|
|
{id = "a", fieldWork = true}, {id = "b", fieldWork = false}, {id = "c"}})
|
|
check("start: kun markarbejds-job", table.concat(mixed, ","), "a,c")
|
|
|
|
print(failures == 0 and "\nALLE TESTS OK" or ("\n" .. failures .. " FEJL"))
|
|
os.exit(failures == 0 and 0 or 1)
|