Toggle navigation
Documentation
The friendly Operating System for the Internet of Things
Loading...
Searching...
No Matches
cppunit_fff.hpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2021 Jens Wetterich <jens@wetterich-net.de>
3
*
4
* This file is subject to the terms and conditions of the GNU Lesser
5
* General Public License v2.1. See the file LICENSE in the top level
6
* directory for more details.
7
*/
16
#ifndef CPPUNIT_FFF_H
17
#define CPPUNIT_FFF_H
18
#if __cplusplus >= 201103L || defined(DOXYGEN)
26
#define EXPECT_FFF_CALL_COUNT(name, count) \
27
if (name##_fake.call_count != (count)) { \
28
fail(); \
29
printf("Expected %d calls to " #name ", but got %d\n", count, name##_fake.call_count); \
30
}
31
33
#define EXPECT_FFF_CALL_1(name, val1) \
34
if (name##_fake.arg0_val != (val1)) { \
35
fail(); \
36
puts("Argument 0 to mock " #name " doesn't match the expectation.\n"); \
37
}
38
#define EXPECT_FFF_CALL_2(name, val1, val2) \
39
if (name##_fake.arg0_val != (val1)) { \
40
fail(); \
41
puts("Argument 1 to mock " #name " doesn't match the expectation.\n"); \
42
} \
43
if (name##_fake.arg1_val != (val2)) { \
44
fail(); \
45
puts("Argument 2 to mock " #name " doesn't match the expectation.\n"); \
46
}
47
#define EXPECT_FFF_CALL_3(name, val1, val2, val3) \
48
if (name##_fake.arg0_val != (val1)) { \
49
fail(); \
50
puts("Argument 1 to mock " #name " doesn't match the expectation.\n"); \
51
} \
52
if (name##_fake.arg1_val != (val2)) { \
53
fail(); \
54
puts("Argument 2 to mock " #name " doesn't match the expectation.\n"); \
55
} \
56
if (name##_fake.arg2_val != (val3)) { \
57
fail(); \
58
puts("Argument 3 to mock " #name " doesn't match the expectation.\n"); \
59
}
60
#define EXPECT_FFF_CALL_4(name, val1, val2, val3, val4) \
61
if (name##_fake.arg0_val != (val1)) { \
62
fail(); \
63
puts("Argument 1 to mock " #name " doesn't match the expectation.\n"); \
64
} \
65
if (name##_fake.arg1_val != (val2)) { \
66
fail(); \
67
puts("Argument 2 to mock " #name " doesn't match the expectation.\n"); \
68
} \
69
if (name##_fake.arg2_val != (val3)) { \
70
fail(); \
71
puts("Argument 3 to mock " #name " doesn't match the expectation.\n"); \
72
} \
73
if (name##_fake.arg3_val != (val4)) { \
74
fail(); \
75
puts("Argument 4 to mock " #name " doesn't match the expectation.\n"); \
76
}
77
#define EXPECT_FFF_CALL_5(name, val1, val2, val3, val4, val5) \
78
if (name##_fake.arg0_val != (val1)) { \
79
fail(); \
80
puts("Argument 1 to mock " #name " doesn't match the expectation.\n"); \
81
} \
82
if (name##_fake.arg1_val != (val2)) { \
83
fail(); \
84
puts("Argument 2 to mock " #name " doesn't match the expectation.\n"); \
85
} \
86
if (name##_fake.arg2_val != (val3)) { \
87
fail(); \
88
puts("Argument 3 to mock " #name " doesn't match the expectation.\n"); \
89
} \
90
if (name##_fake.arg3_val != (val4)) { \
91
fail(); \
92
puts("Argument 4 to mock " #name " doesn't match the expectation.\n"); \
93
} \
94
if (name##_fake.arg4_val != (val5)) { \
95
fail(); \
96
puts("Argument 5 to mock " #name " doesn't match the expectation.\n"); \
97
}
98
#define EXPECT_FFF_CALL_6(name, val1, val2, val3, val4, val5, val6) \
99
if (name##_fake.arg0_val != (val1)) { \
100
fail(); \
101
puts("Argument 1 to mock " #name " doesn't match the expectation.\n"); \
102
} \
103
if (name##_fake.arg1_val != (val2)) { \
104
fail(); \
105
puts("Argument 2 to mock " #name " doesn't match the expectation.\n"); \
106
} \
107
if (name##_fake.arg2_val != (val3)) { \
108
fail(); \
109
puts("Argument 3 to mock " #name " doesn't match the expectation.\n"); \
110
} \
111
if (name##_fake.arg3_val != (val4)) { \
112
fail(); \
113
puts("Argument 4 to mock " #name " doesn't match the expectation.\n"); \
114
} \
115
if (name##_fake.arg5_val != (val6)) { \
116
fail(); \
117
puts("Argument 6 to mock " #name " doesn't match the expectation.\n"); \
118
}
119
#define GET_FFF_MACRO(_1, _2, _3, _4, _5, _6, NAME, ...) NAME
128
#define EXPECT_FFF_CALL_PARAMS(mock, ...) \
129
GET_FFF_MACRO(__VA_ARGS__, EXPECT_FFF_CALL_6, EXPECT_FFF_CALL_5, EXPECT_FFF_CALL_4, \
130
EXPECT_FFF_CALL_3, EXPECT_FFF_CALL_2, EXPECT_FFF_CALL_1) \
131
(mock, __VA_ARGS__)
132
#else
133
#error This library needs C++11 and newer
134
#endif
135
#endif
Generated on Sat Nov 23 2024 01:58:08 by
1.9.8