4 ms·
This would have been so, sooooo easy to detect with a unit test. It boggles the mind that no one would bother to write a test for something both so fundamental
by usefulcat 4y ago
This would have been so, sooooo easy to detect with a unit test. It boggles the mind that no one would bother to write a test for something both so fundamental AND so eminently testable.
- jeffrallen 4y agoYes, it boggles the mind that you didn't. Because if you have enough time to criticize other open source maintainers, you certainly have time to write the unit tests they aren't writing, right?
- loeg 4y agoIt's the m68k target -- to a first degree approximation, no one uses this.
- michael1999 4y agoThat code is older than the culture of comprehensive automated testing. It's hard for modern minds to believe how little automated testing existed before the xunit revolution.
- icedchai 4y agoI'm skeptical. Odds are any such test would use short ASCII strings and probably not uncovered the problem. Also, the most common uses cases of strcmp are comparisons with 0. Any such unit test would probably do the same, further minimizing the odds of discovery.
- mmcgaha 4y agoI agree, this is the type of bug where the test would not have been written until after the bug was found. When the bug gets found, the test will be written, the code will be updated and no one will touch it unless another bug gets found; rinse and repeat. Just like it is hard to proof read your own papers, it is hard to write complete tests for your own code.
- layer8 4y agoWriting a good unit tests always means looking at the possible value ranges and specifically the edge cases within those ranges, and adding tests for those. That’s the standard course of action when writing unit tests for some API. Unit tests aren’t supposed to just mimic typical usage.
- icedchai 4y agoRight. They're not supposed to test only the typical, minimal usage, but they often do. In very old C code, you'll be lucky if it has any tests at all.