how do you test a calculator? [closed] - testing

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? 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.

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.

Related

Program overloading? [closed]

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 9 years ago.
I have this project that has functions to load different chapters of a book. (Ex. loadChapter1)
My thinking was that I will call the functions to load up every chapter when the app launches. But by the time I am done with the program, there would be a huge amount of chapters. It's only loading up lots of NSStrings.
Would that make the program slow to initialize or even crash the program?
My functions are declared in AppDelegate.h using ( -(void)loadChapter1 ). The way I call it in AppDelegate.m is using [self loadChapter1].
If this is not a good way, this there any other way to do this?
You're better off trying something, seeing if it works well, then making changes (and possibly asking questions here) if it doesn't rather than asking a question like this at the outset. For performance questions in particular, the accepted wisdom is that you shouldn't worry too much about performance (memory and CPU usage) while initially writing a program, but rather should do performance optimizations as needed after you've got the program working.
That said, my first approach to this would be to load each chapter as it's requested. So, don't load all the chapters in the book every time the app launches. Rather, load a chapter when the user turns the page to that chapter or selects it in the table of contents (or whatever applies to your app). That way, you don't waste time and memory loading chapters that before they're actually going to be used.

How do I implement an eraser tool for a drawing/painting app? [closed]

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 11 years ago.
I am trying to develop a drawing/painting app for my portfolio.
The functions I have now are "Write", "Change Size", and "Change Color".
Now, I am trying to implement an eraser tool that will totally erase what's written. What I did so far was copy the same code I used for writing, using white as the color, but instead of erasing what's written it just overwrites the first one. Is that the right way, or is there another way to implement this?
I don't honestly know too much about OpenGL as of this writing, but I suspect that painting over with white is the wrong thing to do. Consider what happens if you decide to allow users to change the background color. The your code gets a little more complicated. What if you decide to add support for gradients?
I suggest finding a way to simply clear the data at a given point, for example, where your brush is. You might want to look at an open source graphics program, like GIMP, to see how they do it.

Difference Between Data Driven and Keyword Driven Testing? [closed]

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 9 years ago.
I searched already to see differences between data and keyword driven testing on Google but I did not find an enough answer for me.
Keywords and data are tools used in automated test scripts. You use a keyword to represent an action. A sequence of keywords drive a script. So you can use the same set of keywords to build a variety of test scripts. You use data as inputs to your script actions. Each data set you have in the script, provides a test case. So the more data sets, the more test cases. The idea is that these tools help to quickly define numerous test cases and test scripts so that your test coverage is larger.
I wouldn't get too caught up in trying to learn meaning of buzz words. Just use tools that help you test more and better.
In 8 days, i got something that want to write here:
First thing, kdt is so expensive (for time and people). because of this, almost all automated testing tools uses a hibrit (ddt and kdt) approach. And like Dabowhekk said before, kdt also include test scenarios, actions&events.

Why Pex is not massive [closed]

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.
Hi there: I was looking at a few videos, etc and I just cant help but wonder why Pex usage seems to be so low?
Are there any problems that are not obvious, or is it just a licence issue?
It's a very new tool and to work really well you need to use Code Contracts as well. It also catches a lot of issues like possible integer overflows that a lot of developers think they can just ignore. Pex is amazing and will take off eventually but it has a learning curve so it's going to take some time to percolate through the .Net ecosystem.
I've used it on a few new development projects and it has saved me two major bugs (not caught by normal unit tests) that would have taken at least a week to track down and fix normally plus a few smaller issues so I'm a big proponent of Pex. That said it takes a lot of work to get it producing good results on an existing code base of any size so how cost effective it is will need to be determined on a project by project basis.

Which one is "better" code snippet? [closed]

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 13 years ago.
Which code snippet is better? and How? ['Better' on the basis of, readability, debug, code standards etc...,]
Dim Name As String = Employee.Name
or
Dim Name As String
Name = Employee.Name
Combining declaration and assignement is generally thought to be the best approach (your first example)
Well as they are both equivalent and both very simple I would expect the compiler to reduce them to the same thing so neither is really better.
Personally I feel the second has its advantages in that you can create several variables of one type in one line of code and then initialise them one after the other which for readable code is my preference. But if you only have one variable to initialise then the first is nice and concise as well.
As long as there is no null / empty or content checking between declaration and assignment, I prefer option number 1. Easier to read and less clutter.