From fe4aaaac95942d0b67f0ef31dac7b9ff364de7fc Mon Sep 17 00:00:00 2001
From: Gustavo Jose de Sousa <gustavo.sousa@intel.com>
Date: Mon, 11 Apr 2016 11:00:13 -0300
Subject: [PATCH] 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.
---
 tests/AP_gtest.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tests/AP_gtest.h b/tests/AP_gtest.h
index ee9eceb2d6..c7d0734783 100644
--- a/tests/AP_gtest.h
+++ b/tests/AP_gtest.h
@@ -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[]) \
 { \
-- 
GitLab