[luavsq] ユニットテスト用ユーティリティを追加
@@ -0,0 +1,63 @@ | ||
1 | +LuaUnitResult = {} | |
2 | + | |
3 | +LuaUnitResult.new = function() | |
4 | + local this = {} | |
5 | + | |
6 | + this.name = "" | |
7 | + this.class = "" | |
8 | + this.file = "" | |
9 | + this.line = 0 | |
10 | + this.assertions = 0 | |
11 | + this.time = 0.0 | |
12 | + this.failures = {} | |
13 | + this.errors = {} | |
14 | + | |
15 | + return this | |
16 | +end | |
17 | + | |
18 | +LuaUnitTestCase = {} | |
19 | + | |
20 | +LuaUnitTestCase.new = function() | |
21 | + local this = {} | |
22 | + | |
23 | + this.results = {} | |
24 | + | |
25 | + this.assertEquals = function( self, expected, actual ) | |
26 | + end | |
27 | + | |
28 | + this.assertTrue = function( self, actual ) | |
29 | + local result = LuaUnitResult.new() | |
30 | + self.assertions = self.assertions + 1 | |
31 | + if( not actual )then | |
32 | + local message = "Failed asserting that <boolean:false> is true." | |
33 | + table.insert( self.failures, message ) | |
34 | + end | |
35 | + table.insert( self.results, result ) | |
36 | + end | |
37 | + | |
38 | + this.assertFalse = function( self, actual ) | |
39 | + end | |
40 | + | |
41 | + this.debugPrint = function( self ) | |
42 | + for i = 0, table.maxn( self.failures ), 1 do | |
43 | + print( self.failures[i] ) | |
44 | + end | |
45 | + end | |
46 | + | |
47 | +end | |
48 | + | |
49 | +SampleTestCase = {} | |
50 | +SampleTestCase.new = function() | |
51 | + local this = {} | |
52 | + local parent = LuaUnitTestCase.new() | |
53 | + setmetatable( this, { __index = parent } ) | |
54 | + | |
55 | + this.testFoo = function( self ) | |
56 | + self:assertTrue( true ) | |
57 | + end | |
58 | + | |
59 | + return this | |
60 | +end | |
61 | + | |
62 | +local obj = SampleTestCase.new() | |
63 | +obj:testFoo() |