0

I have been recently working on a calculator application which I thought was working fine and I tested it with all cases I could think of. All pass.

I was discussing my application on stackoverflow when a user @rici actually discovered a case where my application would fail. That naturally made me realize that there may be more cases where my calculator could fail, it would help immensely if there exists a set of test cases that I could enter into my calculator and test it out, like a certification of tested.

Further, how can ensure that my calculator is free of bugs and all it's calculations are accurate?

Sarthak123
  • 150
  • 6
  • 1
    You can't prove that no more bugs exist, as was demonstrated to you. Most you can do is check that your calculator works in these certain conditions / expressions. So, the key to good test coverage is making up a lot of test expressions, from "regular" to "wild" (edge-cases). It is also useful to have failure assertions ("the calculator will fail on this expression with this error") – Sergio Tulentsev Jun 18 '18 at 07:31

1 Answers1

1

The best is to let other people use it, just as Rici found a bug you didn't find. After designing the code yourself it is very hard to zoom out and see all bug possibilities. What you need is new eyes, especially other programmers who like to break things. They don't know the input sequences you usually follow, or might not even understand the workflow well. This means the could do things you never expected.

And just a word of warning, it is hard and very time consuming to write a complex program that is completely free of bugs. Especially when working on your own. But please do try, as that is one of my favourite parts about programming as well.

Hein Wessels
  • 937
  • 5
  • 15
  • "it is hard" - more like impossible. Remember that OpenSSL vuln? The code was 20 years old and was considered bulletproof. – Sergio Tulentsev Jun 18 '18 at 08:01
  • If there is not a well defined standard test of calculator applications, does it mean that *there are* some calculators applications floating around in, say, playstore that aren't properly tested and may show inaccurate results? – Sarthak123 Jun 18 '18 at 14:36
  • Firstly, inaccuracies are **inevitable** due to calculators being digital. Every number must be stored with a limited amount of ones and zeros. For everyday calculators this effect is negligible. But for complex simulations programs like Matlab do complex things to minimize these errors, but they never disappear. **But** I was talking more about your program freezing. Maybe it can go into an unknown state after weird button presses. Maybe minimizing/maximizing hides a button. And variable overflows is hard to handle if not done correctly. But I doubt that any calculators will say: `1+1=3` – Hein Wessels Jun 18 '18 at 14:59