I am unit testing for code coverage, making sure that every possible code path is executed by a unit test.
I find that a switch/case element which merely contains a break can be breakpointed, but that the break is never hit, control just jumps to the end of the switch, presumably because of compiler optimization.
A colleague is arguing that that I have not adequately unit test that path.
So, I searched and found an S.O question - which I can not longer find - about C++ code that does nothing. The only answer that didn't also get optimized away of generate compiler or static code analysis errors was []() {}()
.
This works, insomuch as a breakpoint on it will be hit.
Problem solved, I guess, but what does that actually do?