Guards, when tested with testing::internal::CaptureStdout using an ASSERT_ that fails, will not restore state, will leak, and eventually crash.
A couple points:
1) testing::internal::CaptureStdout should only be used within Logger, and classes that want to output log messages should use Logger and not std::cout or std::cerr.
2) If test are leaking, look into using death tests, to ensure that leaky state does not occur.
When I have time I might create some pull requests to help with this issue by getting rid of some of the std::cerr uses and replacing them with Logger instances.
Sticky note:
A couple points: 1)
testing::internal::CaptureStdout
should only be used withinLogger
, and classes that want to output log messages should useLogger
and notstd::cout
orstd::cerr
. 2) If test are leaking, look into using death tests, to ensure that leaky state does not occur.