Oops! It appears that you have disabled your Javascript. In order for you to see this page as it is meant to appear, we ask that you please re-enable your Javascript!

Condition / Decision Coverage Examples and calculator

[insert_php] $c1=”Empty”;
$c1_1=”Empty”;
$c1_1_1=”Empty”;

$c2=”Empty”;
$c2_1=”Empty”;
$c2_1_1=”Empty”;

$c3=”Empty”;
$c3_1=”Empty”;
$c3_1_1=”Empty”;

$d1=”Empty”;
$d1_1=”Empty”;
$d1_1_1=”Empty”;
[/insert_php]

Input the values in form according to the program mentioned below;

[insert_php] if(isset($_POST[‘cond’]))
{
$x=$_POST[‘x’];
$y=$_POST[‘y’];
$z=$_POST[‘z’];
if(($x >= 0) || ($x < 0)) { if(($y >= 0) || ($y < 0)) { if(($z >= 0) || ($z < 0)) { if($x==0) { $c1='T'; } else { $c1='F'; } if($y>0)
{
$c2=’T’;
}
else
{
$c2=’F’;
}
if($z<0) { $c3='T'; } else { $c3='F'; } if (($x==0) || ($y>0) && ($z<0)) { $d1='T'; } else { $d1='F'; } }}} else { echo "Error"; } $a=$_POST['a']; $b=$_POST['b']; $c=$_POST['c']; if($a==0) { $c1_1='T'; } else { $c1_1='F'; } if($b>0)
{
$c2_1=’T’;
}
else
{
$c2_1=’F’;
}
if($c<0) { $c3_1='T'; } else { $c3_1='F'; } if (($a==0) || ($b>0) && ($c<0)) { $d1_1='T'; } else { $d1_1='F'; } if($c1!=$c1_1) { $c1_1_1= "Covered"; } else { $c1_1_1= "Not Covered"; } if($c2!=$c2_1) { $c2_1_1= "Covered"; } else { $c2_1_1= "Not Covered"; } if($c3!=$c3_1) { $c3_1_1= "Covered"; } else { $c3_1_1= "Not Covered"; } if($d1!=$d1_1) { $d1_1_1= "Covered"; } else { $d1_1_1= "Not Covered"; } } [/insert_php]

Condition / Decision Coverage (TABLE # 1)

Enter A First Value ‘a’**(a==0)
Enter A Second Value ‘b’**(y>0)
Enter A Third Value ‘c’**(c<0)

Condition / Decision Coverage (TABLE # 1.01)

Enter A First Value ‘a’**(a==0)
Enter A Second Value ‘b’**(y>0)
Enter A Third Value ‘c’**(c<0)

Example # 1

Void Main()

cout<<"Enter a First Value";
cin>>a;
cout<<"Enter a Second Value";
cin>>b;
if(a==0)\\ Check For Condition Coverage
“Your Condition 1st is 0”;
else
“Your Condition 1st is 1”;;
if(b>0)
“Your Condition 2nd is 0”;
else
“Your Condition 2nd is 1”;;
if(c<0)
“Your Condition 3rd is 0”;
else
“Your Condition 3rd is 1”;;
if((a==0) ||(b>0) && (c<0)\\ Check For Decision Coverage
cout<<"Your Decision 1st is 0";
else
cout<<"Your Decision 1st is 1";

Condition / Decision Coverage (TABLE # 2)

1st Condition2nd Condition3rd Condition1st Decision
[insert_php] echo $c1; [/insert_php][insert_php] echo $c2; [/insert_php][insert_php] echo $c3; [/insert_php][insert_php] echo $d1; [/insert_php]
[insert_php] echo $c1_1; [/insert_php][insert_php] echo $c2_1; [/insert_php][insert_php] echo $c3_1; [/insert_php][insert_php] echo $d1_1; [/insert_php]

Condition / Decision Coverage (TABLE # 3)

1st Condition[insert_php] echo $c1_1_1; [/insert_php]
2nd Condition[insert_php] echo $c2_1_1; [/insert_php]
3rd Condition[insert_php] echo $c3_1_1; [/insert_php]
1st Decision[insert_php] echo $d1_1_1; [/insert_php]