-1

I have the following constructs in my test:

class FooType {};
class OtherFooType {};

using FooTypes =
    ::testing::Types<FooType, OtherFooType>;

TYPED_TEST_CASE(FooTest, FooTypes);

template <typename FooClassType>
class FooTest : public testing::Test {

TYPED_TEST(FooTest, SimpleTest) {

I also have classes:

class Foo {

class OtherFoo : public Foo {

I would like to make Foo friend of FooTest.

I tried:

  template <typename FooTypes>
  friend class FooTest;

in the Foo class declaration, but the protected fields from Foo are still not visible from FooTest. What else do I need to do?

gruszczy
  • 40,948
  • 31
  • 128
  • 181

1 Answers1

1

I figured out what I was doing wrong. Making FooTest a friend class allows accessing private fields from methods inside FooTest, but not from the individual test cases. I had to add accessors in FooTest that would allow access into Foo.

gruszczy
  • 40,948
  • 31
  • 128
  • 181