FRIEND_TEST in Google Test - possible circular dependency?
- by Mihaela
I am trying to figure out how FRIEND_TEST works in Google Tests.
http://code.google.com/p/googletest/wiki/AdvancedGuide#Private_Class_Members
I am looking at the following item, trying to implement it in my code:
// foo.h
#include "gtest/gtest_prod.h"
// Defines FRIEND_TEST.
class Foo {
...
private:
FRIEND_TEST(FooTest, BarReturnsZeroOnNull);
int Bar(void* x);
};
// foo_test.cc
...
TEST(FooTest, BarReturnsZeroOnNull) {
Foo foo;
EXPECT_EQ(0, foo.Bar(NULL));
// Uses Foo's private member Bar().
}
In the code above, the piece that I can't see, is that foo_test.cc must include foo.h, in order to have access to Foo and Bar(). [Perhaps it works differently for Google ? in my code, I must include it]
That will result in circular dependency...
Am I missing something ?