summaryrefslogtreecommitdiff
path: root/tests/clar/print.h
blob: 5c8857c51db6ec4dbfcf32c0ed4942770d18c2d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97

static void clar_print_cl_init(int test_count, int suite_count, const char *suite_names)
{
	(void)test_count;
	printf("Loaded %d suites: %s\n", (int)suite_count, suite_names);
	printf("Started (test status codes: OK='.' FAILURE='F' SKIPPED='S')\n");
}

static void clar_print_cl_shutdown(int test_count, int suite_count, int error_count)
{
	(void)test_count;
	(void)suite_count;
	(void)error_count;

	printf("\n\n");
	clar_report_all();
}

static void clar_print_cl_error(int num, const struct clar_report *report, const struct clar_error *error)
{
	printf("  %d) Failure:\n", num);

	printf("%s::%s [%s:%"PRIuZ"]\n",
		report->suite,
		report->test,
		error->file,
		error->line_number);

	printf("  %s\n", error->error_msg);

	if (error->description != NULL)
		printf("  %s\n", error->description);

	printf("\n");
	fflush(stdout);
}

static void clar_print_cl_ontest(const char *test_name, int test_number, enum cl_test_status status)
{
	(void)test_name;
	(void)test_number;

	switch(status) {
	case CL_TEST_OK: printf("."); break;
	case CL_TEST_FAILURE: printf("F"); break;
	case CL_TEST_SKIP: printf("S"); break;
	case CL_TEST_NOTRUN: printf("N"); break;
	}

	fflush(stdout);
}

static void clar_print_cl_onsuite(const char *suite_name, int suite_index)
{
	if (_clar.report_suite_names)
		printf("\n%s", suite_name);

	(void)suite_index;
}

static void clar_print_cl_onabort(const char *fmt, va_list arg)
{
	vfprintf(stderr, fmt, arg);
}

static void clar_print_init(int test_count, int suite_count, const char *suite_names)
{
	clar_print_cl_init(test_count, suite_count, suite_names);
}

static void clar_print_shutdown(int test_count, int suite_count, int error_count)
{
	clar_print_cl_shutdown(test_count, suite_count, error_count);
}

static void clar_print_error(int num, const struct clar_report *report, const struct clar_error *error)
{
	clar_print_cl_error(num, report, error);
}

static void clar_print_ontest(const char *test_name, int test_number, enum cl_test_status status)
{
	clar_print_cl_ontest(test_name, test_number, status);
}

static void clar_print_onsuite(const char *suite_name, int suite_index)
{
	clar_print_cl_onsuite(suite_name, suite_index);
}

static void clar_print_onabort(const char *msg, ...)
{
	va_list argp;
	va_start(argp, msg);
	clar_print_cl_onabort(msg, argp);
	va_end(argp);
}