8/8/2019 SEPROGRAMS
1/13
BLACK BOX TESTING
BOUNDARY VALUE TESTING
Consider a program for the determination of the nature of roots of a quadratic
equation. Its input is a triple of positive integers (say a,b,c) and values may be
from interval [0,100]. The program output may have one of the following words.
[Not a quadratic equation; Real roots; Imaginary roots; Equal roots]
Design the boundary value test cases.
Solution
Quadratic equation will be of type:
ax2+bx+c=0
Roots are real if (b2-4ac)>0
Roots are imaginary if (b2-4ac)
8/8/2019 SEPROGRAMS
2/13
8/8/2019 SEPROGRAMS
3/13
BLACK BOX TESTING
EQUIVALENCE CLASS TESTING
Consider the program for the determination of nature of roots of a quadratic
equation. Identify the equivalence class test cases for output and input domains.
Solution
Output domain equivalence class test cases can be identified as follows:
O1={:Not a quadratic equation if a = 0}
O1={:Real roots if (b2-4ac)>0}
O1={:Imaginary roots if (b2-4ac)
8/8/2019 SEPROGRAMS
4/13
We may have another set of test cases based on input domain.
I1= {a: a = 0}
I2= {a: a < 0}
I3= {a: 1 a 100}
I4= {a: a > 100}
I5= {b: 0 b 100}
I6= {b: b < 0}
I7= {b: b > 100}
I8= {c: 0 c 100}
I9= {c: c < 0}
I10={c: c > 100}
8/8/2019 SEPROGRAMS
5/13
//Calculation of effort and development in a COCOMO model
#include#include#include
void organic(int K){float E,D;E=2.4*(K^1.05);D=2.5*(E^0.38);printf("effort and development of organic model is %d,%d",E,D);}
void semidetached(int L){float E,D;E=3.0*(L^1.12);D=2.5*(E^0.35);printf("effort and development of semidetached model is %d,%d",E,D);}
void embedded(int C){float E,D;E=3.6*(C^1.20);
D=2.5*(E^0.32);printf("effort and development of embedded model is %d,%d",E,D);}
void main(){ int KLOC;printf("enter size of the software development:");scanf("%d",KLOC);printf("organic mode");organic(KLOC);
printf("semidetached mode");semidetached(KLOC);printf("embedded mode");embedded(KLOC);getch();
}
8/8/2019 SEPROGRAMS
6/13
//PROGRAM TO IMPLEMENT FUNCTION POINT ANALYSIS
#include#includevoid main()
{int f_ip[3];int f_op[3];int f_inq[3];int f_ilf[3];int f_eif[3];int f_ufp=0;int r[14];int i,f;float caf,fp;clrscr();printf("enter number of lowest inputs\n");
scanf("%d",f_ip[0]);printf("enter number of average inputs\n");scanf("%d",f_ip[1]);printf("enter number of high inputs\n");scanf("%d",f_ip[2]);printf("enter number of low outputs\n");scanf("%d",f_op[0]);printf("enter number of average outputs\n");scanf("%d",f_op[1]);printf("enter number of high outputs\n");scanf("%d",f_op[2]);printf("enter number of low inquiries\n");
scanf("%d",f_inq[0]);printf("enter number of average inquiries\n");scanf("%d",f_inq[1]);printf("enter number of high inquiries\n");scanf("%d",f_inq[2]);printf("enter number of low internal logical files\n");scanf("%d",f_ilf[0]);printf("enter number of average internal logical files\n");scanf("%d",f_ilf[1]);printf("enter number of high internal logical files\n");scanf("%d",f_ilf[2]);printf("enter the number of low external interface files\n");scanf("%d",f_eif[0]);printf("enter the number of average external interface files\n");scanf("%d",f_eif[1]);printf("enter the number of high external interface files\n");scanf("%d",f_eif[2]);
8/8/2019 SEPROGRAMS
7/13
f_ufp =((f_ip[0]*3)+(f_ip[1]*4)+(f_ip[2]*6)+(f_op[0]*4)+(f_op[1]*5)+(f_op[2]*7)+(f_inq[0]*3)+(f_inq[1]*4)+(f_inq[2]*6)+(f_ilf[0]*7)+(f_ilf[1]*10)+(f_ilf[2]*15)+(f_eif[0]*5)+(f_eif[1]*7)+(f_eif[2]*10));
printf("\nunadjusted function point = %d", f_ufp);printf("\ngive ratings for factors\n0. no influence\t1.incidental\t2. moderate\t3. average\t4. significant\t5.essential\n");printf("\n\n does system require reliable backup and recovery\n");scanf("%d", r[0]);printf("is data communication required\n");scanf("%d", r[1]);printf("are there distributed processing functions\n");scanf("%d",r[2]);printf("is performance critical\n");
scanf("%d",r[3]);printf("will system run in an existing heavily utilized operationalenvironment\n");scanf("%d",r[4]);printf("does system require online data entry\n");scanf("%d",r[5]);printf("input transaction over multiple screens\n");scanf("%d",r[6]);printf("are master files updated on line\n");scanf("%d",r[7]);printf("is i/ps, o/ps, files, inquiries complex\n");scanf("%d", r[8]);
printf("is internal processing complex\n");scanf("%d", r[9]);printf("is code reusable\1");scanf("%d",r[10]);printf("are conversions and instll. included in design\n");scanf("%d",r[11]);printf("is system designed for multiple instll. in diff. orgs.\n");scanf("%d",r[12]);printf("is app. designed to facilitate change and ease of use byuser\n");scanf("%d",r[13]);for(i=0;i
8/8/2019 SEPROGRAMS
8/13
//PROGRAM TO FIND THE LINES OF CODE(LOC) IN THE GIVEN
FILE.
#include
#include#include#includeFILE *fp;void main(){char name[10],ch;int count=0,fl=0,f1,f2=0,fn=0;clrscr();printf("Enter the file name:\t");scanf("%s",name);fp=fopen(name,"r");if(fp==NULL){printf("Error- File does not exist");getch();exit(0);}while(!feof(fp)){ fscanf(fp,"%c",&ch);
switch(ch){case '/': fl=1;
if (f2==1)f2=0;
break;case '*': if(fl==1)
f2=1;break;case '\n': if(f2==0&&fn==0)
{++count;}fn=1;
break;default : fl=0,fn=0;}}
printf("\nNumbers of line are -\t%d",count+1);getch();fclose(fp);}
8/8/2019 SEPROGRAMS
9/13
WHITE BOX TESTING
Consider a program given in Fig.20 for the classification of a triangle. Its input is a triple of
positive integers (say a,b,c) from the interval [1,100]. The output may be [Scalene, Isosceles,
Equilateral, Not a triangle].
Draw the flow graph & DD Path graph. Also find the independent paths from the DD Path
graph.
Code of triangle classification problem
8/8/2019 SEPROGRAMS
10/13
8/8/2019 SEPROGRAMS
11/13
Solution :
Flow graph of triangle problem is:
8/8/2019 SEPROGRAMS
12/13
The mapping table for DD path graph is:
8/8/2019 SEPROGRAMS
13/13
DD Path graph is:
Independent paths are:
(i) ABFGNPQR
(ii) ABFGNOQR
(iii) ABCEGNPQR
(iv) ABCDEGNOQR
(v) ABFGHIMQR
(vi) ABFGHJKMQR
(vii) ABFGHJMQR