• R/O
  • SSH
  • HTTPS

cstl: Commit


Commit MetaInfo

Revision407 (tree)
Time2010-10-06 22:07:54
Authorkatono

Log Message

TestCaseにsetup/teardownを追加。
*Result構造体を追加。

Change Summary

Incremental Difference

--- branches/try-vfunc/unittest/TestSuite.c (revision 406)
+++ branches/try-vfunc/unittest/TestSuite.c (revision 407)
@@ -1,27 +1,39 @@
1+#include <string.h>
12 #include "TestCase.h"
23 #include "TestSuite.h"
34 #include "LibcImpl.h"
45
56
6-size_t TestSuite_init(const TestSuite *self)
7+static void TestSuite_clear_result(TestSuite *self)
78 {
9+ self->setup_error = 0;
10+ self->teardown_error = 0;
11+ memset(&self->result, 0, sizeof(self->result));
12+}
13+
14+size_t TestSuite_init(TestSuite *self)
15+{
816 size_t i;
917 for (i = 0; self->test_cases[i].name != 0; i++) {
1018 TestCase_init(&self->test_cases[i]);
1119 }
20+ TestSuite_clear_result(self);
21+ self->result.num_tests = i;
1222 return i;
1323 }
1424
15-size_t TestSuite_cleanup(const TestSuite *self)
25+size_t TestSuite_cleanup(TestSuite *self)
1626 {
1727 size_t i;
1828 for (i = 0; self->test_cases[i].name != 0; i++) {
1929 TestCase_cleanup(&self->test_cases[i]);
2030 }
31+ TestSuite_clear_result(self);
32+ self->result.num_tests = i;
2133 return i;
2234 }
2335
24-int TestSuite_setup(const TestSuite *self)
36+static int TestSuite_setup(const TestSuite *self)
2537 {
2638 int ret = 0;
2739 if (self->setup) {
@@ -30,7 +42,7 @@
3042 return ret;
3143 }
3244
33-int TestSuite_teardown(const TestSuite *self)
45+static int TestSuite_teardown(const TestSuite *self)
3446 {
3547 int ret = 0;
3648 if (self->teardown) {
@@ -39,22 +51,33 @@
3951 return ret;
4052 }
4153
42-enum TestSuiteErr TestSuite_test(const TestSuite *self, size_t *ncases, size_t *ncases_failed,
54+enum TestSuiteErr TestSuite_test(TestSuite *self, size_t *ncases, size_t *ncases_failed,
4355 size_t *nasserts, size_t *nasserts_failed)
4456 {
4557 size_t i;
46- int err;
4758 *ncases = *ncases_failed = *nasserts = *nasserts_failed = 0;
4859 PRINTF1("Suite: %s\n", self->name);
49- err = TestSuite_setup(self);
50- if (err) {
51- PRINTF1(" SETUP FAILED: error[%d]\n", err);
60+ self->setup_error = TestSuite_setup(self);
61+ if (self->setup_error) {
62+ PRINTF1(" SETUP ERROR[%d]\n", self->setup_error);
5263 PRINTF0("\n");
64+ self->result.num_errors_setup++;
5365 return SETUP_NG;
5466 }
5567 for (i = 0; self->test_cases[i].name != 0; i++) {
5668 size_t na, naf;
69+ TestCaseResult case_result;
5770 TestCase_test(&self->test_cases[i], &na, &naf);
71+ TestCase_get_result(&self->test_cases[i], &case_result);
72+ self->result.case_result.num_asserts += case_result.num_asserts;
73+ self->result.case_result.num_asserts_ran += case_result.num_asserts_ran;
74+ self->result.case_result.num_asserts_failed += case_result.num_asserts_failed;
75+ self->result.case_result.num_errors_setup += case_result.num_errors_setup;
76+ self->result.case_result.num_errors_teardown += case_result.num_errors_teardown;
77+ self->result.num_tests_ran++;
78+ if (case_result.num_asserts_failed > 0) {
79+ self->result.num_tests_failed++;
80+ }
5881 (*nasserts) += na;
5982 (*nasserts_failed) += naf;
6083 if (naf > 0) {
@@ -62,10 +85,11 @@
6285 }
6386 }
6487 (*ncases) += i;
65- err = TestSuite_teardown(self);
66- if (err) {
67- PRINTF1(" TEARDOWN FAILED: error[%d]\n", err);
88+ self->teardown_error = TestSuite_teardown(self);
89+ if (self->teardown_error) {
90+ PRINTF1(" TEARDOWN ERROR[%d]\n", self->teardown_error);
6891 PRINTF0("\n");
92+ self->result.num_errors_teardown++;
6993 return TEARDOWN_NG;
7094 }
7195 PRINTF0("\n");
@@ -72,27 +96,39 @@
7296 return SUITE_OK;
7397 }
7498
75-enum TestSuiteErr TestSuite_test_selected(const TestSuite *self, int case_idx, size_t *ncases, size_t *ncases_failed,
99+enum TestSuiteErr TestSuite_test_selected(TestSuite *self, int case_idx, size_t *ncases, size_t *ncases_failed,
76100 size_t *nasserts, size_t *nasserts_failed)
77101 {
78- int err;
102+ TestCaseResult case_result;
79103 *ncases = *ncases_failed = *nasserts = *nasserts_failed = 0;
80104 PRINTF1("Suite: %s\n", self->name);
81- err = TestSuite_setup(self);
82- if (err) {
83- PRINTF1(" SETUP FAILED: error[%d]\n", err);
105+ self->setup_error = TestSuite_setup(self);
106+ if (self->setup_error) {
107+ PRINTF1(" SETUP ERROR[%d]\n", self->setup_error);
84108 PRINTF0("\n");
109+ self->result.num_errors_setup++;
85110 return SETUP_NG;
86111 }
87112 TestCase_test(&self->test_cases[case_idx], nasserts, nasserts_failed);
113+ TestCase_get_result(&self->test_cases[case_idx], &case_result);
114+ self->result.case_result.num_asserts += case_result.num_asserts;
115+ self->result.case_result.num_asserts_ran += case_result.num_asserts_ran;
116+ self->result.case_result.num_asserts_failed += case_result.num_asserts_failed;
117+ self->result.case_result.num_errors_setup += case_result.num_errors_setup;
118+ self->result.case_result.num_errors_teardown += case_result.num_errors_teardown;
119+ self->result.num_tests_ran++;
120+ if (case_result.num_asserts_failed > 0) {
121+ self->result.num_tests_failed++;
122+ }
88123 if (*nasserts_failed > 0) {
89124 *ncases_failed = 1;
90125 }
91126 *ncases = 1;
92- err = TestSuite_teardown(self);
93- if (err) {
94- PRINTF1(" TEARDOWN FAILED: error[%d]\n", err);
127+ self->teardown_error = TestSuite_teardown(self);
128+ if (self->teardown_error) {
129+ PRINTF1(" TEARDOWN ERROR[%d]\n", self->teardown_error);
95130 PRINTF0("\n");
131+ self->result.num_errors_teardown++;
96132 return TEARDOWN_NG;
97133 }
98134 PRINTF0("\n");
@@ -99,3 +135,8 @@
99135 return SUITE_OK;
100136 }
101137
138+void TestSuite_get_result(TestSuite *self, TestSuiteResult *result)
139+{
140+ *result = self->result;
141+}
142+
--- branches/try-vfunc/unittest/TestCase.c (revision 406)
+++ branches/try-vfunc/unittest/TestCase.c (revision 407)
@@ -1,9 +1,7 @@
1+#include <string.h>
12 #include "TestCase.h"
23 #include "LibcImpl.h"
34
4-#define LIST_BEGIN(list) (list)->next
5-#define LIST_END(list) (list)
6-
75 static TestCase *current_case;
86 static jmp_buf fatal_jmp;
97
@@ -13,10 +11,18 @@
1311 static TestAssertion *list_pop(TestAssertion *list);
1412 static int list_empty(TestAssertion *list);
1513
14+static void TestCase_clear_result(TestCase *self)
15+{
16+ self->setup_error = 0;
17+ self->teardown_error = 0;
18+ memset(&self->result, 0, sizeof(self->result));
19+}
20+
1621 void TestCase_init(TestCase *self)
1722 {
1823 self->assertion_list.next = &self->assertion_list;
1924 self->assertion_list.prev = &self->assertion_list;
25+ TestCase_clear_result(self);
2026 }
2127
2228 void TestCase_cleanup(TestCase *self)
@@ -26,8 +32,27 @@
2632 TestAssertion *tmp = list_pop(list);
2733 TestAssertion_delete(tmp);
2834 }
35+ TestCase_clear_result(self);
2936 }
3037
38+static int TestCase_setup(const TestCase *self)
39+{
40+ int ret = 0;
41+ if (self->setup) {
42+ ret = self->setup();
43+ }
44+ return ret;
45+}
46+
47+static int TestCase_teardown(const TestCase *self)
48+{
49+ int ret = 0;
50+ if (self->teardown) {
51+ ret = self->teardown();
52+ }
53+ return ret;
54+}
55+
3156 void TestCase_test(TestCase *self, size_t *nasserts, size_t *nasserts_failed)
3257 {
3358 int failed_flag = 0;
@@ -38,12 +63,21 @@
3863 *nasserts = 0;
3964 *nasserts_failed = 0;
4065 PRINTF1(" Test: %s ... ", self->name);
66+ self->setup_error = TestCase_setup(self);
67+ if (self->setup_error) {
68+ PRINTF1("SETUP ERROR[%d]\n", self->setup_error);
69+ self->result.num_errors_setup++;
70+ return;
71+ }
4172 if (SETJMP(fatal_jmp) == 0) {
4273 self->test();
4374 }
4475 for (pos = LIST_BEGIN(list); pos != LIST_END(list); pos = pos->next) {
76+ self->result.num_asserts++;
77+ self->result.num_asserts_ran++;
4578 (*nasserts)++;
4679 if (!pos->passed_flag) {
80+ self->result.num_asserts_failed++;
4781 (*nasserts_failed)++;
4882 if (!failed_flag) {
4983 failed_flag = 1;
@@ -56,8 +90,19 @@
5690 if (!failed_flag) {
5791 PRINTF0("passed\n");
5892 }
93+ self->teardown_error = TestCase_teardown(self);
94+ if (self->teardown_error) {
95+ PRINTF1(" TEARDOWN ERROR[%d]\n", self->teardown_error);
96+ self->result.num_errors_teardown++;
97+ return;
98+ }
5999 }
60100
101+void TestCase_get_result(TestCase *self, TestCaseResult *result)
102+{
103+ *result = self->result;
104+}
105+
61106 void assert_impl(int passed_flag, const char *expr, const char *file, size_t line, int fatal_flag)
62107 {
63108 TestAssertion *node = TestAssertion_new(passed_flag, expr, file, line);
--- branches/try-vfunc/unittest/TestSuite.h (revision 406)
+++ branches/try-vfunc/unittest/TestSuite.h (revision 407)
@@ -9,14 +9,13 @@
99 TEARDOWN_NG
1010 };
1111
12-size_t TestSuite_init(const TestSuite *self);
13-size_t TestSuite_cleanup(const TestSuite *self);
14-int TestSuite_setup(const TestSuite *self);
15-int TestSuite_teardown(const TestSuite *self);
16-enum TestSuiteErr TestSuite_test(const TestSuite *self, size_t *ncases, size_t *ncases_failed,
12+size_t TestSuite_init(TestSuite *self);
13+size_t TestSuite_cleanup(TestSuite *self);
14+enum TestSuiteErr TestSuite_test(TestSuite *self, size_t *ncases, size_t *ncases_failed,
1715 size_t *nasserts, size_t *nasserts_failed);
18-enum TestSuiteErr TestSuite_test_selected(const TestSuite *self, int case_idx, size_t *ncases, size_t *ncases_failed,
16+enum TestSuiteErr TestSuite_test_selected(TestSuite *self, int case_idx, size_t *ncases, size_t *ncases_failed,
1917 size_t *nasserts, size_t *nasserts_failed);
18+void TestSuite_get_result(TestSuite *self, TestSuiteResult *result);
2019
2120
2221 #endif /* TESTSUITE_H_INCLUDED */
--- branches/try-vfunc/unittest/UnitTest.c (revision 406)
+++ branches/try-vfunc/unittest/UnitTest.c (revision 407)
@@ -2,6 +2,7 @@
22 #include <stdlib.h>
33 #include "UnitTest.h"
44 #include "TestSuite.h"
5+#include "TestCase.h"
56 #include "LibcImpl.h"
67
78 static char input_buf[64];
@@ -11,6 +12,7 @@
1112 static size_t tests_total, tests_ran, tests_failed;
1213 static size_t asserts_total, asserts_ran, asserts_failed;
1314 static size_t setup_failed, teardown_failed;
15+static TestResult result;
1416
1517 static void clear_values(void)
1618 {
@@ -18,28 +20,37 @@
1820 tests_total = tests_ran = tests_failed = 0;
1921 asserts_total = asserts_ran = asserts_failed = 0;
2022 setup_failed = teardown_failed = 0;
23+ memset(&result, 0, sizeof(result));
2124 }
2225
23-static void init(const TestSuite *suites)
26+static void init(TestSuite *suites)
2427 {
2528 size_t i;
2629 clear_values();
2730 for (i = 0; suites[i].name != 0; i++) {
2831 size_t ncases;
32+ TestSuiteResult suite_result;
2933 ncases = TestSuite_init(&suites[i]);
34+ TestSuite_get_result(&suites[i], &suite_result);
3035 tests_total += ncases;
36+ result.num_suites++;
37+ result.suite_result.num_tests += suite_result.num_tests;
3138 }
3239 suites_total += i;
3340 }
3441
35-static void cleanup(const TestSuite *suites)
42+static void cleanup(TestSuite *suites)
3643 {
3744 size_t i;
3845 clear_values();
3946 for (i = 0; suites[i].name != 0; i++) {
4047 size_t ncases;
48+ TestSuiteResult suite_result;
4149 ncases = TestSuite_cleanup(&suites[i]);
50+ TestSuite_get_result(&suites[i], &suite_result);
4251 tests_total += ncases;
52+ result.num_suites++;
53+ result.suite_result.num_tests += suite_result.num_tests;
4354 }
4455 suites_total += i;
4556 }
@@ -56,15 +67,125 @@
5667 PRINTF4("tests %8d %8d %8d %8d\n", tests_total, tests_ran, tests_ran - tests_failed, tests_failed);
5768 PRINTF4("asserts %8d %8d %8d %8d\n", asserts_total, asserts_ran, asserts_ran - asserts_failed, asserts_failed);
5869 PRINTF0("\n");
70+
71+
72+ PRINTF0("Result\n");
73+ PRINTF0("Type Total Ran Passed Failed Error\n");
74+ PRINTF3("suites %8d %8d n/a %8d %8d\n",
75+ result.num_suites, result.num_suites_ran, result.num_suites_failed,
76+ result.suite_result.num_errors_setup + result.suite_result.num_errors_teardown);
77+ PRINTF4("tests %8d %8d %8d %8d %8d\n",
78+ result.suite_result.num_tests,
79+ result.suite_result.num_tests_ran,
80+ result.suite_result.num_tests_ran - result.suite_result.num_tests_failed,
81+ result.suite_result.num_tests_failed,
82+ result.suite_result.case_result.num_errors_setup + result.suite_result.case_result.num_errors_teardown);
83+ PRINTF4("asserts %8d %8d %8d %8d -\n",
84+ result.suite_result.case_result.num_asserts,
85+ result.suite_result.case_result.num_asserts_ran,
86+ result.suite_result.case_result.num_asserts_ran - result.suite_result.case_result.num_asserts_failed,
87+ result.suite_result.case_result.num_asserts_failed);
88+ PRINTF0("\n");
89+
90+ if (result.suite_result.num_errors_setup + result.suite_result.num_errors_teardown > 0) {
91+ }
92+ if (result.num_suites_failed) {
93+ }
5994 }
6095
61-static void run_all(const TestSuite *suites)
96+static void get_result(TestSuite *suites)
6297 {
6398 size_t i;
99+ size_t j;
64100 for (i = 0; suites[i].name != 0; i++) {
101+ TestSuite *suite = &suites[i];
102+ PRINTF1("Suite: %s\n", suite->name);
103+ if (suite->setup_error) {
104+ }
105+ if (suite->teardown_error) {
106+ }
107+ for (j = 0; suite->test_cases[j].name != 0; j++) {
108+ TestCase *tc = &suite->test_cases[j];
109+ if (tc->setup_error || tc->teardown_error) {
110+ PRINTF0("E");
111+ } else if (tc->result.num_asserts_failed == 0) {
112+ PRINTF0(".");
113+ } else {
114+ PRINTF0("F");
115+ }
116+ }
117+ PRINTF0("\n");
118+ if (suite->result.num_tests_failed == 0) {
119+ PRINTF1("OK (%d Tests)\n", suite->result.num_tests_ran);
120+ } else {
121+ PRINTF2("NG (%d Tests, %d Failures)\n", suite->result.num_tests_ran, suite->result.num_tests_failed);
122+ for (j = 0; suite->test_cases[j].name != 0; j++) {
123+ TestCase *tc = &suite->test_cases[j];
124+ TestAssertion *pos;
125+ TestAssertion *list = &tc->assertion_list;
126+ int name_printed = 0;
127+ for (pos = LIST_BEGIN(list); pos != LIST_END(list); pos = pos->next) {
128+ if (!pos->passed_flag) {
129+ if (!name_printed) {
130+ PRINTF1("\nTest: %s\n", tc->name);
131+ name_printed = 1;
132+ }
133+ PRINTF3(" %s(%d) %s\n", pos->file, pos->line, pos->expr);
134+ }
135+ }
136+ }
137+ }
138+ PRINTF0("\n");
139+
140+/* PRINTF1("Test: %s\n", tc->name);*/
141+/* for (pos = LIST_BEGIN(list); pos != LIST_END(list); pos = pos->next) {*/
142+/* if (!pos->passed_flag) {*/
143+/* PRINTF3(" %s(%d) %s\n", pos->file, pos->line, pos->expr);*/
144+/* }*/
145+/* }*/
146+/* PRINTF0("\n");*/
147+/* if (tc->result.num_asserts_failed == 0) {*/
148+/* PRINTF1("OK (%d Tests)\n", tc->result.num_asserts_ran);*/
149+/* } else {*/
150+/* PRINTF2("NG (%d Failures / %d Tests)\n", tc->result.num_asserts_failed, tc->result.num_asserts_ran);*/
151+/* for (pos = LIST_BEGIN(list); pos != LIST_END(list); pos = pos->next) {*/
152+/* if (!pos->passed_flag) {*/
153+/* PRINTF3(" %s(%d) %s\n", pos->file, pos->line, pos->expr);*/
154+/* }*/
155+/* }*/
156+/* }*/
157+/* PRINTF0("\n");*/
158+ }
159+}
160+
161+static void add_result(const TestSuiteResult *s_result)
162+{
163+ result.suite_result.num_tests_ran += s_result->num_tests_ran;
164+ result.suite_result.num_tests_failed += s_result->num_tests_failed;
165+ result.suite_result.num_errors_setup += s_result->num_errors_setup;
166+ result.suite_result.num_errors_teardown += s_result->num_errors_teardown;
167+ result.suite_result.case_result.num_asserts += s_result->case_result.num_asserts;
168+ result.suite_result.case_result.num_asserts_ran += s_result->case_result.num_asserts_ran;
169+ result.suite_result.case_result.num_asserts_failed += s_result->case_result.num_asserts_failed;
170+ result.suite_result.case_result.num_errors_setup += s_result->case_result.num_errors_setup;
171+ result.suite_result.case_result.num_errors_teardown += s_result->case_result.num_errors_teardown;
172+ result.num_suites_ran++;
173+ if (s_result->num_tests_failed > 0) {
174+ result.num_suites_failed++;
175+ }
176+}
177+
178+static void run_all(TestSuite *suites)
179+{
180+ size_t i;
181+ for (i = 0; suites[i].name != 0; i++) {
65182 size_t nc, ncf, na, naf;
66183 enum TestSuiteErr ret;
184+ TestSuiteResult suite_result;
67185 ret = TestSuite_test(&suites[i], &nc, &ncf, &na, &naf);
186+ TestSuite_get_result(&suites[i], &suite_result);
187+ add_result(&suite_result);
188+
68189 asserts_total += na;
69190 asserts_ran += na;
70191 asserts_failed += naf;
@@ -81,14 +202,19 @@
81202 }
82203 suites_ran = i;
83204 print_result();
205+ get_result(suites);
84206 cleanup(suites);
85207 }
86208
87-static void run_suite_selected(const TestSuite *suites, int suite_idx, int case_idx)
209+static void run_suite_selected(TestSuite *suites, int suite_idx, int case_idx)
88210 {
89211 size_t nc, ncf, na, naf;
90212 enum TestSuiteErr ret;
213+ TestSuiteResult suite_result;
91214 ret = TestSuite_test_selected(&suites[suite_idx], case_idx, &nc, &ncf, &na, &naf);
215+ TestSuite_get_result(&suites[suite_idx], &suite_result);
216+ add_result(&suite_result);
217+
92218 asserts_total = na;
93219 asserts_ran = na;
94220 asserts_failed = naf;
@@ -104,14 +230,19 @@
104230 }
105231 suites_ran = 1;
106232 print_result();
233+ get_result(suites);
107234 cleanup(suites);
108235 }
109236
110-static void run_suite(const TestSuite *suites, int suite_idx)
237+static void run_suite(TestSuite *suites, int suite_idx)
111238 {
112239 size_t nc, ncf, na, naf;
113240 enum TestSuiteErr ret;
241+ TestSuiteResult suite_result;
114242 ret = TestSuite_test(&suites[suite_idx], &nc, &ncf, &na, &naf);
243+ TestSuite_get_result(&suites[suite_idx], &suite_result);
244+ add_result(&suite_result);
245+
115246 asserts_total = na;
116247 asserts_ran = na;
117248 asserts_failed = naf;
@@ -127,6 +258,7 @@
127258 }
128259 suites_ran = 1;
129260 print_result();
261+ get_result(suites);
130262 cleanup(suites);
131263 }
132264
@@ -180,11 +312,11 @@
180312 return n - 1;
181313 }
182314
183-static void select_test(const TestSuite *suites, int suite_idx)
315+static void select_test(TestSuite *suites, int suite_idx)
184316 {
185317 int idx;
186318 char *p;
187- const TestSuite *suite = &suites[suite_idx];
319+ TestSuite *suite = &suites[suite_idx];
188320 PRINTF0("Enter Test's Number or Name : ");
189321 FGETS(input_buf, sizeof input_buf, stdin);
190322 p = strpbrk(input_buf, "\r\n");
@@ -231,11 +363,11 @@
231363 return n - 1;
232364 }
233365
234-static void select_suite(const TestSuite *suites)
366+static void select_suite(TestSuite *suites)
235367 {
236368 int idx;
237369 char *p;
238- const TestSuite *selected_suite;
370+ TestSuite *selected_suite;
239371 PRINTF0("Enter Suite's Number or Name : ");
240372 FGETS(input_buf, sizeof input_buf, stdin);
241373 p = strpbrk(input_buf, "\r\n");
@@ -286,7 +418,7 @@
286418 }
287419 }
288420
289-void unittest_run_interactive(const TestSuite *suites)
421+void unittest_run_interactive(TestSuite *suites)
290422 {
291423 init(suites);
292424 if (SETJMP(quit_jmp)) {
@@ -323,7 +455,7 @@
323455 }
324456
325457
326-void unittest_run_all(const TestSuite *suites)
458+void unittest_run_all(TestSuite *suites)
327459 {
328460 PRINTF0("****************** Unit Test ******************\n");
329461 PRINTF0("\n");
--- branches/try-vfunc/unittest/TestCase.h (revision 406)
+++ branches/try-vfunc/unittest/TestCase.h (revision 407)
@@ -3,10 +3,14 @@
33
44 #include "UnitTest.h"
55
6+#define LIST_BEGIN(list) (list)->next
7+#define LIST_END(list) (list)
68
9+
710 void TestCase_init(TestCase *self);
811 void TestCase_cleanup(TestCase *self);
912 void TestCase_test(TestCase *self, size_t *nasserts, size_t *nasserts_failed);
13+void TestCase_get_result(TestCase *self, TestCaseResult *result);
1014
1115
1216 #endif /* TESTCASE_H_INCLUDED */
--- branches/try-vfunc/unittest/UnitTest.h (revision 406)
+++ branches/try-vfunc/unittest/UnitTest.h (revision 407)
@@ -19,18 +19,46 @@
1919 struct TestAssertion *prev;
2020 } TestAssertion;
2121
22+typedef struct {
23+ size_t num_asserts;
24+ size_t num_asserts_ran;
25+ size_t num_asserts_failed;
26+ size_t num_errors_setup;
27+ size_t num_errors_teardown;
28+} TestCaseResult;
2229
30+typedef struct {
31+ size_t num_tests;
32+ size_t num_tests_ran;
33+ size_t num_tests_failed;
34+ size_t num_errors_setup;
35+ size_t num_errors_teardown;
36+ TestCaseResult case_result;
37+} TestSuiteResult;
38+
39+typedef struct {
40+ size_t num_suites;
41+ size_t num_suites_ran;
42+ size_t num_suites_failed;
43+ TestSuiteResult suite_result;
44+} TestResult;
45+
2346 /*
2447 * public
2548 */
2649 #define TEST_SUITE_NULL {0, 0, 0, 0}
27-#define TEST_CASE_NULL {0, 0}
50+#define TEST_CASE_NULL {0, 0, 0, 0}
2851
2952 typedef struct {
3053 /* public */
3154 const char *name;
3255 void (*test)(void);
56+ int (*setup)(void);
57+ int (*teardown)(void);
3358 /* private */
59+ int setup_error;
60+ int teardown_error;
61+ TestCaseResult result;
3462 TestAssertion assertion_list;
3563 } TestCase;
3664
@@ -37,9 +65,13 @@
3765 typedef struct {
3866 /* public */
3967 const char *name;
68+ TestCase *test_cases;
4069 int (*setup)(void);
4170 int (*teardown)(void);
42- TestCase *test_cases;
71+ /* private */
72+ int setup_error;
73+ int teardown_error;
74+ TestSuiteResult result;
4375 } TestSuite;
4476
4577
@@ -46,8 +78,8 @@
4678 /*
4779 * Unit Test API
4880 */
49-void unittest_run_interactive(const TestSuite *suites);
50-void unittest_run_all(const TestSuite *suites);
81+void unittest_run_interactive(TestSuite *suites);
82+void unittest_run_all(TestSuite *suites);
5183
5284
5385 /*
Show on old repository browser