diff options
Diffstat (limited to 'tests/common.lua')
-rw-r--r-- | tests/common.lua | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/common.lua b/tests/common.lua index 0b231bd..f3dc6f7 100644 --- a/tests/common.lua +++ b/tests/common.lua | |||
@@ -176,6 +176,13 @@ function compare_values(val1, val2) | |||
176 | return true | 176 | return true |
177 | end | 177 | end |
178 | 178 | ||
179 | local test_count_pass = 0 | ||
180 | local test_count_total = 0 | ||
181 | |||
182 | function run_test_summary() | ||
183 | return test_count_pass, test_count_total | ||
184 | end | ||
185 | |||
179 | function run_test(testname, func, input, should_work, output) | 186 | function run_test(testname, func, input, should_work, output) |
180 | local function status_line(name, status, value) | 187 | local function status_line(name, status, value) |
181 | local statusmap = { [true] = ":success", [false] = ":error" } | 188 | local statusmap = { [true] = ":success", [false] = ":error" } |
@@ -191,10 +198,13 @@ function run_test(testname, func, input, should_work, output) | |||
191 | local correct = false | 198 | local correct = false |
192 | if success == should_work and compare_values(result, output) then | 199 | if success == should_work and compare_values(result, output) then |
193 | correct = true | 200 | correct = true |
201 | test_count_pass = test_count_pass + 1 | ||
194 | end | 202 | end |
203 | test_count_total = test_count_total + 1 | ||
195 | 204 | ||
196 | local teststatus = { [true] = "PASS", [false] = "FAIL" } | 205 | local teststatus = { [true] = "PASS", [false] = "FAIL" } |
197 | print("==> Test " .. testname .. ": " .. teststatus[correct]) | 206 | print(string.format("==> Test[%d] / %s: %s", |
207 | test_count_total, testname, teststatus[correct])) | ||
198 | 208 | ||
199 | status_line("Input", nil, input) | 209 | status_line("Input", nil, input) |
200 | if not correct then | 210 | if not correct then |
@@ -216,7 +226,7 @@ function run_test_group(testgroup, tests) | |||
216 | end | 226 | end |
217 | 227 | ||
218 | local function test_id(group, id) | 228 | local function test_id(group, id) |
219 | return string.format("%s [%d]", group, id) | 229 | return string.format("%s[%d]", group, id) |
220 | end | 230 | end |
221 | 231 | ||
222 | for k, v in ipairs(tests) do | 232 | for k, v in ipairs(tests) do |