2
$\begingroup$

I've been tasked with providing a comprehensive test for some code that calculates x-y.

You can assume that the code is not simply (x-y)

My idea is that a good set of values would be: 3 and 7

I think this because they are prime. Can anyone give me their opinion on this.

Many thanks.

  • 1
    @Fendorio, it is impossible to completely test it because there are infinitely many numbers and you can only test finitely many! To check that - is correct you need to proof by induction.2012-11-04

1 Answers 1

3

This is really a coding question, but I would recommend having a set of test data which ensures that all possible sorts of result are tested, such as:

  • $x=7$ and $y=7$ (test it gives the correct answer for equal inputs)
  • $x=3$ and $y=7$ (test it gives the correct answer for $x)
  • $x=7$ and $y=3$ (test it gives the correct answer for $x>y$)

It is probably also worth testing that you get the correct answer if $x$ or $y$ or both take the maximum value (or minimum value, i.e. most negative) allowed in your implementation language.

  • 0
    Ok that's brilliant. Thank you for your input! When i'm able to vote answers up i will be sure to vote yours. Thanks again.2012-11-04