From 06f90edd46cafdb9defd561f626ccb6a35aea0e7 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Tue, 15 Aug 2023 00:20:41 +0100 Subject: [PATCH] tests/weaschem: okay, here we go: parse_vector3 Let's go slow, one function at a time, from nuts and bolts gradually up to full files --- .tests/parse/file/weaschem_vector3.test.lua | 61 +++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .tests/parse/file/weaschem_vector3.test.lua diff --git a/.tests/parse/file/weaschem_vector3.test.lua b/.tests/parse/file/weaschem_vector3.test.lua new file mode 100644 index 0000000..baa15bc --- /dev/null +++ b/.tests/parse/file/weaschem_vector3.test.lua @@ -0,0 +1,61 @@ +local weaschem = require("worldeditadditions_core.utils.parse.file.weaschem") + + +describe("parse.file.weaschem.parse_vector3", function() + it("should parse a valid positive integer vector3", function() + local a = { x = 4, y = 5, z = 6 } + local success, code, result = weaschem.parse_vector3(a) + assert.are.same(true, success) + assert.are.same("SUCCESS", code) + assert.are.same(a, result) + end) + it("should parse a valid negative integer vector3", function() + local a = { x = -4, y = -5, z = -6 } + local success, code, result = weaschem.parse_vector3(a) + assert.are.same(true, success) + assert.are.same("SUCCESS", code) + assert.are.same(a, result) + end) + it("should get upset if there's no x coordinate", function() + local a = { y = -5, z = -6 } + local success, code, result = weaschem.parse_vector3(a) + assert.are.same(false, success) + assert.are.same("VECTOR3_NO_X", code) + assert.are.same("string", type(result)) + end) + it("should get upset if there's no y coordinate", function() + local a = { x = -5, z = -6 } + local success, code, result = weaschem.parse_vector3(a) + assert.are.same(false, success) + assert.are.same("VECTOR3_NO_Y", code) + assert.are.same("string", type(result)) + end) + it("should get upset if there's no z coordinate", function() + local a = { x = -5, y = -6 } + local success, code, result = weaschem.parse_vector3(a) + assert.are.same(false, success) + assert.are.same("VECTOR3_NO_Z", code) + assert.are.same("string", type(result)) + end) + it("should get upset if x is not an int", function() + local a = { x = -5.1, y = -6, z = 0 } + local success, code, result = weaschem.parse_vector3(a) + assert.are.same(false, success) + assert.are.same("VECTOR3_X_FLOAT", code) + assert.are.same("string", type(result)) + end) + it("should get upset if y is not an int", function() + local a = { x = -5, y = -6.4, z = 0 } + local success, code, result = weaschem.parse_vector3(a) + assert.are.same(false, success) + assert.are.same("VECTOR3_Y_FLOAT", code) + assert.are.same("string", type(result)) + end) + it("should get upset if z is not an int", function() + local a = { x = -5, y = -6, z = 0.001 } + local success, code, result = weaschem.parse_vector3(a) + assert.are.same(false, success) + assert.are.same("VECTOR3_Z_FLOAT", code) + assert.are.same("string", type(result)) + end) +end)