Skip to content

Commit

Permalink
tests: add macro for printing test parameter
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
guludo authored and lucasdemarchi committed May 16, 2016
1 parent 26959f1 commit fe4aaaa
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/AP_gtest.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
*/
#include <gtest/gtest.h>


#define AP_GTEST_PRINTATBLE_PARAM_MEMBER(class_name_, printable_member_) \
::std::ostream& operator<<(::std::ostream& os, const class_name_& param) \
{ \
return os << param.printable_member_; \
}

#define AP_GTEST_MAIN() \
int main(int argc, char *argv[]) \
{ \
Expand Down

0 comments on commit fe4aaaa

Please sign in to comment.