how do you test a calculator? [closed]
How will you test a calculator? An开发者_开发技巧y thoughts?
thanks,
=== Sorry that I did not elaborate this question much at the beginning. Now, I want to give more backgrounds about this. This question was asked during a technical interview for a programmer position. So I suppose they were looking for some really "smart" answers or some good approach to test such application...
Thanks again.
- Exercise the interface. Does it do what you expect?
- Exercise the functionality. Does it do what you expect?
- Exercise boundary conditions. Does it handle division by zero? How does it handle really big and really small values? Are there rounding errors that crop up?
by throwing it against a wall, if it breaks... then it wasn't meant to be.
Besides normal calculations...
Divide by zero.
Make sure negative numbers work
Check if rounding is correct
If you are a calculator manufacturer you will undoubtedly have a database of formulas with known outputs for specific inputs. To test the calculator, give it the known inputs and check that it computes the known outputs.
You then also need to test that each button has the desired effect on the internal stack.
Finally, you will need to test all the non-math functionality -- does the clear button clear the display? Do your undo buttons properly undo? And so forth.
In general, you would want to check for border cases for every possible operation.
For example, for addition, you would check negative additions, additions involving irrational or infinite numbers etc.
For division, you would check for dividing with 0, etc.
精彩评论