Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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.

share|improve this question
    
My opinion is that this is a coding problem, and would fit better on the coding website than here on the math website. –  Gerry Myerson Nov 4 '12 at 11:54
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. –  sperners lemma Nov 4 '12 at 11:56
add comment

1 Answer 1

up vote 3 down vote accepted

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<y$)
  • $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.

share|improve this answer
    
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. –  Fendorio Nov 4 '12 at 15:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.