FRIEND_TEST in Google Test - possible circular dependency?
Posted
by
Mihaela
on Stack Overflow
See other posts from Stack Overflow
or by Mihaela
Published on 2012-11-01T04:45:52Z
Indexed on
2012/11/01
5:00 UTC
Read the original article
Hit count: 212
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 ?
© Stack Overflow or respective owner