Software Testing Lab Manual
Software Testing Lab Manual
Design and develop a program in a language of your choice to solve the triangle problem defined as follows: Accept
three integers which are supposed to be the three sides of a triangle and determine if the three values represent an
equilateral triangle, isosceles triangle, scalene triangle, or they do not form a triangle at all. Assume that the upper
limit for the size of any side is 10. Derive test cases for your program based on boundary-value analysis, execute the
test cases and discuss the results.
#include<stdio.h>
#include<conio.h>
int main( )
{
int a,b,c,c1,c2,c3;
do
{
printf("enter the sides of triangle\n");
scanf("%d%d%d",&a,&b,&c);
c1=((a>=1) && (a<=10));
c2=((b>=1) && (b<=10));
c3=((c>=1) && (c<=10));
if(!c1)
printf("value of a is out of range");
if(!c2)
printf("value of b is out of range");
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 1
15ISL67 Software Testing Lab
if(!c3)
printf("value of c is out of range");
}while(!c1 || !c2 || !c3);
if((a+b)>c && (b+c)>a && (c+a)>b)
{
if(a==b && b==c)
printf("Triangle is equilateral\n");
else if(a!=b && b!=c && c!=a)
printf("Triangle is scalene\n");
else
printf("Triangle is isosceles\n");
}
else
printf("Triangle cannot be formed \n");
getch( );
return 0;
}
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 2
15ISL67 Software Testing Lab
Considering Triangle program, we have three variables a, b and c. Each variables value ranges from 1 to 10.
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 3
15ISL67 Software Testing Lab
Inputs
Test
Description Output Comments
cases A B C
BVA 5 Enter the values of a(nom),b(nom) and c(max) 5 5 10 Triangle cannot be formed Valid
BVA 9 Enter the values of a(nom),b(max) and c(nom) 5 10 5 Triangle cannot be formed Valid
BVA 13 Enter the values of a(max),b(nom) and c(nom) 10 5 5 Triangle cannot be formed Valid
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 4
15ISL67 Software Testing Lab
Design, develop, code and run the program in any suitable language to solve the commission problem. Analyse it
from the perspective of boundary value testing, derive different test cases, execute these test cases and discuss the
test results.
#include<stdio.h>
#include<conio.h>
int main()
{
int c1,c2,c3,temp;
int locks,stocks,barrels,totallocks,totalstocks,totalbarrels;
float lockprice,stockprice,barrelprice,locksales,stocksales,barrelsales,sales,com;
lockprice=45.0;
stockprice=30.0;
barrelprice=25.0;
totallocks=0;
totalstocks=0;
totalbarrels=0;
clrscr();
printf("Enter the number of locks and to exit press -1\n");
scanf("%d",&locks);
while(locks != -1)
{
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 5
15ISL67 Software Testing Lab
c1=(locks<=0 || locks>70);
printf("\nEnter the number of stocks and barrels\n");
scanf("%d %d",&stocks,&barrels);
c2=(stocks<=0 || stocks>80);
c3=(barrels<=0 || barrels>90);
if(c1)
printf("\nValue of locks are not in the range of 1....70\n");
else
{
temp=totallocks+locks;
if(temp>70)
printf("New totallocks = %d not in the range of 1....70\n",temp);
else
totallocks=temp;
}
printf("Total locks = %d",totallocks);
if(c2)
printf("\n Value of stocks not in the range of 1....80\n");
else
{
temp=totalstocks+stocks;
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 6
15ISL67 Software Testing Lab
if(temp>80)
printf("\nNew total stocks = %d not in the range of 1....80",temp);
else
totalstocks=temp;
}
printf("\nTotal stocks = %d",totalstocks);
if(c3)
printf("\n Value of barrels not in the range of 1....90\n");
else
{
temp=totalbarrels+barrels;
if(temp>90)
printf("\nNew total barrels = %d not in the range of 1....90\n",temp);
else
totalbarrels=temp;
}
printf("\nTotal barrels=%d", totalbarrels);
printf("\nEnter the number of locks and to exit press -1\n");
scanf("%d",&locks);
}
printf("\n Total locks = %d",totallocks);
prin tf("\n Total stocks = %d",totalstocks);
printf("\n Total barrels = %d",totalbarrels);
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 7
15ISL67 Software Testing Lab
locksales=totallocks*lockprice;
stocksales=totalstocks*stockprice;
barrelsales=totalbarrels*barrelprice;
sales=locksales+stocksales+barrelsales;
printf("\n Total sales = %f",sales);
if(sales>1800)
{
com=0.10*1000;
com=com+(0.15*800);
com=com+0.20*(sales-1800);
}
else if(sales>1000)
{
com=0.10*1000;
com=com+0.15*(sales-1000);
}
else
com=0.10*sales;
printf("\nCommission = %f",com);
getch();
return 0;
}
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 8
15ISL67 Software Testing Lab
Considering Commission program, we have three input variables lock, stock and barrels.
Range of value for locks= 1-70, stocks= 1-80 and barrels= 1-90
Considering output variable sales we have 3 slots for calculating commission. i.e., if sales are below 1000, com is
10%, if sales are 1001 to 1800 then com is 15% and if sales are greater than 1801, com is 20%.
2,1,1 9,10,10
1-1000 1,1,1 1,2,1 5,5,5 10,9,10 10,10,10
1,1,2 10,10,9
11,10,10 12,10,10 17,18,18
1001-1800 10,11,10 10,12,10 14,14,14 18,17,18 18,18,18
10,10,11 10,10,12 18,18,17
19,18,18 20,18,18 69,80,90
1801- above 18,19,18 18,20,18 48,48,48 70,79,90 70,80,90
18,18,19 18,18,20 70,80,89
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 9
15ISL67 Software Testing Lab
Test cases for commission program using INPUT Boundary value analysis
Test Inputs Output Comm
cases
Description ents
Locks Stocks Barrels Sales Com
BVA1 Enter the values for locks(nom), stocks(nom) and barrels(min) 35 40 1 2800 420 Valid
BVA2 Enter the values for locks(nom), stocks(nom) and barrels(min+) 35 40 2 2825 425 Valid
BVA3 Enter the values for locks(nom), stocks(nom) and barrels(nom) 35 40 45 3900 640 Valid
BVA7 Enter the values for locks(nom), stocks(min+) and barrels(nom) 35 2 45 2760 412 Valid
BVA10 Enter the values for locks(min), stocks(nom) and barrels(nom) 1 40 45 2370 334 Valid
BVA11 Enter the values for locks(min+), stocks(nom) and barrels(nom) 2 40 45 2415 343 Valid
BVA12 Enter the values for locks(max-), stocks(nom) and barrels(nom) 69 40 45 5430 946 Valid
BVA13 Enter the values for locks(max), stocks(nom) and barrels(nom) 70 40 45 5475 955 Valid
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 10
15ISL67 Software Testing Lab
Test cases for commission program using OUTPUT Boundary value analysis
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 11
15ISL67 Software Testing Lab
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 12
15ISL67 Software Testing Lab
Design, develop, code and run the program in any suitable language to implement the NextDate function. Analyze it
from the perspective of boundary value testing, derive different test cases, execute these test cases and discuss the
test results.
#include<stdio.h>
int check(int day,int month)
{
if((month==4||month==6||month==9 ||month==11) && day==31)
return 1;
else
return 0;
}
int isleap(int year)
{
if((year%4==0 && year%100!=0) || year%400==0)
return 1;
else
return 0;
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 13
15ISL67 Software Testing Lab
int main()
{
int day,month,year,tomm_day,tomm_month,tomm_year;
char flag;
do
{
flag='y';
printf("\nenter the today's date in the form of dd mm yyyy\n");
scanf("%d%d%d",&day,&month,&year);
tomm_month=month;
tomm_year= year;
if(day<1 || day>31)
{
printf("value of day, not in the range 1...31\n");
flag='n';
}
if(month<1 || month>12)
{
printf("value of month, not in the range 1....12\n");
flag='n';
}
else if(check(day,month))
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 14
15ISL67 Software Testing Lab
{
printf("value of day, not in the range day<=30");
flag='n';
}
if(year<=1812 || year>2015)
{
printf("value of year, not in the range 1812.......2015\n");
flag='n';
}
if(month==2)
{
if(isleap(year) && day>29)
{
printf("invalid date input for leap year");
flag='n';
}
else if(!(isleap(year))&& day>28)
{
printf("invalid date input for not a leap year");
flag='n';
}
}
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 15
15ISL67 Software Testing Lab
}while(flag=='n');
switch (month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:if(day<31)
tomm_day=day+1;
else
{
tomm_day=1;
tomm_month=month+1;
}
break;
case 4:
case 6:
case 9:
case 11: if(day<30)
tomm_day=day+1;
else
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 16
15ISL67 Software Testing Lab
{
tomm_day=1;
tomm_month=month+1;
}
break;
else
tomm_year=year+1;
}
break;
case 2:
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 17
15ISL67 Software Testing Lab
if(day<28)
tomm_day=day+1;
else if(isleap(year)&& day==28)
tomm_day=day+1;
else if(day==28 || day==29)
{
tomm_day=1;
tomm_month=3;
}
break;
}
printf("next day is : %d %d %d",tomm_day,tomm_month,tomm_year);
return 0;
}
Considering Date program, we have three variables day, month and year.
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 18
15ISL67 Software Testing Lab
Test Inputs
Description Output Comments
cases DD MM YY
BVA 3 Enter the values for day(nom),month(min) and year(nom) 15 6 1914 16/6/1914 Valid
Enter the values for day(nom),month(nom) and year(max-)
BVA4 15 6 2014 16/6/2014 Valid
Enter the values for day(nom),month(nom) and year(max)
BVA5 15 6 2015 16/6/2015 Valid
BVA6 Enter the values for day(nom),month(min) and year(nom) 15 1 1914 16/1/1914 Valid
BVA7 Enter the values for day(nom),month(min+) and year(nom) 15 2 1914 16/2/1914 Valid
BVA8 Enter the values for day(nom),month(max-) and year(nom) 15 11 1914 16/11/1914 Valid
BVA9 Enter the values for day(nom),month(max) and year(nom) 15 12 1914 16/12/1914 Valid
BVA10 Enter the values for day(min),month(nom) and year(nom) 1 6 1914 2/6/1914 Valid
BVA12 Enter the values for day(max-),month(nom) and year(nom) 30 6 1914 1/7/1914 Valid
Day out of range
BVA13 Enter the values for day(max),month(nom) and year(nom) 31 6 1914 for the month
Valid
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 19
15ISL67 Software Testing Lab
Design and develop a program in a language of your choice to solve the triangle problem defined as follows: Accept
three integers which are supposed to be the three sides of a triangle and determine if the three values represent an
equilateral triangle, isosceles triangle, scalene triangle, or they do not form a triangle at all. Assume the upper limit
for the size of any side is 10. Derive test cases for your program based on equivalence class partitioning, execute the
test cases and discuss the results.
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c,c1,c2,c3;
do
{
printf("enter the sides of triangle\n");
scanf("%d%d%d",&a,&b,&c);
c1=((a>=1) && (a<=10));
c2=((b>=1) && (b<=10));
c3=((c>=1) && (c<=10));
if(!c1)
printf("value of a is out of range");
if(!c2)
printf("value of b is out of range");
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 20
15ISL67 Software Testing Lab
if(!c3)
printf("value of c is out of range");
}while(!c1 || !c2 || !c3);
if((a+b)>c && (b+c)>a && (c+a)>b)
{
if(a==b && b==c)
printf("triangle is equilateral\n");
else if(a!=b && b!=c && c!=a)
printf("triangle is scalene\n");
else
printf("triangle is isosceles\n");
}
else
printf("triangle cannot be formed \n");
getch( );
return 0;
}
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 21
15ISL67 Software Testing Lab
Inputs Expected
Test cases Description Comments
A B C output
Enter the valid values for a, b and c from output
WN/SN1 5 5 5 Equilateral Valid
equivalence classes.
Enter the valid values for a, b and c from output
WN/SN2 equivalence classes.
5 5 3 Isosceles Valid
Enter the valid values for a, b and c from output Triangle cannot
WN/SN4 10 1 1 Valid
equivalence classes. be formed
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 22
15ISL67 Software Testing Lab
Weak Robust
Strong Robust
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 23
15ISL67 Software Testing Lab
Enter the valid values for b and c from output Values of a is not Triangle cannot be
SR 7 equivalence classes and invalid value for a.
-1 5 5 in range formed
Enter the valid values for a and c from output Values of b is not Triangle cannot be
SR 8 equivalence classes and invalid value for b.
10 -1 10 in range formed
Enter the valid values for a and b from output Values of c is not Triangle cannot be
SR 9 equivalence classes and invalid value for c.
7 6 -1 in range formed
Enter the valid values for b and c from output Values of a is not Triangle cannot be
SR 10 equivalence classes and invalid value for a.
11 5 4 in range formed
Enter the valid values for a and c from output Values of b is not Triangle cannot be
SR 11 equivalence classes and invalid value for b.
2 11 3 in range formed
Enter the valid values for a and b from output Values of c is not Triangle cannot be
SR 12 equivalence classes and invalid value for c.
3 4 11 in range formed
Values of a, b and
Triangle cannot be
SR 13 Enter the invalid value for a, b and c. 11 11 11 c are not in a
formed
range
Values of a, b and
Triangle cannot be
SR 14 Enter the invalid value for a, b and c. -1 -1 -1 c are not in a
formed
range
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 24
15ISL67 Software Testing Lab
Design, develop, code and run the program in any suitable language to solve the commission problem. Analyse it
from the perspective of equivalence class testing, derive different test cases, execute these test cases and discuss the
test results.
WN/SN2
Enter the value of locks=-1 and valid
-1 40 65 2825 425 valid
inputs for stocks and barrels For Program termination
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 25
15ISL67 Software Testing Lab
Weak Robust
Strong Robust
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 26
15ISL67 Software Testing Lab
of 1..90
Enter the value of locks & stocks less than or 1125 118.75 Valid
SR 4 equal to zero and valid values for barrels.
-2 -1 45 Value of locks and stocks not in
the range 1..70 & 1..80 resp
Enter the value of locks and barrels less than 1200 130 Valid
SR 5 -2 40 -1 Value of locks and barrels not
or equal to zero and valid values for stocks.
in range of 1..70 & 1..80 resp
1575 186.25
Enter the value of stocks & barrels less than Value of stocks and barrels not Valid
SR 6 35 -1 -1 in range of 1..80 & 1..90 resp
or equal to zero and valid values for locks.
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 27
15ISL67 Software Testing Lab
Design, develop, code and run the program in any suitable language to implement the NextDate function. Analyze it
from the perspective of equivalence class value testing, derive different test cases, execute these test cases and
discuss the test results.
Inputs
Test cases Description Output Comments
DD MM YY
Enter valid values for day, month and year from
WN/SN1 12 2 1990 13/2/1990 Valid
equivalence classes.
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 28
15ISL67 Software Testing Lab
Weak Robust
Test Inputs
Description Output Comments
cases DD MM YY
Enter valid values for month and year from equivalence
WR1 classes and invalid value for day.
-1 6 1992 Day out of range Valid
Strong Robust
Test Inputs
Description Output Comments
cases DD MM YY
Enter valid values for month and year from equivalence
SR1 classes and invalid value for day.
-1 6 1992 Day out of range Valid
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 29
15ISL67 Software Testing Lab
Enter valid value for year from equivalence classes and Day, Month out of
SR4 invalid values for day and month.
-1 -1 1992 range
Valid
SR7 Enter valid values for month and year from equivalence
32 6 1992 Day out of range Valid
classes and invalid value for day.
SR8 Enter valid values for day and year from equivalence
classes and invalid value for month.
15 13 1992 Month out of range Valid
SR9 Enter valid values for day and month from equivalence
classes and invalid value for year.
15 6 2016 Year out of range Valid
SR10 Enter valid value for year from equivalence classes and Day, Month out of
invalid values for day and month.
32 13 1992 range
Valid
SR12 Enter valid value for day from equivalence classes and Month, Year out of
15 13 2016 Valid
invalid values for month and year. range
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 30
15ISL67 Software Testing Lab
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 31
15ISL67 Software Testing Lab
else
printf("triangle cannot be formed\n");
return 0;
}
R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11
C1: a<b+c F T T T T T T T T T T
C2: b<c+a -- F T T T T T T T T T
C3: c<a+b -- -- F T T T T T T T T
Conditions
C4: a=b -- -- -- T T F F F T T F
C5: b=c -- -- -- T F T F F T F T
C6: c=a -- -- -- T F F T F F T T
A1: Not a triangle x x x
Actions
A2: Equilateral x
A3: Isosceles x x x
A4: Scalene x
A5: Impossible x x x
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 32
15ISL67 Software Testing Lab
Inputs
Test Description
Output Comments
cases A B C
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 33
15ISL67 Software Testing Lab
RULES R1 R2 R3 R4 R5 R6 R7 R8 R9
C4: locks = -1 T T T T T T T T T
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 34
15ISL67 Software Testing Lab
IDT2
Enter the valid no. of locks and invalid
20 81 91 900 90 valid
values for stocks and barrels Invalid no.of stocks and barrels
IDT3
Enter the valid values for locks, stocks and
20 20 96 1500 175 valid
invalid value for barrels Invalid no.of barrels
IDT4
Enter the valid values for locks and barrels
20 -1 20 1400 160 valid
and invalid value for stocks Invalid no.of stocks
Enter the valid values for locks, stocks and 2000 260
IDT5 barrels
20 20 20 Calculates sales and valid
commission
Enter the invalid values for locks, stocks and 0 0
IDT6 barrels
-2 81 -1 Invalid no.of locks, Stocks and valid
barrels.
IDT7
Enter the valid value for stocks and invalid
-2 20 91 600 60 valid
values for locks and barrels Invalid no.of locks and barrels
IDT8
Enter invalid input for locks and stocks and
71 -1 20 500 50 valid
valid input for barrels Invalid no.of locks and stocks
IDT9
Enter the invalid value for locks and valid
-3 20 20 1100 115 valid
values for stocks and barrels Invalid no.of locks
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 35
15ISL67 Software Testing Lab
RULES R1 R2 R3
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 36
15ISL67 Software Testing Lab
Design, develop, code and run the program in any suitable language to solve the commission problem. Analyse it
from the perspective of dataflow testing, derive different test cases, execute these test cases and discuss the test
results.
1 #include<stdio.h>
2 #include<conio.h>
3 int main()
4 {
5 int c1,c2,c3,temp;
6 int locks,stocks,barrels,totallocks,totalstocks,totalbarrels;
7 float lockprice,stockprice,barrelprice,locksales,stocksales,barrelsales,sales,com;
8 lockprice=45.0;
9 stockprice=30.0;
10 barrelprice=25.0;
11 totallocks=0;
12 totalstocks=0;
13 totalbarrels=0;
14 clrscr();
15 printf("Enter the number of locks and to exit press -1\n");
16 scanf("%d",&locks);
17 while(locks != -1)
18 {
19 c1=(locks<=0 || locks>70);
20 printf("\nEnter the number of stocks and barrels\n");
21 scanf("%d %d",&stocks,&barrels);
22 c2=(stocks<=0 || stocks>80);
23 c3=(barrels<=0 || barrels>90);
24 if(c1)
25 printf("\nValue of locks are not in the range of 1....70\n");
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 37
15ISL67 Software Testing Lab
26 else
27 {
28 temp=totallocks+locks;
29 if(temp>70)
30 printf("New totallocks = %d not in the range of 1....70\n",temp);
31 else
32 totallocks=temp;
33 }
34 printf("Total locks = %d",totallocks);
35 if(c2)
36 printf("\n Value of stocks not in the range of 1....80\n");
37 else
38 {
39 temp=totalstocks+stocks;
40 if(temp>80)
41 printf("\nNew total stocks = %d not in the range of 1....80",temp);
42 else
43 totalstocks=temp;
44 }
45 printf("\nTotal stocks = %d",totalstocks);
46 if(c3)
47 printf("\n Value of barrels not in the range of 1....90\n");
48 else
49 {
50 temp=totalbarrels+barrels;
51 if(temp>90)
52 printf("\nNew total barrels = %d not in the range of 1....90\n",temp);
53 else
54 totalbarrels=temp;
55 }
56 printf("\nTotal barrels=%d", totalbarrels);
57 printf("\nEnter the number of locks and to exit press -1\n");
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 38
15ISL67 Software Testing Lab
58 scanf("%d",&locks);
59 }
60 printf("\n Total locks = %d",totallocks);
61 printf("\n Total stocks = %d",totalstocks);
62 printf("\n Total barrels = %d",totalbarrels);
63 locksales=totallocks*lockprice;
64 stocksales=totalstocks*stockprice;
65 barrelsales=totalbarrels*barrelprice;
66 sales=locksales+stocksales+barrelsales;
67 printf("\n Total sales = %f",sales);
68 if(sales>1800)
69 {
70 com=0.10*1000;
71 com=com+(0.15*800);
72 com=com+0.20*(sales-1800);
73 }
74 else if(sales>1000)
75 {
76 com=0.10*1000;
77 com=com+0.15*(sales-1000);
78 }
79 else
80 com=0.10*sales;
81 printf("\nCommission = %f",com);
82 getch();
83 return 0;
84 }
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 39
15ISL67 Software Testing Lab
lockprice 8 63
stockprice 9 64
barrelprice 10 65
stocks 21 22,39
barrels 21 23,50
locksales 63 66
stocksales 64 66
barrelsales 65 66
Sales 66 67,68,72,74,77,80
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 40
15ISL67 Software Testing Lab
Variables
Test (beginning DC
Description DU paths
id ,end path ?
nodes)
Check for lockprice variable 8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,26,27,28,29,
1 DEF(ocklprice,8) <8,63> 31,32,33,34,35,37,38,39,40,42,43,44,45,46,48,49 YES
And USE(lockprice,63) ,50,51,53,54,55,56,57,58,59,60,61,62,63
11,12,13,14,15,16,17,18,19,20,21,22,23,24,26,27,28,29,31,32,33,34
<11,34> NO
Check for totallocks
variable 11,12,13,14,15,16,17,18,19,20,21,22,23,24,26,27,28,29,31,32,33,34,35,37
<11,60> NO
4 DEF(totallocks,11,32) ,38,39 ,40,42,43 ,44,45,46,48,49,50,51,53,54,55,56,57,58,59,60
And USE(totallocks,
28,34,60,63)
11,12,13,14,15,16,17,18,19,20,21,22,23,24,26,27,28,29,31,32,33,34,35,37
<11,63> ,38,39 ,40,42,43 ,44,45,46,48,49,50,51,53,54,55,56,57,58,59,60,61,62,63 NO
32,33,34,35,37,38,39,40,42,43,44,45,46,48,49,50,51,53,54,55,56,57,58,17
<32,28> YES
,18,19,20,21,22,23,24,26,27,28
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 41
15ISL67 Software Testing Lab
<32,34> 32,33,34
YES
<32,60> 32,33,34,35,37,38,39,40,42,43,44,45,46,48,49,50,51,53,54,
55,56,57,58,59, 60 YES
<32,63> 32,33,34,35,37,38,39,40,42,43,44,45,46,48,49,50,51,
YES
53,54,55,56,57,58,59 ,60,61,62,63
12,13,14,15,16,17,18,19,20,21,22,23,24,26,27,28,29,31
<12,39> YES
,32,33,34,35,37,38,39
<12,45> NO
12,13,14,15,16,17,18,19,20,21,22,23,24,26,27,28,29
,31,32,33,34,35,37,38,39,40,42,43,44,45
<12,61>
Check for totalstocks 12,13,14,15,16,17,18,19,20,21,22,23,24,26,27,28,29
variable NO
,31,32,33,34,35,37,38,39,40,42,43,44,45,46,48,49
5 DEF(totalstocks,12,43)
,50,51,53,54,55,56,57,58,59,60,61
And USE(totalstocks,
39,45,61,64)
12,13,14,15,16,17,18,19,20,21,22,23,24,26,27,28,29
<12,64> NO
,31,32,33,34,35,37,38,39,40,42,43,44,45,46,48,49
,50,51,53,54,55,56,57,58,59,60,61,62,63,64
<43,45> YES
43,44,45
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 42
15ISL67 Software Testing Lab
YES
<43,61> 43,44,45,46,48,49,50,51,53,54,55,56,57,58,59,60,61
YES
<43,64> 43,44,45,46,48,49,50,51,53,54,55,56,57,58,59,60,61,62,63,64
<13,56> 13,14,15,16,17,18,19,20,21,22,23,24,26,27,28,29 NO
,31,32,33,34,35,37,38,39,40,42,43,44,45,46,48,49
,50,51,53,54,55,56
<13,62> 13,14,15,16,17,18,19,20,21,22,23,24,26,27,28,29, NO
Check for totalbarrels 31,32,33,34,35,37,38,39,40,42,43,44,45,46,48,49,
variable
50,51,53,54,55,56,57,58,59,60,61,62
6 DEF(totalbarrels,13,54)
And USE(totalbarrels,
50,56,62,65) <13,65> 13,14,15,16,17,18,19,20,21,22,23,24,26,27,28,29,
31,32,33,34,35,37,38,39,40,42,43,44,45,46,48,49, NO
50,51,53,54,55,56,57,58,59,60,61,62,63,64,65
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 43
15ISL67 Software Testing Lab
And USE(barrelsales,66)
<66,67> 66,67 YES
Check for sales variable
DEF(sales,66) <66,68> 66,67,68 YES
13 And <66,72> 66,67,68,69,70,71,72 YES
USE(sales,67,68,72,74,77,8 <66,74> 66,67,68,74 YES
0)
<66,77> 66,67,68,74,75,76,77 YES
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 44
15ISL67 Software Testing Lab
<70,71> 70,71 NO
<70,72> 70,71,72 NO
<70,81> 70,71,72,73,81 NO
Check for commission <71,72> 71,72 NO
variable
<71,81> 71,72,73,81 NO
14 DEF(com,70,71,72,76,77,8
0) <72,81> 72,73,81 YES
And USE(com,71,72,77,81) <76,77> 76,77 NO
<76,81> 76,77,78,81 NO
<77,81> 77,78,81 YES
<80,81> 80,81 YES
Note
In above Du-Paths, some paths like
<70,77>,<71,71>,<71,77>,<72,71>,<72,72>,<72,77>,<76,71>,<76,72>,<77,71>,<77,71>,<77,77>,
<80,70>,<80,72>,<80,77>,<80,77> are not possible to be formed. So they are not considered in above table.
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 45
15ISL67 Software Testing Lab
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 46
15ISL67 Software Testing Lab
int main()
{
int a[20],key,i,n,succ;
printf("Enter the n value up to max of 20");
scanf("%d",&n);
if(n>0)
{
printf("enter the elements in ascending order\n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("enter the key element to be searched\n");
scanf("%d",&key);
succ=binsrc(a,0,n-1,key);
if(succ>=0)
printf("Element found in position = %d\n",succ+1);
else
printf("Element not found \n");
}
else
printf("Number of element should be greater than zero\n");
return 0;
}
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 47
15ISL67 Software Testing Lab
Program Graph
1 2 3 4
14
7
8 9
11
15
10
12
13
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 48
15ISL67 Software Testing Lab
DD Path graph
NODES DD-paths
1-3 A
4 B A
5,6 C
7 D
B
8 I
9 E
10 G C
11,12 F
13 H
14 J
15 K D
J
I E
K G F
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 49
15ISL67 Software Testing Lab
Baseline Path: A BC D E FH B J K.
Nodes which are bold and large are decision nodes. Now start flipping each decision node.
Flipping at B : A B J K.
Flipping at D : A B C D I K.
Flipping at E : A B C D E G H B J.
Cyclomatic Complexity
V(G) =e-n+2p
Where,
e is number of edges in DD-Path graph.
n is number of nodes in DD-Path graph.
p is number of regions connected.(always 1)
Number of linearly independent paths for a given graph G = 13-11+2(1)= 4 Test cases
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 50
15ISL67 Software Testing Lab
Test Input
Cases Description Expected Output Comment
N Array elements Key
Infeasible because low>high
Enter the basis path consisting of 2 {5,10} 4 means from B to J then K which
TC1 Valid
all decision nodes ABCDEFHBJK. 1 {10} 5 means no elements left which is
not true in any case.
Infeasible because low>high
Enter the basis path consisting of means from B to J then K which
TC2 0 --------- ---- Invalid
all decision nodes ABJK. means no elements left which is
not true in any case.
2 {5,10} 10 Element found in position 2
Enter the basis path consisting of
TC3 all decision nodes ABCDIK.
3 {5,10,15} 10 Element found in position 2 Valid
5 {5,10,15,20,25} 15 Element found in position 3
Infeasible because low>high
Enter the basis path consisting of 2 {5,10} 15 means from B to J then K which
TC4 Invalid
all decision nodes ABCDEGHBJK. 1 {10} 12 means no elements left which is
not true in any case.
Note
Path B J K indicates fail of while (low<=high) condition. Because when there is one element in the array, then
low will b equal to high (i.e., low=high). Similarly when there are more than one elements in the array low will be
greater than high (i.e., low>high). So low>high means there no elements in the array. So in above table paths
containing B J K are considered as infeasible.
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 51
15ISL67 Software Testing Lab
#include<stdio.h>
A. 1 void quicksort(int x[10],int first,int last)
B. 2 {
3 int temp,pivot,i,j;
C. 4 if(first<last)
D. 5 {
6 pivot=first;
7 i=first;
8 j=last;
E. 9 while(i<j)
F. 10 {
G. 11 while(x[i]<=x[pivot] && i<last)
H. 12 i++;
I. 13 while(x[j]>x[pivot])
J. 14 j--;
K. 15 if(i<j)
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 52
15ISL67 Software Testing Lab
L. 16 {
17 temp=x[i];
18 x[i]=x[j];
19 x[j]=temp;
20 }
M. 21 }
N. 22 temp=x[pivot];
23 x[pivot]=x[j];
24 x[j]=temp;
25 quicksort(x,first,j-1);
P. 26 quicksort(x,j+1,last);
Q. 27 }
O. 28 }
int main()
{
int a[20],i,key,n;
printf("enter the size of the array max of 20 elements");
scanf("%d",&n);
if(n>0)
{
printf("enter the elements of the array");
for(i=0;i<n;i++)
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 53
15ISL67 Software Testing Lab
scanf("%d",&a[i]);
quicksort(a,0,n-1);
printf("the elements in the sorted array is:\n");
for(i=0;i<n;i++)
print f("%d\t",a[i]);
}
else
printf(“size of array is invalid\n”);
}
Cyclomatic Complexity
V(G) =e-n+2p
or
V(G) =e-n+p (for closed closed graph)
Where,
e is number of edges in DD-Path graph.
n is number of nodes in DD-Path graph.
p is number of regions connected.(always 1)
Number of linearly independent paths (Test cases) for a given graph G = 23-17+(1)
= 6+1
= 7 Test cases
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 54
15ISL67 Software Testing Lab
Program graph
1 2 3 4 5 6 7 8
28
9
26
10
22 11
27
12 13
23
14
24 15
21
16
25
17
18
19
20
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 55
15ISL67 Software Testing Lab
DD path graph
NODES DDPATHS B
1 A
2-3 B
4 C C N
5-8 D
9 E
10 F D
11 G
12 H
13 I
O E
14 J
15 K
F
16-20 L P
21 M
G
22-25 N
26 P I
27 Q Q H
28 O K
J
kk
M
kk
L kk
k
K
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 56
15ISL67 Software Testing Lab
Baseline Path: AB C D E F G I K M E N A B C O P A B C O.
Nodes which are bold and large are decision nodes. Now start flipping each decision node.
Flipping at C : A B C O.
Flipping at E : A B C D E N A B C O.
Flipping at G : A B C D E F G H G I K M E N A B C O.
Flipping at I : A B C D E F G I J I K M E N A B C O.
Flipping at K : A B C D E F G I K L M E N A B C O.
Flipping at P : A B C D E F G I K L M E N A B C O P A B C O.
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 57
15ISL67 Software Testing Lab
Enter the basis path consisting of all decision Infeasible because path from G to I means
TC5
nodes ABCDEFGIJIKMENABCO.
---- no elements in array.
Invalid
Enter the basis path consisting of all decision Infeasible because path from G to I means
TC6
nodes ABCDEFGIKLMENABCO.
---- no elements in array.
Invalid
Enter the basis path consisting of all decision Infeasible because path from G to I means
TC7
nodes ABCDEFGIKLMENABCOPABCO.
---- no elements in array.
Invalid
Note
If given array contains a single element, then first=last, if(first<last) condition is true indicates there are more
than one elements in the given array. Even when there will be single element While(x[i]<=x[pivot]&&i<last) condition
will get executed at least once, because x[i]=x[pivot] is also considered. So path there should be one path G to H
present for any feasible solution. So in above table paths containing G to I are all infeasible.
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 58
15ISL67 Software Testing Lab
Design ,develop ,code and run the program in any suitable language to implement an absolute letter grading
procedure, making suitable assumptions. Determine the basis paths and using them derive different cases , execute
these test cases and discuss the test results.
#include<stdio.h>
#include<conio.h>
A. 1 int main()
2{
3 float per;
4 char grade;
5 printf("enter the percentage\n");
6 scanf("%f",&per);
B. 7 if(per>=90)
C. 8 grade='a';
D. 9 else if((per>=80) && (per<90))
E. 10 grade='b';
F. 11 else if((per>=70) && (per<80))
G. 12 grade='c';
H. 13 else if((per>=60) && (per<70))
I. 14 grade='d';
J. 15 else grade='e';
K. 16 switch(grade)
L. 17 {
M. 18 case 'a':printf("excellent\n");
19 break;
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 59
15ISL67 Software Testing Lab
Cyclomatic Complexity
V(G) =e-n+2p
Where,
e is number of edges in DD-Path graph.
n is number of nodes in DD-Path graph.
p is number of regions connected.(always 1)
Number of linearly independent paths (Test cases) for a given graph G = 26-19+2(1)
= 7+2
= 9 Test cases
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 60
15ISL67 Software Testing Lab
Program graph 1 2 3 4 5 6
8 9
10 11
13
12
15
14
16
17
18 20 22 24 26
28
29
30
31
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 61
15ISL67 Software Testing Lab
DD path graph
A
Nodes DD-Paths
1-6 A B
7 B
C D
8 C
9 D
E F
10 E
11 F
G
H
12 G
13 H
I J
14 I
15 J
16 K
17 L K
18-19 M
20-21 N L
22-23 O
24-25 P M N O P Q
26-27 Q
28 R
R
29-31 S
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 62
15ISL67 Software Testing Lab
Finding Basis paths for Letter Grading program using McCabe’s method
Considering DD-Path graph of Absolute Letter grading program, Baseline path is formed by considering all
decision nodes as shown below.
Baseline Path: A B D F H J K L M R S.
Nodes which are bold and large are decision nodes. Now start flipping each decision node.
Flipping at B : A B C K L M R S.
Flipping at D : A B D E K L M R S.
Flipping at F : A B D F G K L M R S.
Flipping at H : A B D F H I K L M R S.
Flipping at L : A B D F H J K L N R S.
A B D F H J K L O R S.
A B D F H J K L P R S.
A B D F H J K L Q R S.
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 63
15ISL67 Software Testing Lab
Test Expected
Description Input Actual Output Comment
ID Output
Enter the basis path containing the Node J indicates grade „e‟ so case „e‟
TC1
decision nodes ABDFHJKLMRS 55 Satisfactory should be executed i.e., node Q. but Invalid
there is no Q in this path so Infeasible
Enter the basis path containing the
TC2
decision nodes ABCKLMRS 95 Excellent Excellent Valid
Enter the basis path containing the Node E indicates grade „b‟ so case „b‟
TC3
decision nodes ABDEKLMRS 85 Very good should be executed i.e., node N. but Invalid
there is no N in this path so Infeasible
Enter the basis path containing the Node F indicates grade „c‟ so case „c‟
TC4
decision nodes ABDFGKLMRS 75 Good should be executed i.e., node O. but Invalid
there is no O in this path so Infeasible
Enter the basis path containing the Node H indicates grade „d‟ so case „d‟
TC5
decision nodes ABDFHIKLMRS 65 Above average should be executed i.e., node P. but Invalid
there is no P in this path so Infeasible
Enter the basis path containing the Node J indicates grade „e‟ so case „e‟
TC6
decision nodes ABDFHJKLNRS 55 Satisfactory should be executed i.e., node Q. but Invalid
there is no Q in this path so Infeasible
Enter the basis path containing the Node J indicates grade „e‟ so case „e‟
TC7 decision nodes ABDFHJKLORS 55 Satisfactory should be executed i.e., node Q. but Invalid
there is no Q in this path so Infeasible
Enter the basis path containing the Node J indicates grade „e‟ so case „e‟
TC8
decision nodes ABDFHJKLPRS 55 Satisfactory should be executed i.e., node Q. but Invalid
there is no Q in this path so Infeasible
Enter the basis path containing the
TC9 decision nodes ABDFHJKLQRS 55 Satisfactory Satisfactory Valid
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 64
15ISL67 Software Testing Lab
In above table we got test cases containing only Excellent and satisfactory type outputs. As we have five types
of outputs in our program, three types of outputs (i.e., good, very good and above average) are left untested. So
for completeness we add three more tests for left out cases as shown below.
SHEIK IMRAN Asst Professor, Dept of IS&E, BIET, Dvg. For any queries Contact: 9916230456. Page 65