blob: 2153a70cdfce7e881cfdbe2711f152ab0b69c4ab (
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
|
/* keep this include at the very top of the file */
#include "simple-test.h"
/* any global variables, functions, other inclusions, etc.
* should be declared here */
#include "header_with_stuff_to_be_tested.h"
BEGIN_TEST
/* the string is a description of the test being run */
TEST("check add()'s return value")
{
int var1=2;
int var2=4;
/* add is a function included from our hypothetical
* header_with_stuff_to_be_tested */
EXPECT_INT(var1+var2, add(var1, var2));
}
TEST("compare two arrays of strings")
{
int i;
char array1[][10] = {
"str1",
"str2",
"str3",
};
char array2[][10] = {
"str1",
"str2",
/* matching will fail here */
"different",
};
for(i = 0; i < sizeof(array1) / sizeof(char[10]); i++) {
/* ECHO can be used to print (with pretty
* formatting) the current state within the
* test */
ECHO("checking strs at i == %i", i);
EXPECT_STR_EQ(array1[i], array2[i]);
}
}
END_TEST
|