I just revisited the classic C textbook K&R. And read the exercise 1-11:
How would you test the word count program? What kinds of input are most likely to uncover bugs if there are any?
Actually, I only have a basic idea to manually count an existing paragraph to get the exact word numbers and compare it with the result word count program calculates.
Is there anything I've missed? And what is the trick of the test?
EDIT
Answers summary:
Semantic definition of word, some special cases:
boundary conditions:
Well, it depends on what you semantically define as words. Since it is you who's writing the word count program, you are supposed to know what a word is.
So to test this program, you have to think where are the corner cases: does a "linked-word" count as one or two words? Do you consider "I'm" to be one or two? Etc..
As for the K&R exercise, I guess they voluntarily forgot some of these corner cases, and they suggest that you, analyzing their code, find these caveats.
Here are some examples of texts that could uncover bugs:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With