44 lines
2.2 KiB
Lua
44 lines
2.2 KiB
Lua
-- Load the helper script
|
|
dofile("luahelper.lua")
|
|
|
|
-- Test helper function
|
|
local function assert(condition, message)
|
|
if not condition then error("ASSERTION FAILED: " .. (message or "unknown error")) end
|
|
end
|
|
|
|
local function test(name, fn)
|
|
local ok, err = pcall(fn)
|
|
if ok then
|
|
print("PASS: " .. name)
|
|
else
|
|
print("FAIL: " .. name .. " - " .. tostring(err))
|
|
end
|
|
end
|
|
|
|
test("regression test 001", function()
|
|
local csv =
|
|
[[Id Enabled ModuleId DepartmentId IsDepartment PositionInGraph Parents Modifiers UpgradePrice
|
|
news_department TRUE navigation TRUE 2 0 NewsAnalyticsDepartment + 1 communication_relay communication_relay
|
|
nd_charge_bonus TRUE navigation news_department FALSE 1 0 news_department NDSkillChargeBonus + 1 expert_disk expert_disk
|
|
nd_cooldown_time_reduce TRUE navigation news_department FALSE 3 0 news_department NDCooldownTimeReduce - 2 communication_relay communication_relay]]
|
|
local rows, err = fromCSV(csv, { delimiter = "\t", hasheader = true, hascomments = true })
|
|
if err then error("fromCSV error: " .. err) end
|
|
assert(#rows == 3, "Should have 3 rows")
|
|
assert(rows[1].Id == "news_department", "First row Id should be 'news_department'")
|
|
assert(rows[1].Enabled == "TRUE", "First row Enabled should be 'TRUE'")
|
|
assert(rows[1].ModuleId == "navigation", "First row ModuleId should be 'navigation'")
|
|
assert(rows[1].DepartmentId == "", "First row DepartmentId should be ''")
|
|
assert(rows[1].IsDepartment == "TRUE", "First row IsDepartment should be 'TRUE'")
|
|
assert(rows.Headers[1] == "Id", "First row Headers should be 'Id'")
|
|
assert(rows.Headers[2] == "Enabled", "First row Headers should be 'Enabled'")
|
|
assert(rows.Headers[3] == "ModuleId", "First row Headers should be 'ModuleId'")
|
|
assert(rows.Headers[4] == "DepartmentId", "First row Headers should be 'DepartmentId'")
|
|
assert(rows.Headers[5] == "IsDepartment", "First row Headers should be 'IsDepartment'")
|
|
assert(rows.Headers[6] == "PositionInGraph", "First row Headers should be 'PositionInGraph'")
|
|
assert(rows.Headers[7] == "Parents", "First row Headers should be 'Parents'")
|
|
assert(rows.Headers[8] == "Modifiers", "First row Headers should be 'Modifiers'")
|
|
assert(rows.Headers[9] == "UpgradePrice", "First row Headers should be 'UpgradePrice'")
|
|
end)
|
|
|
|
print("\nAll tests completed!")
|