-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patht_Testing.ino
99 lines (98 loc) · 1.75 KB
/
t_Testing.ino
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
98
99
/**
* This file contains testing-functions.
* It contains functions to compare
* certain datatypes and then
* display the result of the comparison.
*/
/*
* Only compile this file
* if a test is being run.
*/
#if (TEST)
/*
* Generate a file specific warning during compilation,
* so that it is possible to identify
* which files are being compiled.
*/
#warning Testing
/*
* The text which will be printed
* when a test succeeds.
*/
#define TEXT_OK "V"
/*
* The text which will be printed
* when a test fails.
*/
#define TEXT_NOT_OK "X"
/**
* Compare the given boolean to false.
* @param actual the boolean to be compared to false.
*/
void compareFalse(boolean actual)
{
compareUnsignedNumbers(false, actual);
}
/**
* Compare the given boolean to true.
* @param actual the boolean to be compared to true.
*/
void compareTrue(boolean actual)
{
compareUnsignedNumbers(true, actual);
}
/**
* Compare 2 numbers.
* @param expected the expected number.
* @param actual the actual number.
*/
void compareUnsignedNumbers(const uint64_t expected, const uint64_t actual)
{
if (expected == actual)
{
ok();
}
else
{
notOk();
}
}
/**
* Compare 2 strings.
* @param expected the expected string.
* @param actual the actual string.
*/
void compareStrings(const char* expected, const char* actual)
{
if ((strlen(expected) == strlen(actual)) && (!strcmp(expected, actual)))
{
ok();
}
else
{
notOk();
}
}
/**
* Called when a test succeeds.
*/
void ok()
{
printString(TEXT_OK);
}
/**
* Called when a test fails.
*/
void notOk()
{
printString(TEXT_NOT_OK);
}
/**
* Each test-file will only use the setup-function.
* So an empty loop-function is just here
* so that it doesn't have to be placed in every test-file.
*/
void loop()
{
}
#endif