开发者

Give test cases for a code that finds a power of a number

Give test cases for a code that finds a power of a number

Guys this would seem to be the most easiest question to开发者_如何学编程 all the experienced members of this forum but i being a neophyte can only put up these many test cases.

1.Check both values are inputted correctly or not.

2.Check for trivial case when x=0 then for any value of n it should return 0.

3.when n=0 it should always return 1 whatever x be.

4.check for negative values of x and n. i)If n is negative then result should be always less than or equal to x.

5.Check first for smaller values of x and n i.e for 2,2 3,4 etc.

6.Now check for larger values of n and x and see the results.

Are these test cases correct and Could anybody help me in adding more test cases.


Using Boundary Value Analysis, I would test a combination of following x and n values (asuming the inputs are integers).

  • x: Low(Integer), -3, -1, 0, 1, 3, High(Integer)
  • n: Low(Integer), -3, -1, 0, 1, 3, High(Integer)

Resulting in 7x7 possible combinations or 49 testcases.

Boundary value analysis is a software testing technique in which tests are designed to include representatives of boundary values. Values on the edge of an equivalence partition or at the smallest value on either side of an edge. The values could be either input or output ranges of a software component. Since these boundaries are common locations for errors that result in software faults they are frequently exercised in test cases.

Testcases

x        n
-1              -1
-1              -3
-1              0
-1              1
-1              3
-1              High(Integer)
-1              Low(Integer)
-3              -1
-3              -3
-3              0
-3              1
-3              3
-3              High(Integer)
-3              Low(Integer)
0               -1
0               -3
0               0
0               1
0               3
0               High(Integer)
0               Low(Integer)
1               -1
1               -3
1               0
1               1
1               3
1               High(Integer)
1               Low(Integer)
3               -1
3               -3
3               0
3               1
3               3
3               High(Integer)
3               Low(Integer)
High(Integer)   -1
High(Integer)   -3
High(Integer)   0
High(Integer)   1
High(Integer)   3
High(Integer)   High(Integer)
High(Integer)   Low(Integer)
Low(Integer)    -1
Low(Integer)    -3
Low(Integer)    0
Low(Integer)    1
Low(Integer)    3
Low(Integer)    High(Integer)
Low(Integer)    Low(Integer)


You can still create testcases around the "valid input" and the way it is input:

  1. text input
  2. empty input
  3. separator equal to locale? (,. etc.)
  4. allow thousands sign?
  5. thousands sign equal to locale?
  6. how is negative input defined? - or ()
  7. scientific numbers: 5e3, 5.6e4, 1,234,567e4, -12e34, 12e-34 etc.
  8. numbers that are input in another unicode format (japanese, chinese, (real) arabic, bath etc.)
  9. insertion of input by javascript (assuming web-application)
  10. does validation work if javascript is disabled (assuming web-application)
  11. fiddling with input put in http-post (assuming web-application)
  12. what are the max numbers specified for a, b and result?

But you have to explain us more; what type of application are we talking about, what are the specifications, how is the input delivered, and do you have to test the input validation?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