FRIEND_TEST and Type-Parameterized Tests

408 views
Skip to first unread message

Fed

unread,
Nov 3, 2014, 6:16:37 PM11/3/14
to googletes...@googlegroups.com
It seems that FRIEND_TEST and Type-Parameterized tests don't go hand in hand. TYPED_TEST_P seems to prefix the tests and do some namespacing along with more name mangling than gtest normally does.

Is there a reasonable way to emulate the behavior of FRIEND_TEST in this situation?

Thanks for the help!

Billy Donahue

unread,
Nov 3, 2014, 6:44:26 PM11/3/14
to Fed, googletes...@googlegroups.com
I find it's better to just make test accessors or a test peer class for "private" things I want tests to access, and just forget about FRIEND_TEST. I don't like modifying the code when I add new tests.
--

---
You received this message because you are subscribed to the Google Groups "Google C++ Testing Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to googletestframe...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Fed

unread,
Nov 3, 2014, 6:52:59 PM11/3/14
to googletes...@googlegroups.com, fspa...@gmail.com
Billy, do you have any example code for your approach?

I'm in the middle of working on an existing code base and ended up with a few specialized versions of classes I need to test. The original testing design depends heavily on accessing internal members and I'm trying not to rock the boat too much.

Billy Donahue

unread,
Nov 4, 2014, 12:13:17 AM11/4/14
to Fed, Google C++ Testing Framework
I don't have code handy, but the idea is simple.

class X {
 private:
  int secret() const;
 public:
  class TestPeer;
};

// used in tests to interrogate 'X' objects for private data through a controlled facade.
struct X::TestPeer {
  private:
    int secret(const X& x) { return x.secret(); }
};



On Mon, Nov 3, 2014 at 6:52 PM, Fed <fspa...@gmail.com> wrote:
Billy, do you have any example code for your approach?

I'm in the middle of working on an existing code base and ended up with a few specialized versions of classes I need to test. The original testing design depends heavily on accessing internal members and I'm trying not to rock the boat too much.

--
Reply all
Reply to author
Forward
0 new messages