-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunittest.lua
More file actions
75 lines (63 loc) · 2.2 KB
/
unittest.lua
File metadata and controls
75 lines (63 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
-- Prepare Lua's search path so ulutest will be found.
local bpattern={
["/"]="ulutest/?.so;",
["\\"]="ulutest\\?.dll;",
}
package.cpath=(bpattern[package.config:sub(1,1)] or "")..package.cpath
local ok,X=pcall(require, "lodepng")
if not ok then
error("\n\tThis is a test suite for 'lodepng'."..
"\n\tHowever, require 'lodepng' failed."..
"\n\tBuild it right here.")
end
local ok,ULU=pcall(require, "ulutest")
if not ok then
error("\n\tThis is a Unit Test implemented with 'ulutest'."..
"\n\tHowever, require 'ulutest' failed."..
"\n\tBuild it as a submodule right here.")
end
local TT=ULU.TT
ULU.RUN {
{
name="version",
TT("present", function(T) T:ASSERT_EQ("string", type(X.version)) end),
TT("value", function(T) T:ASSERT_EQ("0.1", X.version) end)
},
{
name="url",
TT("present", function(T) T:ASSERT_EQ("string", type(X.url)) end),
TT("value", function(T) T:ASSERT_EQ("https://github.com/vorgestern/LuaLodePNG.git", X.url) end)
},
{
name="lodepng.version",
TT("present", function(T) T:ASSERT_EQ("string", type(X.lodepng.version)) end),
TT("value", function(T) T:ASSERT_EQ("20250506", X.lodepng.version) end)
},
{
name="colortype",
TT("present", function(T)
T:ASSERT_EQ("table", type(X.colortype))
end),
TT("values", function(T)
T:ASSERT(X.colortype.LCT_GREY)
T:ASSERT(X.colortype.LCT_RGB)
T:ASSERT(X.colortype.LCT_PALETTE)
T:ASSERT(X.colortype.LCT_GREY_ALPHA)
T:ASSERT(X.colortype.LCT_RGBA)
end),
TT("tostring", function(T)
T:ASSERT_EQ("LCT_GREY", tostring(X.colortype.LCT_GREY))
T:ASSERT_EQ("LCT_RGB", tostring(X.colortype.LCT_RGB))
T:ASSERT_EQ("LCT_PALETTE", tostring(X.colortype.LCT_PALETTE))
T:ASSERT_EQ("LCT_GREY_ALPHA", tostring(X.colortype.LCT_GREY_ALPHA))
T:ASSERT_EQ("LCT_RGBA", tostring(X.colortype.LCT_RGBA))
end),
TT("numeric", function(T)
T:ASSERT_EQ(0, X.colortype.LCT_GREY:numeric())
T:ASSERT_EQ(2, X.colortype.LCT_RGB:numeric())
T:ASSERT_EQ(3, X.colortype.LCT_PALETTE:numeric())
T:ASSERT_EQ(4, X.colortype.LCT_GREY_ALPHA:numeric())
T:ASSERT_EQ(6, X.colortype.LCT_RGBA:numeric())
end)
}
}