Program 1-Boundary Value Analysis
Program 1-Boundary Value Analysis
#include<stdio.h>
int main()
{
int n,i=0,total,tcno=0,col,var_count=0;
int ar[100][3];//Assuming variables are not more than 100
printf("Enter the number of variables ");
scanf("%d",&n);
total=4*n;
col=n;
while(n)
{
printf("\n\nEnter the range of variable %d:",i+1);
printf("\nMINIMUM: ");
scanf("%d",&ar[i][0]);
printf("MAXIMUM: ");
scanf("%d",&ar[i][1]);
ar[i][2]=(ar[i][1]+ar[i][0])/2;
n--;
i++;
}//end while
printf("\n\n\nTest cases according to BOUNDARY VALUE ANALYSIS
are:\n\n\n");
printf("TEST CASE No. \t");
while(i)
{
printf("Variable %d \t",n+1);
n++;
i--;
}//end while
printf("\n\n%-14d\t",tcno+1);
tcno++;
while(n--)
{
printf("%-10d\t",ar[i][2]);
}//end while
while(total--)
{
printf("\n\n%-14d\t",tcno+1);
i=0;
while(i<col)
{
if(i == var_count)
{
switch ( tcno % 4 )
{
case 0: printf("%-10d\t",ar[i][1]-1);
break;
case 1: printf("%-10d\t",ar[i][0]);
break;
case 2: printf("%-10d\t",ar[i][0]+1);
break;
case 3: printf("%-10d\t",ar[i][1]);
break;
}// end switch
}//end if
else
{
printf("%-10d\t",ar[i][2]);
}//end else
i++;
}//end inner while
if(tcno%4==0)
var_count++;
tcno++;
}//end outer while
getch();
return 0;
}//end main
PROGRAM 2-ROBUSTNESS TESTING
#include<stdio.h>
int main()
{
int n,i=0,total,tcno=0,col,var_count=0;
int ar[100][5]; //Assuming variables are not more than 100
printf("Enter the number of variables ");
scanf("%d",&n);
total=6*n;
col=n;
while(n)
{
printf("\nEnter the range of %d variable:",i+1);
printf("\nMINIMUM: ");
scanf("%d",&ar[i][0]);
printf("MAXIMUM: ");
scanf("%d",&ar[i][1]);
ar[i][2]=(ar[i][1]+ar[i][0])/2;
n--;
i++;
} //end while
while(i)
{
printf("Variable %d \t",n+1);
n++;
i--;
} //end while
printf("\n\n%-14d\t",tcno+1);
tcno++;
while(n--)
{
printf("%-10d\t",ar[i][2]);
}
while( total--)
{
printf("\n\n%-14d\t",tcno+1);
i=0;
while( i< col)
{
if(i == var_count)
{
switch( tcno%6 )
{
case 1: printf("%-10d\t",ar[i][0]-1);
break;
case 2: printf("%-10d\t",ar[i][0]);
break;
case 3: printf("%-10d\t",ar[i][0]+1);
break;
case 4: printf("%-10d\t",ar[i][1]-1);
break;
case 5: printf("%-10d\t",ar[i][1]);
break;
case 0: printf("%-10d\t",ar[i][1]+1);
break;
}// end switch
}//end if
else
{
printf("%-10d\t",ar[i][2]);
}
i++;
}//end while
if( tcno%6==0 )
{
var_count++;
}
tcno++;
}
getch();
return 0;
}
PROGRAM 3-WORST
CASE TESTING
#include<stdio.h>
#include<math.h>
int main()
{
int n=2,i=0,j,k,total,tcno=0,col,var_count=0;
int ar[2][5]; //Assuming variables are 3
col=n;
while(n)
{
printf("\nEnter the range of variable %d :",i+1);
printf("\nMINIMUM: ");
scanf("%d",&ar[i][0]);
printf("MAXIMUM: ");
scanf("%d",&ar[i][4]);
ar[i][2]=(ar[i][0]+ar[i][4])/2;
ar[i][1]=ar[i][0]+1;
ar[i][3]=ar[i][4]-1;
n--;
i++;
}
//end while
printf("\n\nTEST CASES according to WORST CASE TESTING are:\n\n");
printf("TEST CASE No. \t");
while(i)
{
printf("Variable %d \t",n+1);
n++;
i--;
} //end while
for( i=0 ; i<5 ; i++)
for( j=0 ; j<5 ; j++)
{
printf("\n\n%-14d\t",tcno+1);
tcno++;
printf("%-10d\t%-10d",ar[0][i],ar[1][j]);
}
getch();
return 0;
}
while(i)
{
printf("Variable %d \t",n+1);
n++;
i--;
} //end while
for( i=0 ; i<7 ; i++)
for( j=0 ; j<7 ; j++)
{
printf("\n\n%-14d\t",tcno+1);
tcno++;
printf("%-10d\t%-10d\t",ar[0][i],ar[1][j]);
getch();
return 0;
}
generateClasses();
cout<<"\nInput Classes...";
for(i=0;i<20;i++)
cout<<"\nI"<<i<<": "<<inputClass[i];
cout<<"\n\nOutput Classes...";
for(i=0;i<4;i++)
cout<<"\nO"<<i<<": "<<outputClass[i];
cout<<"\n\nTest Cases...";
cout<<"\n+"; for(int i=0;i<71;i++) cout<<"-"; cout<<"+";
cout<<"\n|\t\t Input\t\t\t| Expected\t\t|";
cout<<"\n+"; for(int i=0;i<71;i++) cout<<"-"; cout<<"+";
cout<<"\n|\ta\t\tb\t\tc\t| Output\t\t|";
cout<<"\n+"; for(int i=0;i<71;i++) cout<<"-"; cout<<"+\n";
for(int i=0;i<24;i++)
{
for(int j=0;j<3;j++)
{
if(j==0) cout<<"|";
cout<<"\t"<<testCases[i][j]<<"\t|";
}
int expOut=triangle(testCases[i],min,max);
if(expOut<0)
cout<<" Invalid input\t";
else cout<<" "<<outputClass[expOut];
cout<<"\t|"<<endl;
}
cout<<"+";for(int i=0;i<71;i++) cout<<"-"; cout<<"+";
cout<<"\n>>No. of Test Cases =
"<<sizeof(inputClass)/sizeof(inputClass[0]) +
sizeof(outputClass)/sizeof(outputClass[0]);
}
int main()
{
int min[3], max[3];
for(int i=0;i<3;i++)
{
cout<<"Enter min & max value of vertex "<<i+1<<" : ";
cin>>min[i]>>max[i];
}
equivalenceTesting(min,max);
return 0;
}