O'Reilly logo

Pragmatic Software Testing: Becoming an Effective and Efficient Test Professional by Black, Rex, Rex Black Consulting Services, Bulverde, Texas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

  1. Identify the data items.

  2. For each data item, identify the set-use pairs.

  3. For each data item and set-use pair, identify test inputs to cover those set-use pairs.

  4. 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.

  5. 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. /* ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required