#include "xml_reporter.h" #include #include #include #include static indent(TestReporter *reporter); static void xml_reporter_start(TestReporter *reporter, const char *name); static void xml_reporter_finish(TestReporter *reporter, const char *name); static void xml_show_fail(TestReporter *reporter, const char *file, int line, const char *message, va_list arguments); static void xml_show_incomplete(TestReporter *reporter, const char *name); TestReporter *create_xml_reporter() { TestReporter *reporter = create_reporter(); reporter->start_suite = &xml_reporter_start; reporter->start_test = &xml_reporter_start; reporter->show_fail = &xml_show_fail; reporter->show_incomplete = &xml_show_incomplete; reporter->finish_test = &xml_reporter_finish; reporter->finish_suite = &xml_reporter_finish; return reporter; } static indent(TestReporter *reporter) { int depth = get_breadcrumb_depth((Breadcrumb *)reporter->breadcrumb); while (depth-- > 0) { printf("\t"); } } static void xml_reporter_start(TestReporter *reporter, const char *name) { if (get_breadcrumb_depth((Breadcrumb *)reporter->breadcrumb) == 0) { printf("\n"); } indent(reporter); printf("\n", name); reporter_start(reporter, name); } static void xml_reporter_finish(TestReporter *reporter, const char *name) { reporter_finish(reporter, name); indent(reporter); printf("\n"); } static void xml_show_fail(TestReporter *reporter, const char *file, int line, const char *message, va_list arguments) { indent(reporter); printf("\n"); indent(reporter); printf("\t\n"); indent(reporter); printf("\t\n", file, line); indent(reporter); printf("\n"); } static void xml_show_incomplete(TestReporter *reporter, const char *name) { indent(reporter); printf("\n"); indent(reporter); printf("\t\n"); indent(reporter); printf("\n"); }