Modul:Homokozó/Tgr/Set/tests
Homokozó/Tgr/Set modul tesztek[mi ez?]
Név | Várt | Tényleges | |
---|---|---|---|
testRemove | |||
testSubset | |||
testEquals | |||
testDifference | |||
testCreate | |||
testIntersect | |||
testUnion | |||
testInsert | |||
testHas |
local Set = require('Modul:Homokozó/Tgr/Set')
local ScribuntoUnit = require('Modul:ScribuntoUnit')
local suite = ScribuntoUnit:new()
function suite:makeSets()
local set1 = Set({1,2,3})
local set2 = Set({3,4,5})
local set3 = Set({'a','b','c'})
return set1, set2, set3
end
function suite:testCreate()
local set1, set2, set3 = self:makeSets()
end
function suite:testHas()
local set1, set2, set3 = self:makeSets()
self:assertTrue(set1:has(2))
self:assertFalse(set1:has(4))
self:assertTrue(set3:has('a'))
self:assertFalse(set3:has('z'))
end
function suite:testInsert()
local set1, set2, set3 = self:makeSets()
set1:insert('x')
self:assertTrue(set1:has('x'))
end
function suite:testRemove()
local set1, set2, set3 = self:makeSets()
set1:remove(2)
set3:remove('a')
self:assertFalse(set1:has(2))
self:assertFalse(set3:has('a'))
end
function suite:testEquals()
local set1 = Set({1,2,3})
local set2 = Set({1,2,3})
local set3 = Set({1,2,3,4})
self:assertTrue(set1 == set2)
self:assertFalse(set1 == set3)
end
function suite:testSubset()
local set1, set2, set3 = self:makeSets()
local set1 = Set({1,2,3})
local set2 = Set({1,2,3,4})
self:assertTrue(set1 < set2)
self:assertTrue(set1 <= set2)
self:assertFalse(set1 < set1)
end
function suite:testUnion()
local set1, set2, set3 = self:makeSets()
self:assertEquals(Set({1,2,3,4,5}), set1 + set2)
self:assertEquals(Set({1,2,3,4,5}), set1 .. set2)
end
function suite:testIntersect()
local set1, set2, set3 = self:makeSets()
self:assertEquals(Set({3}), Set.intersect(set1, set2))
end
function suite:testDifference()
local set1, set2, set3 = self:makeSets()
self:assertEquals(Set({1,2}), set1 - set2)
end
return suite