-- 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) print(failures == 0 and "\nALLE TESTS OK" or ("\n" .. failures .. " FEJL")) os.exit(failures == 0 and 0 or 1)