tests/weaschem: more tests, but not done w/parse_header yet

This commit is contained in:
Starbeamrainbowlabs 2023-08-15 03:24:15 +01:00
parent 270ec92fee
commit 8d79e6f0ab
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
4 changed files with 62 additions and 0 deletions

View file

@ -0,0 +1,16 @@
{
"name": "A castle",
"description": 88,
"size": {
"x": 50,
"y": 25,
"z": 75
},
"offset": {
"x": 3,
"y": 0,
"z": 5
},
"type": "full",
"generator": "WorldEditAdditions v1.14"
}

View file

@ -0,0 +1,10 @@
{
"name": "A castle",
"size": {
"x": 50,
"y": 25,
"z": 75
},
"type": "full",
"generator": "WorldEditAdditions v1.14"
}

View file

@ -0,0 +1,10 @@
{
"name": "A castle",
"offset": {
"x": 50,
"y": 25,
"z": 75
},
"type": "full",
"generator": "WorldEditAdditions v1.14"
}

View file

@ -63,5 +63,31 @@ describe("parse.file.weaschem.parse_header", function()
assert.are.same("HEADER_NAME_INVALID", code)
assert.are.same("string", type(result))
end)
it("should complain for an invalid header with description of wrong type", function()
local content = get_json_string("invalid_description_type")
assert.are_not.same(nil, content)
local success, code, result = weaschem.parse_header(content)
assert.are.same(false, success)
assert.are.same("HEADER_DESCRIPTION_INVALID", code)
assert.are.same("string", type(result))
end)
it("should complain for an invalid header with no offset", function()
local content = get_json_string("invalid_no_offset")
assert.are_not.same(nil, content)
local success, code, result = weaschem.parse_header(content)
assert.are.same(false, success)
assert.are.same("HEADER_NO_OFFSET", code)
assert.are.same("string", type(result))
end)
it("should complain for an invalid header with no size", function()
local content = get_json_string("invalid_no_size")
assert.are_not.same(nil, content)
local success, code, result = weaschem.parse_header(content)
assert.are.same(false, success)
assert.are.same("HEADER_NO_SIZE", code)
assert.are.same("string", type(result))
end)
-- TODO: Test invalid sizes/offsets, but this is mainly handled by the above
end)