exercism.org/lua/cars-assemble/cars-assemble_spec.lua
2024-03-24 18:37:22 +01:00

31 lines
1.7 KiB
Lua

local cars_assemble = require('cars-assemble')
describe('cars assemble', function()
it('should return the amount of working cars produced by the assembly line every hour', function()
assert.are.equal(0.0, cars_assemble.calculate_working_cars_per_hour(0, 100))
assert.are.equal(221.0, cars_assemble.calculate_working_cars_per_hour(221, 100))
assert.are.equal(340.8, cars_assemble.calculate_working_cars_per_hour(426, 80))
assert.are.equal(1398.92, cars_assemble.calculate_working_cars_per_hour(6824, 20.5))
assert.are.equal(0.0, cars_assemble.calculate_working_cars_per_hour(8000, 0))
end)
it('should return the amount of working cars produced by the assembly line every minute', function()
assert.are.equal(0, cars_assemble.calculate_working_cars_per_minute(0, 100))
assert.are.equal(3, cars_assemble.calculate_working_cars_per_minute(221, 100))
assert.are.equal(5, cars_assemble.calculate_working_cars_per_minute(426, 80))
assert.are.equal(23, cars_assemble.calculate_working_cars_per_minute(6824, 20.5))
assert.are.equal(0, cars_assemble.calculate_working_cars_per_minute(8000, 0))
end)
it('should return the cost of producing the given number of cars', function()
assert.are.equal(0, cars_assemble.calculate_cost(0))
assert.are.equal(10000, cars_assemble.calculate_cost(1))
assert.are.equal(20000, cars_assemble.calculate_cost(2))
assert.are.equal(90000, cars_assemble.calculate_cost(9))
assert.are.equal(95000, cars_assemble.calculate_cost(10))
assert.are.equal(200000, cars_assemble.calculate_cost(21))
assert.are.equal(355000, cars_assemble.calculate_cost(37))
assert.are.equal(950000, cars_assemble.calculate_cost(100))
assert.are.equal(1410000, cars_assemble.calculate_cost(148))
end)
end)