Skip to content
Snippets Groups Projects
  • Gustavo Jose de Sousa's avatar
    fe4aaaac
    tests: add macro for printing test parameter · fe4aaaac
    Gustavo Jose de Sousa authored
    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.
    fe4aaaac
    History
    tests: add macro for printing test parameter
    Gustavo Jose de Sousa authored
    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.
AP_gtest.h 423 B
/*
 * Utility header for unit tests with gtest.
 */
#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[]) \
{ \
    ::testing::InitGoogleTest(&argc, argv); \
    return RUN_ALL_TESTS(); \
}