34 lines
1.7 KiB
Lua
34 lines
1.7 KiB
Lua
-- Kør: luajit tests/test_adFields.lua (fra repo-roden)
|
|
dofile("FS25_ADSmartPickup/adFields.lua")
|
|
local F = ADFields
|
|
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
|
|
|
|
-- F1/F2: markørnavne
|
|
check("F1 F109", F.parseMarkerName("F109"), 109)
|
|
check("F1 småt", F.parseMarkerName("f7"), 7)
|
|
check("F1 mellemrum", F.parseMarkerName(" F 12 "), 12)
|
|
check("F2 andet navn", F.parseMarkerName("Field 109"), nil)
|
|
check("F2 tekst efter", F.parseMarkerName("F109 wait"), nil)
|
|
check("F2 nil", F.parseMarkerName(nil), nil)
|
|
|
|
-- F3: slåafgrøde = MOWER giver et skår som TEDDER gør til DRY…; halm udelukket
|
|
local names = {[10] = "GRASS_WINDROW", [11] = "DRYGRASS_WINDROW", [20] = "STRAW", [30] = "CLOVER_WINDROW", [31] = "DRYCLOVER_WINDROW", [40] = "BEANSTRAW"}
|
|
local mower = {[1] = {fillTypeIndex = 10}, [2] = {fillTypeIndex = 20}, [3] = {fillTypeIndex = 30}, [4] = {fillTypeIndex = 40}}
|
|
local tedder = {[10] = {targetFillTypeIndex = 11}, [30] = {targetFillTypeIndex = 31}, [40] = {targetFillTypeIndex = 20}}
|
|
local mowable = F.buildMowable(mower, tedder, function(index) return names[index] end)
|
|
check("F3 græs", mowable[1] ~= nil, true)
|
|
check("F3 græs skår", mowable[1].windrow, 10)
|
|
check("F3 græs hø", mowable[1].hay, 11)
|
|
check("F3 rug (halm) ikke", mowable[2], nil)
|
|
check("F3 kløver", mowable[3].hay, 31)
|
|
check("F3 bønnehalm -> halm ikke", mowable[4], nil)
|
|
|
|
print(failures == 0 and "\nALLE TESTS OK" or ("\n" .. failures .. " FEJL"))
|
|
os.exit(failures == 0 and 0 or 1)
|