Jump to content

Module:Infobox dim/testcases: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
viewport doesn't affect dim->dim computation
fix test cases
Line 23: Line 23:
{'type=city|population=100000','11km'},
{'type=city|population=100000','11km'},
{'type=mountain|length_km=20','10km'},
{'type=mountain|length_km=20','10km'},
{'length_km=20|viewport_cm=25','10km'},
{'length_km=20|viewport_cm=25','8km'},
{'length_km=20|viewport_px=800','10km'},
{'length_km=20|viewport_px=800','8km'},
{'area_ha=blerg',''},
{'area_ha=blerg',''},
{'',''}
{'',''}
Line 49: Line 49:
{'type=mountain','100000'},
{'type=mountain','100000'},
{'type=mountain|width_km=no','100000'},
{'type=mountain|width_km=no','100000'},
{'type=city|population=100000','112830'},
{'type=city|population=100000','110235'},
{'type=mountain|length_km=20','100000'},
{'type=mountain|length_km=20','100000'},
{'length_km=20|viewport_cm=25','40000'},
{'length_km=20|viewport_cm=25','80000'},
{'length_km=20|viewport_px=800','41667'},
{'length_km=20|viewport_px=800','83333'},
{'area_ha=blerg',''},
{'area_ha=blerg',''},
{'',''}
{'',''}
Line 61: Line 61:
function p:test_zoom()
function p:test_zoom()
self:preprocess_equals_sandbox_many('{{#invoke:Infobox dim','zoom', {
self:preprocess_equals_sandbox_many('{{#invoke:Infobox dim','zoom', {
{'length_km=20|width_km=30','12'},
{'length_km=20|width_km=30','10'},
{'length_mi=20|width_mi=30','11'},
{'length_mi=20|width_mi=30','9'},
{'width_km=20|length_km=30','12'},
{'width_km=20|length_km=30','10'},
{'width_mi=20|length_mi=30','11'},
{'width_mi=20|length_mi=30','9'},
{'length_km=20','12'},
{'length_km=20','10'},
{'length_mi=20','12'},
{'length_mi=20','9'},
{'width_km=30','12'},
{'width_km=30','10'},
{'width_mi=30','11'},
{'width_mi=30','9'},
{'area_km2=300','12'},
{'area_km2=300','9'},
{'area_mi2=200','11'},
{'area_mi2=200','9'},
{'area_ha=30,000','12'},
{'area_ha=30,000','9'},
{'area_acre=75,000','12'},
{'area_acre=75,000','9'},
{'dim=50km','10'},
{'dim=50km','9'},
{'scale=100000','12'},
{'scale=100000','12'},
{'type=mountain','12'},
{'type=mountain','10'},
{'type=mountain|width_km=no','12'},
{'type=mountain|width_km=no','10'},
{'type=city|population=100000','12'},
{'type=city|population=100000','10'},
{'type=mountain|length_km=20','12'},
{'type=mountain|length_km=20','10'},
{'length_km=20|viewport_cm=25','14'},
{'length_km=20|viewport_cm=25','12'},
{'length_km=20|viewport_px=800','14'},
{'length_km=20|viewport_px=800','12'},
{'area_ha=blerg',''},
{'area_ha=blerg',''},
{'',''}
{'',''}

Revision as of 01:18, 7 October 2024

-- 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_sandbox_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','10km'},
		{'type=mountain','10km'},
		{'type=mountain|width_km=no','10km'},
		{'type=city|population=100000','11km'},
		{'type=mountain|length_km=20','10km'},
		{'length_km=20|viewport_cm=25','8km'},
		{'length_km=20|viewport_px=800','8km'},
		{'area_ha=blerg',''},
		{'',''}
	})
end

-- Test scale
function p:test_scale()
	self:preprocess_equals_sandbox_many('{{#invoke:Infobox dim','scale', {
			{'length_km=20|width_km=30','150000'},
			{'length_mi=20|width_mi=30','241401'},
			{'width_km=20|length_km=30','150000'},
			{'width_mi=20|length_mi=30','241401'},
			{'length_km=20','100000'},
			{'length_mi=20','160934'},
			{'width_km=30','150000'},
			{'width_mi=30','241401'},
			{'area_km2=300','169221'},
			{'area_mi2=200','222361'},
			{'area_ha=30,000','169221'},
			{'area_acre=75,000','170210'},
			{'dim=50km','500000'},
			{'scale=100000','100000'},
			{'type=mountain','100000'},
		    {'type=mountain|width_km=no','100000'},
			{'type=city|population=100000','110235'},
			{'type=mountain|length_km=20','100000'},
			{'length_km=20|viewport_cm=25','80000'},
			{'length_km=20|viewport_px=800','83333'},
			{'area_ha=blerg',''},
			{'',''}
		})
end

-- Test zoom
function p:test_zoom()
	self:preprocess_equals_sandbox_many('{{#invoke:Infobox dim','zoom', {
			{'length_km=20|width_km=30','10'},
			{'length_mi=20|width_mi=30','9'},
			{'width_km=20|length_km=30','10'},
			{'width_mi=20|length_mi=30','9'},
			{'length_km=20','10'},
			{'length_mi=20','9'},
			{'width_km=30','10'},
			{'width_mi=30','9'},
			{'area_km2=300','9'},
			{'area_mi2=200','9'},
			{'area_ha=30,000','9'},
			{'area_acre=75,000','9'},
			{'dim=50km','9'},
			{'scale=100000','12'},
			{'type=mountain','10'},
			{'type=mountain|width_km=no','10'},
			{'type=city|population=100000','10'},
			{'type=mountain|length_km=20','10'},
			{'length_km=20|viewport_cm=25','12'},
			{'length_km=20|viewport_px=800','12'},
			{'area_ha=blerg',''},
			{'',''}
		})
end

return p