Fixed initialization order of test framework.

This commit is contained in:
Davi de Castro Reis 2012-08-21 18:07:46 +02:00 committed by Davi Reis
parent e4d6e18de0
commit 4238530db6
2 changed files with 14 additions and 7 deletions

View File

@ -2,13 +2,19 @@
#include "test.h" #include "test.h"
Suite* global_suite = suite_create("cxxmph_test_suite"); Suite* global_suite() {
TCase* global_tc_core = tcase_create("Core"); 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) { int main (void) {
suite_add_tcase(global_suite, global_tc_core); suite_add_tcase(global_suite(), global_tc_core());
int number_failed; int number_failed;
SRunner *sr = srunner_create (global_suite); SRunner *sr = srunner_create (global_suite());
srunner_run_all (sr, CK_NORMAL); srunner_run_all (sr, CK_NORMAL);
number_failed = srunner_ntests_failed (sr); number_failed = srunner_ntests_failed (sr);
srunner_free (sr); srunner_free (sr);

View File

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