Skip to content

Commit fe4aaaa

Browse files
guludolucasdemarchi
authored andcommitted
tests: add macro for printing test parameter
Google Test allows to instantiate tests for a list of different values, which are called parameters. A common use of that feature in Ardupilot will be that a parameter will be represented by an object that will have the value to be tested and information about that value. That information will basically map the expected behavior of tests on the value stored by the parameter. The macro added in this patch allows to easily print the value of a failed test's parameter.
1 parent 26959f1 commit fe4aaaa

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tests/AP_gtest.h

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
*/
44
#include <gtest/gtest.h>
55

6+
7+
#define AP_GTEST_PRINTATBLE_PARAM_MEMBER(class_name_, printable_member_) \
8+
::std::ostream& operator<<(::std::ostream& os, const class_name_& param) \
9+
{ \
10+
return os << param.printable_member_; \
11+
}
12+
613
#define AP_GTEST_MAIN() \
714
int main(int argc, char *argv[]) \
815
{ \

0 commit comments

Comments
 (0)