[Testing an Instrumented File] [Home]
Site Map

Calculator RPN Test Example Calculator


Suppose you want to locate the code that implements the division option of RPN. You will need two test cases, one that does a division and a similar one that does something else, say an addition, using similar inputs. Before each test you run R2TEST with two parameters: a name for the trace file, and an optional comment.

The sequence for the first test would look like the following, where your input is in bold:

  R2TEST -T DIVIDE.R2T -C "Divide test"
  RPN
  Welcome to the Reverse Polish Calculator
  Enter Two Numbers Separated by White Space
  Then an Operator. (i.e., 2 3+)
  Enter Q anytime to Quit
  6 3 / 
  2
  Q
  R2END

For the second test, using add instead of divide, you would do the following:

  R2TEST -T ADD.R2T -C "Add test"
  RPN
  Welcome to the Reverse Polish Calculator
  Enter Two Numbers Separated by White Space
  Then an Operator. (i.e., 2 3+)
  Enter Q anytime to Quit
  6 3 +
  9
  Q
  R2END

Two trace files would be created, one named DIVIDE.R2T and the other named ADD.R2T. Each contains the source code file index, the line number, and the direction (T or F) of each branch that was encountered in one of the tests. For example, DIVIDE.R2T would look like

DIVIDE.R2T
Divide test
002 14 F
002 17 F
002 20 T
002 21 F
002 28 T
001 15 F
004 11 T
002 14 F
etc....


[Testing an Instrumented File] [Home]
Site Map