GoogleTest PrintTo not getting called for a class

不想你离开。 提交于 2019-12-01 16:00:10

Problem is that you break the One Definition Rule (ODR) of one of the gtest function (probably template ::testing::PrintToString<MyNamespace::CPunto2D>(const MyNamespace::CPunto2D&)).

In one TU where you use ASSERT_EQ, void PrintTo(const MyNamespace::CPunto2D& pto, ::std::ostream* os) is not declared, so ::testing::PrintToString<MyNamespace::CPunto2D> 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<MyNamespace::CPunto2D> 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).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!