Chapter 24. Data-Flow Testing Exercise
It’s time to apply the white-box data-flow testing concepts you’ve learned to a simple program. Again, we’ll use our simple C program that converts hexadecimal input, shown in Listing 24-1. To refresh your memory, this program converts hexadecimal character input into an integer. It displays the number of hexadecimal characters it received and their value (in hexadecimal). It ignores nonhexadecimal characters. It accepts as many characters as you want to give it. This program will run on a Windows or Linux system if you have a compiler available to you.
The exercise consists of five major activities:
Identify the data items.
For each data item, identify the set-use pairs.
For each data item and set-use pair, identify test inputs to cover those set-use pairs.
Compare those test inputs to the test inputs you created for control-flow testing, for both statement, branch, condition, and loop (SBCL) coverage and basis test coverage.
Identify any additional data-flow-related tests you’d like to run to investigate other bug assumptions.
I suggest 60 minutes as a time limit. When you’re done, keep reading to see my solution.
Example 24-1. Hexadecimal converter program
1. main() 2. /* Convert hex digits to a number */ 3. { 4. int c; 5. unsigned long int hexnum, nhex; 6. 7. hexnum = nhex = 0; 8. 9. while ((c = getchar()) != EOF) { 10. switch (c) { 11. case '0': case '1': case '2': case '3': case '4': 12. case '5': case '6': case '7': case '8': case '9': 13. /* ...
Get Pragmatic Software Testing: Becoming an Effective and Efficient Test Professional now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.