Fixed initialization order of test framework.

This commit is contained in:
Davi de Castro Reis 2012-08-21 18:07:46 +02:00
parent 4f3c9003d5
commit d59aaa88c4
2 changed files with 14 additions and 7 deletions

View File

@ -2,13 +2,19 @@
#include "test.h"
Suite* global_suite = suite_create("cxxmph_test_suite");
TCase* global_tc_core = tcase_create("Core");
Suite* global_suite() {
static Suite* gs = suite_create("cxxmph_test_suite");
return gs;
}
TCase* global_tc_core() {
static TCase* gtc = tcase_create("Core");
return gtc;
}
int main (void) {
suite_add_tcase(global_suite, global_tc_core);
suite_add_tcase(global_suite(), global_tc_core());
int number_failed;
SRunner *sr = srunner_create (global_suite);
SRunner *sr = srunner_create (global_suite());
srunner_run_all (sr, CK_NORMAL);
number_failed = srunner_ntests_failed (sr);
srunner_free (sr);

View File

@ -9,9 +9,10 @@
// included last.
#include <check.h>
#include <stdio.h>
extern Suite* global_suite;
extern TCase* global_tc_core;
Suite* global_suite();
TCase* global_tc_core();
// Creates a new test case calling boolean_function. Name must be a valid,
// unique c identifier when prefixed with tc_.
@ -24,7 +25,7 @@ extern TCase* global_tc_core;
struct TestCase {
TestCase(void (*f)(int)) {
tcase_add_test(global_tc_core, f);
tcase_add_test(global_tc_core(), f);
}
};