Jump to content

Module:Infobox dim/testcases

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Hike395 (talk | contribs) at 12:42, 4 October 2024 (add scale test (main vs sandbox)). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
-- Unit tests for [[Module:Infobox dim]]. Click talk page to run tests.
local p = require('Module:UnitTests')

-- Test dim
function p:test_dim()
	self:preprocess_equals_many('{{#invoke:Infobox dim | dim |','}}', {
		{'length_km=20|width_km=30','15km'},
		{'length_mi=20|width_mi=30','24km'},
		{'width_km=20|length_km=30','15km'},
		{'width_mi=20|length_mi=30','24km'},
		{'length_km=20','10km'},
		{'length_mi=20','16km'},
		{'width_km=30','15km'},
		{'width_mi=30','24km'},
		{'area_km2=300','17km'},
		{'area_mi2=200','22km'},
		{'area_ha=30,000','17km'},
		{'area_acre=75,000','17km'},
		{'dim=50km','50km'},
		{'scale=100000','24km'},
		{'type=mountain','24km'},
		{'type=city|population=100000','11km'},
		{'type=mountain|length_km=20','10km'}
	})
	self:preprocess_equals('{{#invoke:Infobox dim | dim }}','')
end

-- Test scale
function p:test_scale()
	self:preprocess_equals_preprocess_many(
		'{{#invoke:Infobox dim | scale |','}}','{{#invoke:Infobox dim/sandbox | scale |','}}',{
			{'length_km=20|width_km=30'},
			{'length_mi=20|width_mi=30'},
			{'width_km=20|length_km=30'},
			{'width_mi=20|length_mi=30'},
			{'length_km=20'},
			{'length_mi=20'},
			{'width_km=30'},
			{'width_mi=30'},
			{'area_km2=300'},
			{'area_mi2=200'},
			{'area_ha=30,000'},
			{'area_acre=75,000'},
			{'dim=50km'},
			{'scale=100000'},
			{'type=mountain'},
			{'type=city|population=100000'},
			{'type=mountain|length_km=20'}			
		})
	self:preprocess_equals('{{#invoke:Infobox dim | scale}}','')
end

return p