In: Computer Science
Given a module which implements the function Z= F(X, Y), defined as follows:
X + Y when 10<=X<=20, and 12<=Y<=30
Z = X - Y when 0<=X<10, and 0<=Y<12
0 under other conditions
where X and Y are integer parameters for F.
1. Identify the equivalence classes in [X, Y].
2. List your test cases in [X, Y] based on your equivalence class analysis.
Answer 1:
Equivalence class is a subset which include all the elements
equivalent to each other i.e. any element from that subset will
give the same result. There are following equivalent classes in
[X,Y]:
a. X<0;
Y
Z (X is any negative integer, Y belongs to any integer) result
will be 0
Note, Z is the notation for integers
b. X
[ 0, 10);
Y
[ 0, 12 ) (X is any integer greater than equal to 0 and less than
10, Y belongs to any integer greater than equal to 0 and less than
12) result will be (X-Y)
c. X
[ 0, 10);
Y
Z except [ 0, 12 ) (X is any integer greater than equal to 0 and
less than 10, Y belongs to any integer less than 0 or greater than
equal to 12) result will be 0
d. X
[ 10, 20];
Y
[ 12, 30 ] (X is any integer greater than equal to 10 and less
than equal to 20, Y belongs to any integer greater than equal to 12
and less than equal to 30) result will be (X+Y)
e. X
[ 10, 20];
Y
Z except [ 12, 30 ] (X is any integer greater than equal to 10 and
less than equal to 20, Y belongs to any integer less than 12 or
greater than 30) result will be 0
f. X > 20;
Y
Z (X is any integer greater than 20, Y belongs to any integer)
result will be 0
Answer 2:
Test cases in [X, Y] will include one element from each class
defined above. Therefore, there will be following 6 test cases:
(there are multiple answers possible to this question)
1. [X,Y] = [-2, 30] ...
2. [X,Y] = [3, 9] ...
3. [X,Y] = [3, 12] ...
4. [X,Y] = [10, 12] ...
5. [X,Y] = [12, 8] ...
6. [X,Y] = [30, -6] OR [30, 60] ....