Skip to content

Commit 87a3508

Browse files
committed
add tests
1 parent 992bb66 commit 87a3508

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/convert/converter_spec.lua

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ local size_values = {
2121
pt = 12
2222
}
2323

24+
local number_val = {
25+
bin = "0b0101",
26+
hex = "0x155",
27+
octal = "0o525",
28+
decimal = "341"
29+
}
30+
2431
describe("Unit Conversions", function()
2532
for unit, value in pairs(size_values) do
2633
for i = 1, #units, 1 do
@@ -45,3 +52,24 @@ describe("Unit Conversions", function()
4552
::continue::
4653
end
4754
end)
55+
56+
describe("Number Conversions", function()
57+
for unit, value in pairs(number_val) do
58+
for i = 1, #units, 1 do
59+
60+
local to_unit = units[i]
61+
local from_unit = unit
62+
63+
if from_unit == to_unit then
64+
goto continue
65+
end
66+
67+
68+
it(string.format("Should convert %s, to %s", from_unit, to_unit), function()
69+
local converted = utils.round(converters(from_unit, to_unit, value), 0)
70+
assert.are.equal(size_values[to_unit], converted)
71+
end)
72+
end
73+
::continue::
74+
end
75+
end)

0 commit comments

Comments
 (0)