forked from Sol128/hash
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting.c
More file actions
29 lines (25 loc) · 739 Bytes
/
testing.c
File metadata and controls
29 lines (25 loc) · 739 Bytes
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
#include "testing.h"
#include <stdio.h>
#include <unistd.h> // isatty
#define ANSI_COLOR_LGH_RED "\x1b[1m\x1b[31m"
#define ANSI_COLOR_LGH_GREEN "\x1b[1m\x1b[32m"
#define ANSI_COLOR_RESET "\x1b[0m"
static int _failure_count;
void real_print_test(const char* mensaje, bool ok,
const char* file, int line, const char* failed_expr) {
if (ok) {
printf("%s... ", mensaje);
if (isatty(1)==1) printf(ANSI_COLOR_LGH_GREEN);
printf("OK\n");
} else {
printf("%s: ",mensaje);
if (isatty(1)==1) printf(ANSI_COLOR_LGH_RED);
printf("ERROR\n" "%s:%d: %s\n", file, line, failed_expr);
}
if (isatty(1)==1) printf(ANSI_COLOR_RESET);
fflush(stdout);
_failure_count += !ok;
}
int failure_count() {
return _failure_count;
}