I'm wondering if people see much value to using this macro.
or a runtime check that enforces the comment:
#define UNIT_TEST_ONLY CHECK(g_running_unit_tests);
where g_running_unit_tests is a global static that defaults to false
and that the unit testing framework sets to true.
Adam
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
or a runtime check that enforces the comment:#define UNIT_TEST_ONLY CHECK(g_running_unit_tests);
where g_running_unit_tests is a global static that defaults to false
and that the unit testing framework sets to true.
Seems OK to me, and the least complicated approach. We could write a
presubmit check to ensure functions with names ending with ForTesting
are only called from _unittest or _test_support files.
Cheers,
Jói
I've previously seen a number of "XXXForTest()" functions, and this
crude search makes it look relatively prevalent.
http://google.com/codesearch#search/&q=.*ForTest%5C(.*%5C)%5C%20%7B%20file:.*%5C.cc&type=cs
Seems more popular that the ForTesting variant.
http://google.com/codesearch#search/&q=.*ForTesting%5C(.*%5C)%5C%20%7B%20file:.*%5C.cc&type=cs
Personally, having the function named "ForTest" seems like pretty
strong documentation even without any sort of build system
enforcement.
-Albert
Cheers,
Jói