Regularized unit testing framework.
This commit is contained in:
@@ -3,10 +3,7 @@
|
||||
# in the order that they're supposed to be loaded.
|
||||
#
|
||||
|
||||
utils.lua
|
||||
inspect.lua
|
||||
ut-misc.lua
|
||||
ut-table.lua
|
||||
ut-globaldb.lua
|
||||
ut-cellgrid.lua
|
||||
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
local ut = {}
|
||||
|
||||
function ut.cellgrid()
|
||||
end
|
||||
|
||||
|
||||
rununittests(ut)
|
||||
@@ -1,7 +1,6 @@
|
||||
makeclass("unittests")
|
||||
|
||||
local ut = {}
|
||||
|
||||
function ut.globaldb()
|
||||
function unittests.globaldb()
|
||||
globaldb.enable()
|
||||
local g1a = global("unittest-g1")
|
||||
local g2a = global("unittest-g2")
|
||||
@@ -13,4 +12,3 @@ function ut.globaldb()
|
||||
assert(g2a.__global == "unittest-g2")
|
||||
end
|
||||
|
||||
rununittests(ut)
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
|
||||
local ut = {}
|
||||
|
||||
function ut.idalloc()
|
||||
cunittests.idalloc()
|
||||
end
|
||||
|
||||
function ut.planemap()
|
||||
cunittests.planemap()
|
||||
end
|
||||
|
||||
rununittests(ut)
|
||||
@@ -1,27 +1,25 @@
|
||||
|
||||
local ut = {}
|
||||
makeclass("unittests")
|
||||
|
||||
function ut.table_count()
|
||||
function unittests.tables()
|
||||
-- check table.count
|
||||
assert(table.count({}) == 0)
|
||||
assert(table.count({a=1,b=2}) == 2)
|
||||
assert(table.count({[2]=5,[5]=3}) == 2)
|
||||
end
|
||||
|
||||
function ut.table_clear()
|
||||
-- check table.clear
|
||||
local t = { a = 1, b = 2 }
|
||||
table.clear(t)
|
||||
assert(t.a == nil)
|
||||
assert(t.b == nil)
|
||||
assert(table.count(t) == 0)
|
||||
end
|
||||
|
||||
function ut.table_empty()
|
||||
-- check table.empty
|
||||
assert(table.empty({}) == true)
|
||||
assert(table.empty({1}) == false)
|
||||
assert(table.empty({a=1}) == false)
|
||||
end
|
||||
|
||||
function ut.table_equal()
|
||||
-- check table.equal
|
||||
assert(table.equal({},{}))
|
||||
assert(not table.equal({}, {1}))
|
||||
assert(not table.equal({1}, {}))
|
||||
@@ -31,9 +29,8 @@ function ut.table_equal()
|
||||
assert(not table.equal({1,2,3}, {1,2}))
|
||||
assert(table.equal({a=1,b=2},{a=1,b=2}))
|
||||
assert(not table.equal({a=1,b=3},{a=1,b=2}))
|
||||
end
|
||||
|
||||
function ut.table_push()
|
||||
-- check table.push
|
||||
t = {}
|
||||
table.push(t, 1)
|
||||
assert(table.equal(t, {1}))
|
||||
@@ -41,9 +38,8 @@ function ut.table_push()
|
||||
assert(table.equal(t, {1,2}))
|
||||
table.push(t, 3)
|
||||
assert(table.equal(t, {1,2,3}))
|
||||
end
|
||||
|
||||
function ut.table_findremove()
|
||||
|
||||
-- check table.findremove
|
||||
t = {1,2,3,4,5,1,2,3,4,5}
|
||||
table.findremove(t, 2)
|
||||
assert(table.equal(t, {1,3,4,5,1,3,4,5}))
|
||||
@@ -53,7 +49,7 @@ function ut.table_findremove()
|
||||
assert(table.equal(t, {3,4,3,4}))
|
||||
end
|
||||
|
||||
function ut.queues()
|
||||
function unittests.queues()
|
||||
local q = queue.create()
|
||||
assert(q.head == 1000000)
|
||||
assert(q.tail == 1000000)
|
||||
@@ -78,6 +74,3 @@ function ut.queues()
|
||||
assert(q.tail == 1000002)
|
||||
assert(queue.size(q) == 0)
|
||||
end
|
||||
|
||||
rununittests(ut)
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
|
||||
|
||||
function rununittests(tab)
|
||||
for k, v in pairs(tab) do
|
||||
v()
|
||||
end
|
||||
end
|
||||
|
||||
function crash2()
|
||||
local tab = nil
|
||||
tab[3] = 1
|
||||
end
|
||||
|
||||
function crash1()
|
||||
crash2()
|
||||
end
|
||||
|
||||
function doyield()
|
||||
coroutine.yield()
|
||||
end
|
||||
Reference in New Issue
Block a user