Module:Sandbox/isaacl/ColourSpace/testcases
Appearance
![]() | This is the test cases page for the module Module:Sandbox/isaacl/ColourSpace. Results of the test cases. |
-- Unit test cases for [[Module:Sandbox/isaacl/ColourSpace]].
-- Click on talk page to run tests.
local me = require('Module:UnitTests')
local cs = require('Module:Sandbox/isaacl/ColourSpace')
function me:test_Colour_convert_template_identity()
self:preprocess_equals('{{User:Isaacl/Colour convert|127|0|255|to=sRGB24bit}}',
"127, 0, 255")
self:preprocess_equals('{{User:Isaacl/Colour convert|127|0|255|to=sRGB24bit|separator=---}}',
"127---0---255")
self:preprocess_equals('{{User:Isaacl/Colour convert|#7F|#00|#FF|from=sRGB24bitHex|to=sRGB24bitHex}}',
"#7F, #00, #FF")
self:preprocess_equals('{{User:Isaacl/Colour convert|49.8039291568627%|0%|100%|from=sRGB|to=sRGB}}',
"49.8039291568627%, 0%, 100%")
self:preprocess_equals('{{User:Isaacl/Colour convert|#7F00FF|to=sRGB24bitHexString}}',
"#7F00FF")
end
function me:test_Colour_convert_template_sRGB()
self:preprocess_equals('{{User:Isaacl/Colour convert|49.803921568627%|0%|100%|from=sRGB|to=sRGB24bit}}',
"127, 0, 255")
self:preprocess_equals('{{User:Isaacl/Colour convert|49.803921568627%|0%|100%|from=sRGB|to=sRGB24bitHex}}',
"#7F, #00, #FF")
self:preprocess_equals('{{User:Isaacl/Colour convert|49.803921568627%|0%|100%|from=sRGB}}',
"127, 0, 255")
self:preprocess_equals('{{User:Isaacl/Colour convert|49.803921568627%|0%|100%|to=sRGB24bit}}',
"127, 0, 255")
self:preprocess_equals('{{User:Isaacl/Colour convert|49.803921568627%|0%|100%|to=sRGB24bitHex}}',
"#7F, #00, #FF")
self:preprocess_equals('{{User:Isaacl/Colour convert|49.803921568627%|0%|100%}}',
"127, 0, 255")
self:preprocess_equals('{{User:Isaacl/Colour convert|49.803921568627%|0%|100%|to=sRGB24bitHexString}}',
"#7F00FF")
end
function me:test_Colour_convert_template_sRGB24bit()
self:preprocess_equals('{{User:Isaacl/Colour convert|127|0|255|from=sRGB24bit}}',
"49.803921568627%, 0%, 100%")
self:preprocess_equals('{{User:Isaacl/Colour convert|127|0|255|from=sRGB24bit|separator=:}}',
"49.803921568627%:0%:100%")
self:preprocess_equals('{{User:Isaacl/Colour convert|127|0|255|from=sRGB24bit|to=sRGB}}',
"49.803921568627%, 0%, 100%")
self:preprocess_equals('{{User:Isaacl/Colour convert|127|0|255}}',
"49.803921568627%, 0%, 100%")
self:preprocess_equals('{{User:Isaacl/Colour convert|127|0|255|separator=:}}',
"49.803921568627%:0%:100%")
self:preprocess_equals('{{User:Isaacl/Colour convert|127|0|255|to=sRGB}}',
"49.803921568627%, 0%, 100%")
self:preprocess_equals('{{User:Isaacl/Colour convert|127|0|255|to=sRGB24bitHexString}}',
"#7F00FF")
end
function me:test_Colour_convert_template_sRGB24bitHex()
self:preprocess_equals('{{User:Isaacl/Colour convert|#7F|#00|#FF|from=sRGB24bitHex|to=sRGB24bit}}',
"127, 0, 255")
self:preprocess_equals('{{User:Isaacl/Colour convert|#7F|#00|#FF|to=sRGB24bit}}',
"127, 0, 255")
self:preprocess_equals('{{User:Isaacl/Colour convert|#7F|#00|#FF|to=sRGB}}',
"49.803921568627%, 0%, 100%")
self:preprocess_equals('{{User:Isaacl/Colour convert|#7F|#00|#FF|to=sRGB24bitHexString}}',
"#7F00FF")
end
function me:test_Colour_convert_template_sRGB24bitHexString()
self:preprocess_equals('{{User:Isaacl/Colour convert|#7F00FF|from=sRGB24bitHexString|to=sRGB24bit}}',
"127, 0, 255")
self:preprocess_equals('{{User:Isaacl/Colour convert|#7F00FF|from=sRGB24bitHexString|to=sRGB}}',
"49.803921568627%, 0%, 100%")
self:preprocess_equals('{{User:Isaacl/Colour convert|#7f00ff|from=sRGB24bitHexString}}',
"127, 0, 255")
self:preprocess_equals('{{User:Isaacl/Colour convert|#a2f|from=sRGB24bitHexString}}',
"170, 34, 255")
self:preprocess_equals('{{User:Isaacl/Colour convert|#a2f|from=sRGB24bitHexString|to=sRGB24bitHex}}',
"#AA, #22, #FF")
self:preprocess_equals('{{User:Isaacl/Colour convert|#7F00FF|to=sRGB24bit}}',
"127, 0, 255")
self:preprocess_equals('{{User:Isaacl/Colour convert|#7F00FF|to=sRGB}}',
"49.803921568627%, 0%, 100%")
self:preprocess_equals('{{User:Isaacl/Colour convert|#7f00ff}}',
"127, 0, 255")
self:preprocess_equals('{{User:Isaacl/Colour convert|#a2f}}',
"170, 34, 255")
self:preprocess_equals('{{User:Isaacl/Colour convert|#a2f|to=sRGB24bitHex}}',
"#AA, #22, #FF")
end
function me:test_Colour_convert_template_W3Cnames()
self:preprocess_equals('{{User:Isaacl/Colour convert|70|130|180|to=W3Cnames}}',
"steelblue")
self:preprocess_equals('{{User:Isaacl/Colour convert|0|255|127|to=W3Cnames}}',
"springgreen")
self:preprocess_equals('{{User:Isaacl/Colour convert|102|205|170|to=W3Cnames}}',
"mediumaquamarine")
self:preprocess_equals('{{User:Isaacl/Colour convert|102|51|153|to=W3Cnames}}',
"rebeccapurple")
self:preprocess_equals('{{User:Isaacl/Colour convert|steelblue|from=W3Cnames}}',
"70, 130, 180")
self:preprocess_equals('{{User:Isaacl/Colour convert|springgreen|from=W3Cnames}}',
"0, 255, 127")
self:preprocess_equals('{{User:Isaacl/Colour convert|mediumaquamarine|from=W3Cnames}}',
"102, 205, 170")
self:preprocess_equals('{{User:Isaacl/Colour convert|rebeccapurple|from=W3Cnames}}',
"102, 51, 153")
self:preprocess_equals('{{User:Isaacl/Colour convert|mediumaquamarine|from=W3Cnames|to=sRGB}}',
"40%, 80.392156862745%, 66.666666666667%")
self:preprocess_equals('{{User:Isaacl/Colour convert|adamantine|from=W3Cnames|to=}}',
"InvalidValue badInputValues")
self:preprocess_equals('{{User:Isaacl/Colour convert|112|205|170|to=W3Cnames}}',
"InvalidValue conversionError 112, 205, 170")
self:preprocess_equals('{{User:Isaacl/Colour convert|rebeccapurple|from=W3Cnames|to=sRGB24bitHexString}}',
"#663399")
self:preprocess_equals('{{User:Isaacl/Colour convert|#663399|to=W3Cnames|from=sRGB24bitHexString}}',
"rebeccapurple")
end
function me:test_ColourSpaceModule()
self:preprocess_equals('{{#invoke:Sandbox/isaacl/ColourSpace|convertColour|127|0|255|to=sRGB}}',
"49.803921568627%, 0%, 100%")
self:preprocess_equals('{{#invoke:Sandbox/isaacl/ColourSpace|convertColour|127|0|255}}',
"49.803921568627%, 0%, 100%")
self:preprocess_equals('{{#invoke:Sandbox/isaacl/ColourSpace|convertColour|127|0|255|to=sRGB24bitHex}}',
"#7F, #00, #FF")
end
return me