1. ## testing question

Hi!
My name is Ioana and I need some help..
How do I test a program designed to take inputs of integers from 1-1000 and to output the factorial value of that number? (I do not have access to the code).
Thanks a lot.

2. ## Re: testing question

hmmmm.......

First query. How do you get a fractional part of an integer? By definition, integers do not have fractional parts.....

[ 10-24-2005, 08:34 AM: Message edited by: Darrel Damon ]

3. ## Re: testing question

Darrel,
"factorial" is not the same as "fractional"

Ioana,
For some small integers you may compare the output to the result of your manual calculations (4!=1x2x3x4=12). For larger integers, I do not see other possibility than to compare two programs: one that is known to give good outputs (called "oracle") and the other that you test. If the program under test returns the same answers as the oracle (both fed by a large number of inputs), it can be considered as correct (assuming that the oracle is correct).

Now, if you do not have an oracle, create a new program that uses another algorythm (you can find them in almost any old school book on programming) and compare them. If both give the same answers, you may say with quite a good confidence that both are right. (If you do not know which algorithm is used in the program under test, create two new programs, each with different algorithm.) If they give different outputs to the same inputs, well, all you can say is that at least one of them is wrong (but you do not know which one)! [img]images/icons/frown.gif[/img]

There is, of course the problem of the output format: factorial of 1000 is a very big number and it is not evident how to present the outputs and how to compare them.

4. ## Re: testing question

Sorry, RTQ failed in my case. Too early. I didn't have my coffee. My apologies.

Even testers fail every once in a while. [img]images/icons/frown.gif[/img]

There is a basic issue in the question and your response.

Do you test all 1000 factorials? Or do you test only a few? If only a few, which ones?

I think those questions are more important than the mechanics of how to construct the test.

Sounds like a test question or an interview question to me. The premise of the question, and the code to be tested, is too basic to be otherwise.

[ 10-24-2005, 08:35 AM: Message edited by: Darrel Damon ]

5. ## Re: testing question

You could actually create the factors in an excel spreadsheet. There is a function and it shouldn't take you more than a few minutes. Howvere you will get to a limit on the size of the number which I think will be under 200. If you create a program verify the language limit on numbers as this is going to be a limiting factor.

A2 = 6
Formula Description (Result)
=FACT(A2) Factorial of 6, or 6*5*4*3*2*1 (720)
=FACT(3) Factorial of 3, or 3*2*1 (6)
=FACT(A2+4) Factorial of 10 (3628800)

[ 10-24-2005, 10:07 AM: Message edited by: lynneM ]

6. ## Re: testing question

Guys, let's not forget boundary testing, which for integers would be 0,1,2,7,8, ... I suspect the attempt with 8 will be telling [img]images/icons/wink.gif[/img]

7. ## Re: testing question

Originally posted by IoanaC:
Hi!
My name is Ioana and I need some help..
How do I test a program designed to take inputs of integers from 1-1000 and to output the factorial value of that number? (I do not have access to the code).
Thanks a lot.
<font size="2" face="Verdana, Arial, Helvetica">Is this an interview question?
Or an exam question?

8. ## Re: testing question

That was my thoughts Joe. I surely can't see that testing this program is a job scenario.

9. ## Re: testing question

Factorial of 1000 is a really HUGE number. More than 1 followed by 1000000 zeros. Surely an Excel sheet is not an adequate tool.
For me it looks like a very nice subject for an academic seminar.

10. ## Re: testing question

Ioana,

It is a good thing Darrell did not have a coffee induced urge to tell you that we normally don't do interview questions or educational questions. I guess the others were getting excited enough to jump in with excellent solutions. Surely there is more to this question than you let on, otherwise it is just a little too easy to be taken serious.

1. Assuming the program exists already.

Who asked you to write tests for an application I assume has very little commercial value? What is that program used for? What is the business risk if that program fails to perform? I guess you get my drift: I don't believe this is a testing issue at all.

2. Assuming you want to figure out how to create an algorithm that would simulate calculations for numbers of that magnitude.

Your problem is not that complicated. You need an array (a character string will do if necessary) and assuming you have figured out how to get the prime numbers between 1 and 1000 you can in fact solve this by multiplying the numbers one digit at a time (don't forget right to left). It is a cute programming challenge actually, and you can solve it using Excel if you know how to use VBA.

Page 1 of 5 12345 Last

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.