See below program:

m1(int x, int y)    
  if (x<0) and (y>0) 
      print("only x is negative")
  else if (x>0) and (y<0) 
      print("only y is negative")
end m1

I think the equivalence partitioning for y includes y<0, y=0 and y>0. Similarly for x. When x and y are considered together, I think we have 9 equivalence classes (for example, one is when x>0 and y>0 and so on).

However, I have no idea how to write the boundary value analysis and relevant test cases. Most of the reference I found deal with the case when each x and y are ranges of values. Could you please help me?

  • What if your conditions are wrong in the first place? What if both x and y will be zero? Or undefined, or null? Hm...
    – pavelsaman
    Nov 26, 2021 at 11:10
  • @pavelsaman Depends on the implementation, but "int", in lower case, usually means a value, not an object - thus null or undefined probably don't make sense. Nov 26, 2021 at 11:49
  • 1
    @JoãoFarias: If you attempt to compile such a program (meaning int data types as parameters and calling the function with NULL arguments) in C, it will succeed with only a warning about not using casting. It makes sense to consider such testing as well.
    – pavelsaman
    Nov 26, 2021 at 12:13
  • The conditions are correct, and both x and y expect integer values.
    – Karl 17302
    Nov 26, 2021 at 15:56


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.