views:

160

answers:

5

How will you test a calculator? Any 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.

A: 

by throwing it against a wall, if it breaks... then it wasn't meant to be.

jeremiah
Haha...was calculator designed to be like this robust?
Jay
Not a bad answer! Part of testing should be to get the app to crash and burn.
John at CashCommons
A: 

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.

sbenderli
Not only border cases, but normal cases as well. If you only test divide-by-zero, for example, how are you sure that divide-by-one and divide-by-two works?
Bryan Oakley
+4  A: 
  • 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?
John at CashCommons
+1  A: 

Besides normal calculations...

Divide by zero.

Make sure negative numbers work

Check if rounding is correct

Ed B
How would you make sure the normal calculations work as expected?
Jay
You would compare the results of the calculations to the results of a calculator that has been proven to work.
Ed B
A: 

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.

Bryan Oakley