-
Notifications
You must be signed in to change notification settings - Fork 9
/
tests.lua
67 lines (52 loc) · 1.38 KB
/
tests.lua
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
--
-- Tests for lib/parser.lua
--
-- Unit testing starts
-- use https://github.com/rjpcomputing/luaunit
local LuaUnit = require('luaunit')
require('lib/parser')
TestMaxWeight = {} --class
TestMaxHeight = {} --class
--
-- maxweight
--
function TestMaxWeight:testWithoutUnit()
result = parse_maxweight("150")
assertEquals( type(result), 'number' )
assertEquals( result, 150 )
end
function TestMaxWeight:testWithUnitNoSpace()
result = parse_maxweight("30t")
assertEquals( type(result), 'number' )
assertEquals( result, 30 )
end
function TestMaxWeight:testWithUnitMeterSpace()
result = parse_maxheight("3 m")
assertEquals( type(result), 'number' )
assertEquals( result, 3 )
end
--
-- maxheight
--
function TestMaxHeight:testWithUnitMeterNoSpace()
result = parse_maxheight("30m")
assertEquals( type(result), 'number' )
assertEquals( result, 30 )
end
function TestMaxHeight:testWithUnitMeterSpace()
result = parse_maxheight("30 m")
assertEquals( type(result), 'number' )
assertEquals( result, 30 )
end
function TestMaxHeight:testWithUnitFootInch()
result = parse_maxheight("13'3\"")
assertEquals( type(result), 'number' )
assertEquals( result, 4.5 )
end
function TestMaxHeight:testWithUnitFootInch2()
result = parse_maxheight("11'6\"")
assertEquals( type(result), 'number' )
assertEquals( result, 3.9 )
end
-- class TestMyStuff
LuaUnit:run()