Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. FRIEND_TEST(TestCaseName, TestName);
  2.  
  3. // foo.h
  4. #include <gtest/gtest_prod.h>
  5.  
  6. // Defines FRIEND_TEST.
  7. class Foo {
  8. ...
  9. private:
  10. FRIEND_TEST(FooTest, BarReturnsZeroOnNull);
  11. int Bar(void* x);
  12. };
  13.  
  14. // foo_test.cc
  15. ...
  16. TEST(FooTest, BarReturnsZeroOnNull) {
  17. Foo foo;
  18. EXPECT_EQ(0, foo.Bar(NULL));
  19. // Uses Foo's private member Bar().
  20. }
  21.  
  22. #define FRIEND_TEST(test_case_name, test_name)
  23. friend class test_case_name##_##test_name##_Test
  24.  
  25. friend class FooTest_BarReturnsZeroOnNull_Test;
  26.  
  27. // foo.h
  28. #include <gtest/gtest_prod.h>
  29.  
  30. class FooTest_BarReturnsZeroOnNull_Test;
  31.  
  32. // Defines FRIEND_TEST.
  33. class my_namespace::Foo {
  34. ...
  35. private:
  36. FRIEND_TEST(::FooTest, BarReturnsZeroOnNull);
  37. int Bar(void* x);
  38. };
  39.  
  40. // foo_test.cc
  41. using namespace my_namespace;
  42.  
  43. ...
  44. TEST(FooTest, BarReturnsZeroOnNull) {
  45. Foo foo;
  46. EXPECT_EQ(0, foo.Bar(NULL));
  47. // Uses Foo's private member Bar().
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement