Jump to content

Module:ConvertIB/testcases

From Wikipedia, the free encyclopedia
-- Unit tests for [[Module:ConvertIB]]. Click talk page to run tests.
local p = require('Module:UnitTests')

function p:test_main()
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert|100|m2||sqft}}', '{{Convert|100|m2|sqft|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert||m2|100|sqft}}', '{{Convert|100|sqft|m2|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert|1000|m||ft}}', '{{Convert|1000|m|ft|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert||m|1000|ft}}', '{{Convert|1000|ft|m|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert|100|km/h||mph}}', '{{Convert|100|km/h|mph|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert||km/h|100|mph}}', '{{Convert|100|mph|km/h|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert|1000|ha||acre}}', '{{Convert|1000|ha|acre|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert||ha|1000|acre}}', '{{Convert|1000|acre|ha|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert|1000|km2||sqmi}}', '{{Convert|1000|km2|sqmi|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert||km2|1000|sqmi}}', '{{Convert|1000|sqmi|km2|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert|5|ft||in}}', '{{Convert|5|ft|in|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert||ft|120|in}}', '{{Convert|120|in|ft|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert|375|ml||impoz||USoz}}', '{{Convert|375|ml|impoz+USoz|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert||ml|40|impoz||USoz}}', '{{Convert|40|impoz|ml+USoz|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert||ml||impoz|32|USoz}}', '{{Convert|32|USoz|ml+impoz|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert|180|cm||ft||in}}', '{{Convert|180|cm|ftin|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert||cm|5|ft||in}}', '{{Convert|5|ft|0|in|cm|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert||cm||ft|120|in}}', '{{Convert|120|in|cm|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert||cm|5|ft|6|in}}', '{{Convert|5|ft|6|in|cm|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert||ft||in|180|cm}}', '{{Convert|180|cm|ftin|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert|5|ft||in||cm}}', '{{Convert|5|ft|0|in|cm|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert||ft|120|in||cm}}', '{{Convert|120|in|cm|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert|5|ft|6|in||cm}}', '{{Convert|5|ft|6|in|cm|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert|8.5|kg||lb||oz}}', '{{Convert|8.5|kg|lboz|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert||kg|4|lb|3|oz}}', '{{Convert|4|lb|3|oz|kg|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert|65|kg||st||lb}}', '{{Convert|65|kg|lb+stlb|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert||kg|10|st||lb}}', '{{Convert|10|st|0|lb|kg+lb|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert||kg|11|st||lb}}', '{{Convert|11|st|0|lb|kg+lb|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert||kg|10|st|7|lb}}', '{{Convert|10|st|7|lb|kg+lb|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert||kg||st|145|lb}}', '{{Convert|145|lb|kg+stlb|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert|65|kg|10|st||lb}}', '{{Convert|65|kg|lb+stlb|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert||m2||sqft}}', '')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert||ml||impoz||USoz}}', '')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert|100|m2|100|sqft}}', '{{Convert|100|m2|sqft|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert|375|ml|40|impoz||USoz}}', '{{Convert|375|ml|impoz+USoz|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert|375|ml||impoz|32|USoz}}', '{{Convert|375|ml|impoz+USoz|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert||ml|40|impoz|32|USoz}}', '{{Convert|40|impoz|ml+USoz|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert|100|m2||sqft|4}}', '{{Convert|100|m2|sqft|4|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert|100|m2||sqft|sigfig=4}}', '{{Convert|100|m2|sqft|sigfig=4|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert||ml|40|impoz||USoz|2}}', '{{Convert|40|impoz|ml+USoz|2|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert||ml|40|impoz||USoz|sigfig=3}}', '{{Convert|40|impoz|ml+USoz|sigfig=3|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert||kg|10|st|7|lb|3}}', '{{Convert|10|st|7|lb|kg+lb|3|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert||kg|10|st|7|lb|sigfig=5}}', '{{Convert|10|st|7|lb|kg+lb|sigfig=5|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert|65|kg||st||lb|0}}', '{{Convert|65|kg|lb+stlb|0|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert|65|kg||st||lb|1}}', '{{Convert|65|kg|lb+stlb|1|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert|23|stone||kg||lb|lk=in|abbr=out}}', '{{Convert|23|st|kg+lb|lk=in|abbr=out}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert|160|kg||lb|-1|abbr=off}}', '{{Convert|160|kg|lb|-1|abbr=off}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert|150|L||USgal|1|abbr=off}}', '{{Convert|150|L|USgal|1|abbr=off}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert|3,287,263|km2|1,269,346|sqmi}}', '{{Convert|3,287,263|km2|sqmi|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert}}', '')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert|10}}', '')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert|10|m}}', '')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB|convert|10|m|2}}', '')
end

