Module:Storm categories/testcases
| This is the test cases page for the module Module:Storm categories. Results of the test cases. |
local ScribuntoUnit = require('Module:ScribuntoUnit')
local sc = require('Module:Storm categories/sandbox') -- the module to be tested
local suite = ScribuntoUnit:new()
function suite:testColors()
self:assertEquals('c0c0c0', string.lower(sc._color()))
self:assertEquals('c0c0c0', string.lower(sc._color(nil)))
-- Ensure that none of the global scale colors are falling back to default.
self:assertFalse('c0c0c0' == string.lower(sc._color('disturbance')))
self:assertFalse('c0c0c0' == string.lower(sc._color('depression')))
self:assertFalse('c0c0c0' == string.lower(sc._color('storm')))
self:assertFalse('c0c0c0' == string.lower(sc._color('sts')))
-- Ensure that none of the SSHWS scale colors are falling back to default.
self:assertFalse('c0c0c0' == string.lower(sc._color('cat1')))
self:assertFalse('c0c0c0' == string.lower(sc._color('cat2')))
self:assertFalse('c0c0c0' == string.lower(sc._color('cat3')))
self:assertFalse('c0c0c0' == string.lower(sc._color('cat4')))
self:assertFalse('c0c0c0' == string.lower(sc._color('cat5')))
-- nullIfMissing
self:assertEquals(nil, sc._color('not-an-actual-category', true))
self:assertFalse(nil == sc._color('cat1', true))
end
function suite:testNames()
self:assertEquals('Unknown-strength storm', sc._name())
self:assertEquals('Unknown-strength storm', sc._name(nil))
-- Ensure that none of the global scale colors are falling back to default.
self:assertFalse('Unknown-strength storm' == sc._name('disturbance'))
self:assertFalse('Unknown-strength storm' == sc._name('depression'))
self:assertFalse('Unknown-strength storm' == sc._name('storm'))
self:assertFalse('Unknown-strength storm' == sc._name('sts'))
-- Ensure that none of the SSHWS scale colors are falling back to default.
self:assertFalse('Unknown-strength storm' == sc._name('cat1'))
self:assertFalse('Unknown-strength storm' == sc._name('cat2'))
self:assertFalse('Unknown-strength storm' == sc._name('cat3'))
self:assertFalse('Unknown-strength storm' == sc._name('cat4'))
self:assertFalse('Unknown-strength storm' == sc._name('cat5'))
-- Basin differences
self:assertFalse(sc._name('cat1') == sc._name('cat1', 'atl'))
self:assertFalse(sc._name('cat1') == sc._name('cat1', 'wpac'))
-- Default fallback
self:assertEquals(sc._name('cat1', 'default'), sc._name('cat1', 'basin-that-does-not-exist'))
-- nullIfMissing
self:assertEquals(nil, sc._name('not-an-actual-category', nil, true))
self:assertFalse(nil == sc._name('cat1', nil, true))
self:assertFalse(nil == sc._name('cat1', 'atl', true))
self:assertFalse(nil == sc._name('cat1', 'wpac', true))
end
function suite:testSortkey()
self:assertEquals(0, sc._sortkey())
self:assertEquals(0, sc._sortkey(nil))
-- Ensure that none of the global scale colors are falling back to default.
self:assertFalse(0 == sc._sortkey('disturbance'))
self:assertFalse(0 == sc._sortkey('depression'))
self:assertFalse(0 == sc._sortkey('storm'))
self:assertFalse(0 == sc._sortkey('sts'))
-- Ensure that none of the SSHWS scale colors are falling back to default.
self:assertFalse(0 == sc._sortkey('cat1'))
self:assertFalse(0 == sc._sortkey('cat2'))
self:assertFalse(0 == sc._sortkey('cat3'))
self:assertFalse(0 == sc._sortkey('cat4'))
self:assertFalse(0 == sc._sortkey('cat5'))
-- Ensure that sortkeys are following the proper order.
self:assertTrue(sc._sortkey('cat4') < sc._sortkey('cat5'))
self:assertTrue(sc._sortkey('cat3') < sc._sortkey('cat4'))
self:assertTrue(sc._sortkey('cat2') < sc._sortkey('cat3'))
self:assertTrue(sc._sortkey('cat1') < sc._sortkey('cat2'))
self:assertTrue(sc._sortkey('sts') < sc._sortkey('cat1'))
self:assertTrue(sc._sortkey('storm') < sc._sortkey('sts'))
self:assertTrue(sc._sortkey('depression') < sc._sortkey('storm'))
self:assertTrue(sc._sortkey('disturbance') < sc._sortkey('depression'))
self:assertTrue(sc._sortkey('unknown') < sc._sortkey('disturbance'))
-- nullIfMissing
self:assertEquals(nil, sc._sortkey('not-an-actual-category', true))
self:assertFalse(nil == sc._sortkey('cat1', true))
end
function suite:testIcons()
self:assertEquals("'''?'''", sc._icon())
self:assertEquals("'''?'''", sc._icon(nil))
-- Ensure that none of the global scale colors are falling back to default.
self:assertFalse("'''?'''" == sc._icon('disturbance'))
self:assertFalse("'''?'''" == sc._icon('depression'))
self:assertFalse("'''?'''" == sc._icon('storm'))
self:assertFalse("'''?'''" == sc._icon('sts'))
-- Ensure that none of the SSHWS scale colors are falling back to default.
self:assertFalse("'''?'''" == sc._icon('cat1'))
self:assertFalse("'''?'''" == sc._icon('cat2'))
self:assertFalse("'''?'''" == sc._icon('cat3'))
self:assertFalse("'''?'''" == sc._icon('cat4'))
self:assertFalse("'''?'''" == sc._icon('cat5'))
-- nullIfMissing
self:assertEquals(nil, sc._icon('not-an-actual-category', true))
self:assertFalse(nil == sc._icon('cat1', true))
end
function suite:testIsEqual()
-- Equal existing categories
self:assertTrue(sc._isEqual("depression", "depression"))
-- Equal aliases
self:assertTrue(sc._isEqual("depression", "td"))
self:assertTrue(sc._isEqual("severets", "severe"))
self:assertTrue(sc._isEqual("shdepression", "depression"))
-- Not equal existing categories
self:assertFalse(sc._isEqual("depression", "unknown"))
self:assertFalse(sc._isEqual("depression", "cat5"))
self:assertFalse(sc._isEqual("unknown", "cat5"))
-- '5' is a generic ID that only has a color and an
self:assertFalse(sc._isEqual("5", "cat5"))
self:assertFalse(sc._isEqual("a5", "aus5"))
self:assertFalse(sc._isEqual("aus5", "cat5"))
--== EDGE CASES
-- Only one category exists
self:assertFalse(sc._isEqual("depression", "not-an-actual-category"))
-- None of the categories exist
self:assertFalse(sc._isEqual("not-an-actual-category", "also-not-an-actual-category"))
-- None of the categories exist but the IDs are equal
self:assertTrue(sc._isEqual("not-an-actual-category", "not-an-actual-category"))
-- Nil argument 1
self:assertFalse(sc._isEqual(nil, "not-an-actual-category"))
-- Nil argument 2
self:assertFalse(sc._isEqual("not-an-actual-category", nil))
-- Nil arguments (but equal)
self:assertFalse(sc._isEqual(nil, nil))
-- Missing argument 2
self:assertFalse(sc._isEqual("not-an-actual-category"))
-- Missing arguments
self:assertFalse(sc._isEqual())
end
return suite
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.