Here is a typical C++ code:foo.hpp#pragma onceclass Foo {public:  void f();  void g();  ...};foo.cpp#include foo.hppnamespace {    const int kUpperX = 111;    const int kAlternativeX = 222;    bool match(int x) {      return x < kUpperX || x == kAlternativeX;    }} // namespacevoid Foo::f() {  ...  if (match(x)) return;  ...It looks like a decent idiomatic C++ code - a class, a helper function match which is used by the methods of Foo, some constants for that helper function.And then I want to write tests.It would be perfectly logical to write a separate unit test for match, because it's quite non-trivial.But it resides in an anonymous namespace.Of course I can write a test which would call Foo::f(). However it won't be a good test if Foo is heavy and complicated, such test won't isolate the testee from other unrelated factors.So I have to move match and everything else out of the anonymous namespace.Question: what's the point of putting functions and constants into the anonymous namespace, if it makes them unusable in tests?
Anonymous namespaces make code untestable
c++;unit testing