Ad Code

Contract for square root routine keeping in view unit testing.

Below is the chunk of code :

result = squareRoot(argument);
assert (abs (result * result – argument) < epsilon);

Write the Contract for square root routine keeping in view unit testing.


  • Pass in a negative argument and ensure that it is rejected
  • Pass in an argument of zero to ensure that it is accepted (this is a boundary value)
  • Pass in values between zero and the maximum expressible argument and verify that the difference between the square of the result and the original argument is less than some value epsilon.
Reactions

Post a Comment

0 Comments