An Ky
unread,Jul 18, 2011, 12:24:00 PM7/18/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google C++ Mocking Framework
Hi there,
having the code snippet below I get the following compiler error:
"error: no match for 'operator<< in '* os << val'" from gtest-
internal.h line 97 which results from the EXPECT_EQ in the test case
at the end. (where val is of type aNamespace::LayoutIndices)
It works if I define operator<< globally. Using PrintTo does not work
at all.
My understanding of the gtest documentation and the C++ NDL rules is
that either method should be found if it is defined in the same
namespace as the typedef. Furthermore PrintTo should be preferred by
gtest.
I'm asking this here and not in the gtest group, because I'm currently
trying to switch from gtest/mockpp to gtest/gmock and in the old
setup, the above code just worked.
I am using tdm-gcc 4.4.1 with gtest/gmock 1.6, migrating from gtest
1.5 and mockpp (dunno which version)
#include <iostream>
#include <gtest/gtest.h>
#include <vector>
using namespace std;
namespace aNamespace {
typedef std::vector<int> LayoutIndices;
std::ostream& operator<<(std::ostream& o, const LayoutIndices& li)
{
o << "no";
return o;
}
}
// void PrintTo(const aNamespace::LayoutIndices& li, std::ostream* o)
// {
// *o << "hello";
// }
//}
int main(int argc, char* argv[])
{
::testing::InitGoogleTest(&argc, argv);
int testStatus = RUN_ALL_TESTS();
return testStatus;
}
TEST(Global, equalLayout)
{
aNamespace::LayoutIndices a, b;
EXPECT_EQ(a, b);
}