I\'m having a rather strange problem telling googletest to print a certain class the way I want using PrintTo.
The class is a very simple 2D point, it is in a namespace
Problem is that you break the One Definition Rule (ODR) of one of the gtest function
(probably template ::testing::PrintToString
).
In one TU where you use ASSERT_EQ
, void PrintTo(const MyNamespace::CPunto2D& pto, ::std::ostream* os)
is not declared,
so ::testing::PrintToString
uses the default printer.
In an other TU where you use ASSERT_EQ
, you have void PrintTo(const MyNamespace::CPunto2D& pto, ::std::ostream* os)
declared (and potentially defined), so ::testing::PrintToString
uses a version using your custom PrintTo
.
That is a second different definition of the same function.
You have to make sure that each TU which uses ASSERT_EQ
see the declaration of your custom PrintTo
(as in CPunto2D
's header).