Looking at script/descriptor.cpp, and the associated test file descriptor_tests.cpp, much of the code in descriptor.cpp is inside an anonymous namespace (AN). If I'm not mistaken, this makes functions accessible only within the translation unit corresponding to the source file they're defined in. Functions that are used in the test in descriptor_tests.cpp (such as the Parse function) are outside of the AN. I would like to use the DescriptorChecksum function from descriptor.cpp in a unit test, but it's inside the AN and thus inaccessible from descriptor_tests.cpp. I currently see three options:
#include "descriptor.cpp"at the top of descriptor_tests.cpp, which is ugly- Move the
DescriptorChecksumfunction outside of the AN. - Leave it alone and find something else to unit test
What's the best way to approach this?
Also - a lot of the code is inside ANs. Is there a special reason for this? Wouldn't it make sense to gradually move the code outside of ANs to make it more accessible to unit tests?