Jump to content

Module:Format price/testcases

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by GKFX (talk | contribs) at 22:43, 28 May 2021 (tests). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
-- Unit tests for [[Module:Format price]]. Click talk page to run tests.
local p = require('Module:UnitTests')

-- Example unit test.
function p:test_main()
	self:preprocess_equals('{{#invoke:Format price||123456.78|-2}}', '123,500') 
	self:preprocess_equals('{{#invoke:Format price||123456.78|-1}}', '123,460') 
	self:preprocess_equals('{{#invoke:Format price||123456.78|0}}', '123,457') 
	self:preprocess_equals('{{#invoke:Format price||123456.78|1}}', '123,457') 
	self:preprocess_equals('{{#invoke:Format price||123456.78|2}}', '123,457') 
	
	self:preprocess_equals('{{#invoke:Format price||12.78|-2}}', '0') 
	self:preprocess_equals('{{#invoke:Format price||12.78|-1}}', '10') 
	self:preprocess_equals('{{#invoke:Format price||12.78|0}}', '13') 
	self:preprocess_equals('{{#invoke:Format price||12.78|1}}', '13') 
	self:preprocess_equals('{{#invoke:Format price||12.78|2}}', '12.78') 
	
	self:preprocess_equals('{{#invoke:Format price||1234560.78|1}}', '1.23 million') 
	self:preprocess_equals('{{#invoke:Format price||12345600.78|2}}', '12.3 million') 
	self:preprocess_equals('{{#invoke:Format price||123456000.78|-2}}', '123 million') 
	self:preprocess_equals('{{#invoke:Format price||1234560000.78|-1}}', '1.23 billion') 
	self:preprocess_equals('{{#invoke:Format price||12345600000.78|0}}', '12.3 billion') 
	self:preprocess_equals('{{#invoke:Format price||123456000000.78|0}}', '123 billion') 
	self:preprocess_equals('{{#invoke:Format price||1234560000000.78|0}}', '1.23 trillion') 
end

return p