tester_data_func_t post_teardown_func;
gdouble start_time;
gdouble end_time;
+ tester_destroy_func_t destroy;
+ void *user_data;
};
static GMainLoop *main_loop;
{
struct test_case *test = data;
+ if (test->destroy)
+ test->destroy(test->user_data);
+
g_free(test->name);
g_free(test);
}
}
void tester_add_full(const char *name, const void *test_data,
- tester_data_func_t pre_setup_func,
- tester_data_func_t setup_func,
- tester_data_func_t test_func,
- tester_data_func_t teardown_func,
- tester_data_func_t post_teardown_func)
+ tester_data_func_t pre_setup_func,
+ tester_data_func_t setup_func,
+ tester_data_func_t test_func,
+ tester_data_func_t teardown_func,
+ tester_data_func_t post_teardown_func,
+ void *user_data, tester_destroy_func_t destroy)
{
struct test_case *test;
else
test->post_teardown_func = default_post_teardown;
+ test->destroy = destroy;
+ test->user_data = user_data;
+
test_list = g_list_append(test_list, test);
}
tester_data_func_t teardown_func)
{
tester_add_full(name, test_data, NULL, setup_func, test_func,
- teardown_func, NULL);
+ teardown_func, NULL, NULL, NULL);
+}
+
+void *tester_get_data(void)
+{
+ struct test_case *test;
+
+ if (!test_current)
+ return NULL;
+
+ test = test_current->data;
+
+ return test->user_data;
}
static void tester_summarize(void)
void tester_warn(const char *format, ...)
__attribute__((format(printf, 1, 2)));
+typedef void (*tester_destroy_func_t)(void *user_data);
typedef void (*tester_data_func_t)(const void *test_data);
void tester_add_full(const char *name, const void *test_data,
- tester_data_func_t pre_setup_func,
- tester_data_func_t setup_func,
- tester_data_func_t test_func,
- tester_data_func_t teardown_func,
- tester_data_func_t post_teardown_func);
+ tester_data_func_t pre_setup_func,
+ tester_data_func_t setup_func,
+ tester_data_func_t test_func,
+ tester_data_func_t teardown_func,
+ tester_data_func_t post_teardown_func,
+ void *user_data, tester_destroy_func_t destroy);
+
void tester_add(const char *name, const void *test_data,
tester_data_func_t setup_func,
tester_data_func_t test_func,
tester_data_func_t teardown_func);
+void *tester_get_data(void);
+
void tester_pre_setup_complete(void);
void tester_pre_setup_failed(void);