Consider the following code fragment in Java. The code examines the values of 4 integer variables (called ‘a’, ‘b’, ‘c’ and ‘d’). Depending on the value of these 4 variable, the flow-of-control in the code will move on to different lines of code. We wish to do glass-box testing of this code. For this problem you must find a set of values for the 4 variables to guarantee that LINE 1 is executed. Then you must find another set of 4 values to guarantee that LINE 2 is executed, etc. You should provide 8 different sets of the 4 values a, b, c, and d that together would insure that every line of code in this small program is executed by at least one of the 8 sets of values.
if ( a < b ) {
if ( c < d ) {
if ( a < c )
System.out.println ( a ); /* LINE 1 */
else
System.out.println ( c ); /* LINE 2 */
else {
if ( a < d )
System.out.println ( a ); /* LINE 3 */
else
System.out.println ( d ); /* LINE 4 */
}
}
else {
if ( d < c) {
if ( b < d )
System.out.println ( b ); /* LINE 5 */
else
System.out.println ( d ); /* LINE 6 */
}
else {
if ( b < c )
System.out.println ( b ); /* LINE 7 */
else
System.out.println ( c ); /* LINE 8 */
}
}