Re: C++ fluency
James Kanze wrote:
On May 7, 2:30 pm, Pete Becker <p...@versatilecoding.com> wrote:
James Kanze wrote:
Testing the test? If the test is supposed to test something
very specific and non-trivial, it might be worth creating a
special version of the code to be tested, with the exact
error the test is meant to reveal.
Or the other way around, to improve test coverage. Several
years ago there was an idea called "mutation testing", where
some high-level test tool went through your source code
systematically, reversing the sense of each test that the code
did, one at a time, and running the pertinent test code to see
whether the "error" was detected. I didn't look into this too
deeply because it seems like it would take an inordinate
amount of time.
If it's the computer which is doing it, why not?
Because it would take an inordinate amount of time. <g>
I may not have made it clear:
if (a < 0) ...
Change the < to >=, rebuild the application, run the test suite, and log
failures.
Change the >= back to < and move on to the next check. Repeat for every
comparison in the source code. One at a time.
Of course, I'm
not sure that it buys that much---I've seen a lot of errors
because a variable was incorrectly initialized, a expression was
wrong (missing a parentheses, or the parentheses in the wrong
place), the code used the wrong variable or called the wrong
function, etc., etc.
It's about branch coverage: if your test cases don't exercise that
branch, changing it won't affect the test results, and you've found a
hole in the test suite.
--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of
"The Standard C++ Library Extensions: a Tutorial and Reference"
(www.petebecker.com/tr1book)