-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.c
56 lines (46 loc) · 1.05 KB
/
test.c
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "os.h"
static int assertionCount = 0;
static int errorCount = 0;
// Should return something
static void
test_funcionality()
{
const char *os = operating_system();
printf(" Your operating system is: %s\n\n", os);
if (strlen(os) <= 0)
{
errorCount++;
fprintf(stderr, "\033[31m");
fprintf(stderr," (✖) Error, should display the operating system.");
fprintf(stderr, "\n\033[0m");
fprintf(stderr, "\n");
} else
{
printf("\033[32m (✓) Test passed\033[0m\n");
}
assertionCount++;
}
int
main()
{
// If it has an output it should work :(
test_funcionality();
// Log total errors.
printf("\n");
if (errorCount != 0) {
printf("\033[31m");
printf("(✖) Failed on %d of %d assertions", errorCount, assertionCount);
printf("\033[0m");
printf("\n");
exit(EXIT_FAILURE);
}
// Or, log total successes.
printf("\033[32m");
printf("(✓) Passed %d assertions without errors", assertionCount);
printf("\033[0m");
printf("\n");
return 0;
}