开发者

how do you test a calculator? [closed]

开发者 https://www.devze.com 2023-01-06 17:30 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号