function p:test_sandbox()
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert|100|m2||sqft}}', '{{Convert|100|m2|sqft|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert||m2|100|sqft}}', '{{Convert|100|sqft|m2|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert|1000|m||ft}}', '{{Convert|1000|m|ft|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert||m|1000|ft}}', '{{Convert|1000|ft|m|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert|100|km/h||mph}}', '{{Convert|100|km/h|mph|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert||km/h|100|mph}}', '{{Convert|100|mph|km/h|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert|1000|ha||acre}}', '{{Convert|1000|ha|acre|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert||ha|1000|acre}}', '{{Convert|1000|acre|ha|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert|1000|km2||sqmi}}', '{{Convert|1000|km2|sqmi|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert||km2|1000|sqmi}}', '{{Convert|1000|sqmi|km2|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert|5|ft||in}}', '{{Convert|5|ft|in|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert||ft|120|in}}', '{{Convert|120|in|ft|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert|375|ml||impoz||USoz}}', '{{Convert|375|ml|impoz+USoz|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert||ml|40|impoz||USoz}}', '{{Convert|40|impoz|ml+USoz|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert||ml||impoz|32|USoz}}', '{{Convert|32|USoz|ml+impoz|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert|180|cm||ft||in}}', '{{Convert|180|cm|ftin|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert||cm|5|ft||in}}', '{{Convert|5|ft|0|in|cm|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert||cm||ft|120|in}}', '{{Convert|120|in|cm|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert||cm|5|ft|6|in}}', '{{Convert|5|ft|6|in|cm|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert||ft||in|180|cm}}', '{{Convert|180|cm|ftin|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert|5|ft||in||cm}}', '{{Convert|5|ft|0|in|cm|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert||ft|120|in||cm}}', '{{Convert|120|in|cm|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert|5|ft|6|in||cm}}', '{{Convert|5|ft|6|in|cm|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert|8.5|kg||lb||oz}}', '{{Convert|8.5|kg|lboz|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert||kg|4|lb|3|oz}}', '{{Convert|4|lb|3|oz|kg|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert|65|kg||st||lb}}', '{{Convert|65|kg|lb+stlb|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert||kg|10|st||lb}}', '{{Convert|10|st|0|lb|kg+lb|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert||kg|11|st||lb}}', '{{Convert|11|st|0|lb|kg+lb|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert||kg|10|st|7|lb}}', '{{Convert|10|st|7|lb|kg+lb|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert||kg||st|145|lb}}', '{{Convert|145|lb|kg+stlb|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert|65|kg|10|st||lb}}', '{{Convert|65|kg|lb+stlb|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert||m2||sqft}}', '')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert||ml||impoz||USoz}}', '')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert|100|m2|100|sqft}}', '{{Convert|100|m2|sqft|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert|375|ml|40|impoz||USoz}}', '{{Convert|375|ml|impoz+USoz|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert|375|ml||impoz|32|USoz}}', '{{Convert|375|ml|impoz+USoz|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert||ml|40|impoz|32|USoz}}', '{{Convert|40|impoz|ml+USoz|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert|100|m2||sqft|4}}', '{{Convert|100|m2|sqft|4|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert|100|m2||sqft|sigfig=4}}', '{{Convert|100|m2|sqft|sigfig=4|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert||ml|40|impoz||USoz|2}}', '{{Convert|40|impoz|ml+USoz|2|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert||ml|40|impoz||USoz|sigfig=3}}', '{{Convert|40|impoz|ml+USoz|sigfig=3|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert||kg|10|st|7|lb|3}}', '{{Convert|10|st|7|lb|kg+lb|3|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert||kg|10|st|7|lb|sigfig=5}}', '{{Convert|10|st|7|lb|kg+lb|sigfig=5|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert|65|kg||st||lb|0}}', '{{Convert|65|kg|lb+stlb|0|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert|65|kg||st||lb|1}}', '{{Convert|65|kg|lb+stlb|1|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert|23|stone||kg||lb|lk=in|abbr=out}}', '{{Convert|23|st|kg+lb|lk=in|abbr=out}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert|160|kg||lb|-1|abbr=off}}', '{{Convert|160|kg|lb|-1|abbr=off}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert|150|L||USgal|1|abbr=off}}', '{{Convert|150|L|USgal|1|abbr=off}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert|3,287,263|km2|1,269,346|sqmi}}', '{{Convert|3,287,263|km2|sqmi|abbr=on}}')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert}}', '')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert|10}}', '')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert|10|m}}', '')
	self:preprocess_equals_preprocess('{{#invoke:ConvertIB/sandbox|convert|10|m|2}}', '')
end

return p