Wir laden dich herzlich auf den Star Citizen Wiki Discord Server ein! Du kannst uns auch auf unserem neuen YouTube-Chanel finden!

Modul:Commodity/testcases

From Star Citizen Wiki

Modulabhängigkeiten


-- Unit tests for [[Module:Commodity]]
local module = require('Module:Commodity')
local ScribuntoUnit = require('Module:ScribuntoUnit')
local suite = ScribuntoUnit:new()

--[[
    module.formatOffset tests
]]--
function suite:testFormatOffset()
    self:assertEquals('0%', module.formatOffset( 0 ))
    self:assertEquals('0%', module.formatOffset( '0' ))
    self:assertEquals('0%', module.formatOffset( nil ))
end

function suite:testFormatOffsetSpan()
    self:assertEquals('<span title="10%">10%</span>', module.formatOffset( 10 ))
end


--[[
    module.calcPrice tests
]]--
function suite:testCalcPriceInt()
    self:assertEquals("100", module.calcPrice( 100, 0 ))
	self:assertEquals("9", module.calcPrice( 100, -90 ))
	self:assertEquals("190", module.calcPrice( 100, 90 ))
end

function suite:testCalcPriceFloat()
    self:assertEquals("1.010", module.calcPrice( 1000, 1.1 ))
	self:assertEquals("989", module.calcPrice( 1000, -1.1 ))
end



--[[
    module.calcPricePP tests
]]--
function suite:testCalcPricePPInt()
	-- 10 - 10%
    self:assertEquals(9, module.calcPricePP( 10, 10 ))
	-- 10 + 10%
    self:assertEquals(11, module.calcPricePP( 10, 10, true ))
    
	self:assertEquals(1100, module.calcPricePP( 1000, 10, true ))
end

function suite:testCalcPricePPFloat()
    self:assertEquals(866.125, module.calcPricePP( 1025, 15.5, false, 3 ))
end

return suite
Cookies help us deliver our services. By using our services, you agree to our use of cookies.