Skip to content

Commit 35b75a2

Browse files
Abseil Teamcopybara-github
authored andcommitted
Although the following paragraph explains there is a better solution, having this technique in the bullet point seems to suggest that this technique is considered as a valid alternative. It would be better to drop it or make it clear that this technique is not recommended.
PiperOrigin-RevId: 771116391 Change-Id: I753560115ed65e8858b749473935df57b6a50488
1 parent 175c1b5 commit 35b75a2

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

docs/advanced.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,17 +1448,19 @@ are two cases to consider:
14481448
To test them, we use the following special techniques:
14491449

14501450
* Both static functions and definitions/declarations in an unnamed namespace
1451-
are only visible within the same translation unit. To test them, you can
1452-
`#include` the entire `.cc` file being tested in your `*_test.cc` file.
1453-
(#including `.cc` files is not a good way to reuse code - you should not do
1454-
this in production code!)
1455-
1456-
However, a better approach is to move the private code into the
1457-
`foo::internal` namespace, where `foo` is the namespace your project
1458-
normally uses, and put the private declarations in a `*-internal.h` file.
1459-
Your production `.cc` files and your tests are allowed to include this
1460-
internal header, but your clients are not. This way, you can fully test your
1461-
internal implementation without leaking it to your clients.
1451+
are only visible within the same translation unit. To test them, move the
1452+
private code into the `foo::internal` namespace, where `foo` is the
1453+
namespace your project normally uses, and put the private declarations in a
1454+
`*-internal.h` file. Your production `.cc` files and your tests are allowed
1455+
to include this internal header, but your clients are not. This way, you can
1456+
fully test your internal implementation without leaking it to your clients.
1457+
1458+
{: .callout .note}
1459+
NOTE: It is also technically *possible* to `#include` the entire `.cc` file
1460+
being tested in your `*_test.cc` file to test static functions and
1461+
definitions/declarations in an unnamed namespace. However, this technique is
1462+
**not recommended** by this documentation and it is only presented here for the
1463+
sake of completeness.
14621464

14631465
* Private class members are only accessible from within the class or by
14641466
friends. To access a class' private members, you can declare your test

0 commit comments

Comments
 (0)