3
匿名名称空间使代码不可测试
这是典型的C ++代码: foo.hpp #pragma once class Foo { public: void f(); void g(); ... }; foo.cpp #include "foo.hpp" namespace { const int kUpperX = 111; const int kAlternativeX = 222; bool match(int x) { return x < kUpperX || x == kAlternativeX; } } // namespace void Foo::f() { ... …
12
c++
unit-testing