Rofl.
Acacademic half knowledge with complete wrongs
Dude. I've been a professional software developer for 25 years, and am a respected engineer at one of the biggest names in software. You use my software daily.
If there are any heap-allocated blocks remaining (not freed) at exit, the program has a memory leak
No it has not. Where should the memory go to after the program has exited?
Well, obviously it'll all be returned to the system after exit. The point is to check AT EXIT. If there are any blocks still allocated, you've screwed up.
Technically you can test a 40 lines mess of loops and if cascades, practicaly you can't ... or how likely is it that you can prove me in a reasonable time that a certain branch in an if - else inside of a cascade of nested loops and if's is executed with meaningfull data in your test? Especially if I have written the function and you want to write the test?
I've done it many times. Just check to see which branches aren't being executed and work out what needs to be done to execute them.
Though it's much, much better to refactor the function first.
The rest I leave as it stands if you like to argue about how likely it is that a single compilation unit has a bug that is not dicovered by a functional user acceptance test ... unit tests without user acceptance tests or integration tests are pointless.
I've found thousands of bugs with unit tests that were not discovered by functional tests, integration tests, or user acceptance tests. In fact, unit tests are the most likely ones to find thing like subtle boundary condition errors which are hard to reproduce and are the source of nasty, rare bugs that are seen in production only once in a while.
The next thing is you tell me to test getters and setters ...
Typically those get exercised by integration tests... and it is a good idea to have coverage of them at some point in your automated suite, because the whole point of getters and setters is that they may someday become non-trivial. Writing tests for them at that point isn't as good as already having tests in place, because you want to verify that your new implementation doesn't have subtle differences in behavior.
But you will figure that soon enough when you have 100% code coverage and still have bugs and wonder why
No one is claiming that unit tests are sufficient, only that they're necessary.
Btw, I never was in a team that had a memory leak in a GCed language.
Then you haven't worked on many non-trivial systems.