Professional Documents
Culture Documents
Question 1:
Create Test cases to satisfy statement coverage and branch coverage
// Program to print positive number entered by the user
// If the user enters a negative number, it is skipped
#include <iostream>
using namespace std;
int main() {
int number;
cout << "Enter an integer: ";
cin >> number;
// checks if the number is positive
if (number > 0) {
cout << "You entered a positive integer: " << number << endl;
}
cout << "This statement is always executed.";
return 0;
}
number > 0
n1
T F
Exit
Test Cases:
Statement Coverage:
Test Cases Input Expected Actual
Branch Coverage:
Test Cases Input Expected Actual
1-Yes number=1 You entered a positive integer: 1 You entered a positive integer: 1
This statement is always executed. This statement is always executed.
2-No number=-2 This statement is always executed. This statement is always executed.
Question 2:
Create Test cases to satisfy condition coverage and multiple condition
coverage
Logical operators
#include <iostream>
#include <string>
using namespace std;
int main()
{
int a=10, b=8,c=12,d=14;
if(!(a==0))
cout<<"a is not zero"<<endl;
else
cout<<"a is zero"<<endl;
if((a>b)&&(c<d))
cout<<"Logical AND is true"<<endl;
else
cout<<"Logical AND is false"<<endl;
if((a<c)||(b<d))
cout<<"Logical OR is true"<<endl;
else
cout<<"Logical OR is false"<<endl;}
a=10, b=8,c=12,d=14
n0
!
n1 (a==0)
T F
a is not zero a is zero
n2 n3
((a>b)&&(c<d) n4
)
T F
Logical AND is true n5 n6 Logical AND is false
n7 ((a<c)||
(b<d))
T F
Test Cases:
Statement Coverage:
Test Cases Input Expected Actual
1 a=10, b=8, a is not zero a is not zero
c=12,d=14 Logical AND is true Logical AND is true
Logical OR is true Logical OR is true
Conditional Coverage:
FOR LOGICAL AND
Test Cases Input Expected Actual
FOR LOGICAL OR
Test Cases Input Expected Actual