ST Lab Manual
ST Lab Manual
ST Lab Manual
1.1 OBJECTIVE
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.
1.3 DESIGN
ALGORITHM:
Step 1: Input a, b & c i.e three integer values which represent three sides of the triangle.
Step 2: if (a < (b + c)) and (b < (a + c)) and (c < (a + b) then do
step 3
else
print not a triangle. do step 6
Technique used: Boundary value analysis
1. Test Case design
For BVA problem the test cases can be generation depends on the output and the
constraints on the output. Here we least worried on the constraints on Input domain.
The maximum limit of each sides a, b, and c of the triangle is 10 units according to
requirement R4. So a, b and c lies between
0≤a≤10
0≤b≤10
0≤c≤10
Equivalence classes for a:
E1: Values less than 1.
E2: Values in the range.
E3: Values greater than 10.
From the above equivalence classes we can derive the following test cases using boundary value
analysis approach.
1.5TESTCASES
1.6 EXECUTION:
Execute the program and test the test cases in Table-1 against program and complete the table
with for Actual output column and Status column
Test Report:
1. No. of test cases Executed:
2. No. of Defects Raised:
3. No of test cases Passed:
4. No of test cases failed:
1.7 SNAPSHOTS
1. What is an error?
2. What is the use of testing software?
3. What are the types of software testing?
4. What is boundary value analysis?
5. What is white box testing and list the types of white box testing?
6. What is black box testing? What are the different black box testing techniques?
2.1 OBJECTIVE
Design, develop, code and run the program in any suitable language to solve the commission
Problem. Analyze it from the perspective of boundary value testing, derive different test cases,
execute these test cases and discuss the test results.
Locks- $45
Stocks- $30
Barrels- $25
The salesperson had to sell at least one complete rifle per month and production limits were
such that the most the salesperson could sell in a month was 70 locks, 80 stocks and 90 barrels.
After each town visit, the sales person sent a telegram to the Missouri gunsmith with the
number of locks, stocks and barrels sold in the town. At the end of the month, the salesperson
sent a very short telegram showing --1 lock sold. The gunsmith then knew the sales for the
month were complete and computed the salesperson‟s commission as follows:
On sales up to(and including) $1000= 10% On
the sales up to(and includes) $1800= 15% On
the sales in excess of $1800= 20%
The commission program produces a monthly sales report that gave the total number of locks,
stocks and barrels sold, the salesperson’s total dollar sales and finally the commission
2.3 DESIGN
ALGORITHM:
STEP12: exit
2.5 TESTCASES
Table-1: BVB Test case for Commission Problem
This is how we can apply BVA technique to create test cases for our Commission Problem.
2.6 EXECUTIONS
Execute the program and test the test cases in Table-1 against program and complete the table
with for Actual output column and Status column.
TEST REPORT:
1. No of TC‟s Executed:
2. No of Defects Raised:
3. No of TC‟s Pass:
4. No of TC‟s Failed:
2.7SNAPSHOTS:
1. What is Testing
2. What is fault? Name types of faults
3. What is commission problem?
4. What is boundary value analysis?
5. What is debugging?
3.1 OBJECTIVE
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.
Problem Definition: "Next Date" is a function consisting of three variables like: month, date
and year. It returns the date of next day as output. It reads current date as input date.
The constraints are
C1: 1 ≤ month ≤ 12
C2: 1 ≤ day ≤ 31
C3: 1812 ≤ year ≤ 2012.
If any one condition out of C1, C2 or C3 fails, then this function produces an output "value of
month not in the range 1...12".
Since many combinations of dates can exist, hence we can simply displays one message for this
function: "Invalid Input Date".
A very common and popular problem occurs if the year is a leap year. We have taken into
consideration that there are 31 days in a month. But what happens if a month has 30 days or
even 29 or 28 days?
A year is called as a leap year if it is divisible by 4, unless it is a century year. Century years are
leap years only if they are multiples of 400. So, 1992, 1996 and 2000 are leap years while 1900
is not a leap year.
3.3 DESIGN
Algorithm
STEP3:if DD < 31 then do STEP4 else if DD=31 do STEP5 else output(Invalid Date);
STEP7: if DD<30 then do STEP4 else if DD=30 do STEP5 else output(Invalid Date);
STEP8: if MM is 12
STEP11: if MM is 2
STEP19: exit
This is how we can apply BA technique to create test cases for our Next Date Problem.
3.6 EXECUTIONS
Execute the program and test the test cases in Table-1 against program and complete the table
with for Actual output column and Status column
4.1 Objective:
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 equivalence class partitioning, execute the test cases and discuss
the results.
R1. The system should accept 3 positive integer numbers (a, b, c) which represents 3 sides
of the triangle.
R2. Based on the input should determine if a triangle can be formed or not.
R3. If the requirement R2 is satisfied then the system should determine the type of the
triangle, which can be
• Equilateral (i.e. all the three sides are equal)
• Isosceles (i.e. two sides are equal)
• Scalene (i.e. All the three sides are unequal)
R4. Upper Limit for the size of any side is 10
4.3 DESIGN
Form the given requirements we can draw the following conditions:
C1: a<b+c?
C2: b<a+c?
C3: c<a+b?
C4: a=b?
C5: a=c?
C6: b=c?
According to the property of the triangle, if any one of the three conditions C1, C2 and C3
are not satisfied then triangle cannot be constructed. So only when C1, C2 and C3 are true
the triangle can be formed, then depending on conditions C4, C5 and C6 we can decide
what type of triangle will be formed. (i.e requirement R3).
ALGORITHM:
Department of ISE, SCEM Page 18
Software testing laboratory 2019-20
Step 1: Input a, b & c i.e three integer values which represent three sides of the triangle.
Step 2: if (a < (b + c)) and (b < (a + c)) and (c < (a + b) then
do step 3
else
print not a triangle. do step 6.
Step 3: if (a=b) and (b=c) then
Print triangle formed is equilateral. do step 6.
Step 4: if (a ≠ b) and (a ≠ c) and (b ≠ c) then
Print triangle formed is scalene. do step 6.
Step 5: Print triangle formed is Isosceles.
Step 6: stop
scanf("%d%d%d",&a,&b,&
c);
if((a<1||a>10)||(b<1||b>10)||(
c<1||c>10))
{
printf("Out of range
values");
exit(0);
}
if((a<b+c)&&(b<a+c)&&(c
<a+b))
{
if((a==b)&&(b==c))
printf("Equilateral
traingle");
else
if((a!=b)&&(b!=c)&&(a!=c)
)
printf("Scalene traingle");
else
Department of ISE, SCEM Page 19
Software testing laboratory 2019-20
printf("Isosceles
traingle");
}
else
printf("Traingle cannot
be formed");
return 0;
}
4.5 TESTCASES
Table-1: Weak Normal and Strong normal equivalence Test case for Triangle Problem
Second attempt
The strong normal equivalence class test cases can be generated by using following
possibilities:
4.6 EXECUTION:
Execute the program and test the test cases in Table-1, Table-2 and Table-3 against program
and complete the table with for Actual output column and Status column
Test Report
1. No of TC‟s Executed:
2. No of Defects Raised:
3. No of TC‟s Pass:
4. No of TC‟s Failed:
4.7 SNAPSHOTS:
5.1 OBJECTIVES:
Design, develop, code and run the program in any suitable language to solve the commission
problem. Analyze it from the perspective of equivalence class testing, derive different test cases,
execute these test cases and discuss the test results
Locks- $45
Stocks- $30
Barrels- $25
The salesperson had to sell at least one complete rifle per month and production limits were
such that the most the salesperson could sell in a month was 70 locks, 80 stocks and 90 barrels.
After each town visit, the sales person sent a telegram to the Missouri gunsmith with the
number of locks, stocks and barrels sold in the town. At the end of the month, the salesperson
sent a very short telegram showing --1 lock sold. The gunsmith then knew the sales for the
month were complete and computed the salesperson‟s commission as follows:
On sales up to(and including) $1000= 10% On
the sales up to(and includes) $1800= 15% On
the sales in excess of $1800= 20%
The commission program produces a monthly sales report that gave the total number of locks,
stocks and barrels sold, the salesperson‟s total dollar sales and finally the commission
5.3 DESIGN
Algorithm
STEP 1: Define lockPrice=45.0, stockPrice=30.0, barrelPrice=25.0
STEP12: exit
#include<stdio.h>
int main()
{
int locks,stocks,barrels,tlocks,tstocks,tbarrels;
float lprice,sprice,bprice,sales=0,comm;
int c1,c2,c3,temp;
tlocks=0,tstocks=0,tbarrels=0;
lprice=45.0,sprice=30.0,bprice=25.0;
printf("Enter the number of locks and to exit the loop press -1\n");
scanf("%d",&locks);
while(locks!=-1)
{
c1=(locks<=0||locks>70);
printf("Enter the number of stocks and barrels");
scanf("%d%d",&stocks,&barrels);
c2=(stocks<=0||stocks>80);
c3=(barrels<=0||barrels>90);
if(c1)
printf("Value of locks not in range 1--70");
else
{
temp=locks+tlocks;
if(temp>70)
printf("New value of locks = %d not in range 1--70",temp);
else
tlocks=temp;
}
Department of ISE, SCEM Page 25
Software testing laboratory 2019-20
printf("Total locks = %d\n",tlocks);
if(c2)
printf("Value of stocks not in range 1--80");
else
{
temp=stocks+tstocks;
if(temp>80)
printf("New value of stocks = %d not in range 1--80",temp);
else
tstocks=temp;
}
printf("Total stocks = %d\n",tstocks);
if(c3)
printf("Value of barrels not in range 1--90");
else
{
temp=barrels+tbarrels;
if(temp>90)
printf("New value of barrels = %d not in range 1--90",temp);
else
tbarrels=temp;
}
printf("Total barrels = %d\n",tbarrels);
printf("Enter the number of locks and press -1 to exit the loop\n");
scanf("%d",&locks);
}
if(tlocks>0&&tstocks>0&&tbarrels>0)
{
printf("Total locks = %d\nTotal stocks = %d\nTotal barrels = %d\n",tlocks,tstocks,tbarrels);
sales=((tlocks*lprice)+(tstocks*sprice)+(tbarrels*bprice));
printf("Total sales is %f\n",sales);
if(sales>0)
{
if(sales>1800)
{
comm=0.10*1000.0;
comm=comm+0.15*800.0;
comm=comm+0.20*(sales-1800);
}
else if(sales>1000)
{
comm=0.10*1000.0;
comm=comm+0.15*(sales-1000);
}
else
comm=0.10*sales;
printf("Commission is %f \n",comm);
}
}
else
printf("There is no sales\n");
Department of ISE, SCEM Page 26
Software testing laboratory 2019-20
return 0;
}
5.5 TESTCASES:
First attempt
We will have eight weak robust test cases.
3 Locks out of -2 40 45 No No
range sales commissio
n
4 Stocks out of 35 -2 45 No No
range sales commissio
n
5 Barrels out of 35 40 -2 No No
range sales commissio
n
6 Locks out of 71 40 45 No No
range sales commissio
n
7 Stocks out of 35 81 45 No No
range sales commissio
n
8 Barrels out of 35 40 91 No No
range sales commissio
n
Second attempt:
Strong robust equivalence class test cases:
5.6 EXECUTIONS
Execute the program and test the test cases in Table-1 against program and complete the table
with for Actual output column and Status column
Test Report:
1. No of TC‟s Executed:
2. No of Defects Raised:
3. No of TC‟s Pass:
4. No of TC‟s Failed:
6.1 OBJECTIVES:
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.
6.2 REQUIREMENT SPECIFICATION
Problem Definition: "Next Date" is a function consisting of three variables like: month, date
and year. It returns the date of next day as output. It reads current date as input date.
C1:1≤month≤12
C2:1≤day≤31
C3: 1812 ≤ year ≤ 2012.
If any one condition out of C1, C2 or C3 fails, then this function produces an output "value of
month not in the range 1...12".
Since many combinations of dates can exist, hence we can simply displays one message for this
function: "Invalid Input Date".
A very common and popular problem occurs if the year is a leap year. We have taken into
consideration that there are 31 days in a month. But what happens if a month has 30 days or
even 29 or 28 days ?
A year is called as a leap year if it is divisible by 4, unless it is a century year. Century years are
leap years only if they are multiples of 400. So, 1992, 1996 and 2000 are leap years while 1900
is not a leap year.
Furthermore, in this Next Date problem we find examples of Zipf's law also, which states that
"80% of the activity occurs in 20% of the space". Thus in this case also, much of the source-
code of Next Date function is devoted to the leap year considerations.
6.1 DESIGN
Algorithm
STEP 1: Input date in format DD.MM.YYYY
STEP11: if MM is 2
STEP19: exit
if((month==4||month==6||month==9||month==11)&&day==31)
return 1;
else
return 0;
if(((year%4==0)&&(year%100!=0))||(year%400==0))
return 1;
else
return 0;
int main()
int day,month,year,tday,tmonth,tyear;
char flag;
do{
flag='y';
scanf("%d%d%d",&day,&month,&year);
tmonth=month;
tyear=year;
if(day<1||day>31)
flag='n';
if(month<1||month>12)
flag='n';
else if(check(day,month))
Department of ISE, SCEM Page 33
Software testing laboratory 2019-20
{
flag='n';
if(year<1812||year>2018)
flag='n';
if(month==2)
if(isleap(year)&&day>29)
flag='n';
if(!isleap(year)&&day>28)
flag='n';
}while(flag=='n');
switch(month)
case 1:
case 3:
Department of ISE, SCEM Page 34
Software testing laboratory 2019-20
case 5:
case 7:
case 8:
tday=day+1;
else
tday=1;
tmonth=month+1;
break;
case 4:
case 6:
case 9:
tday=day+1;
else
tday=1;
tmonth=month+1;
break;
case 12:if(day<31)
tday=day+1;
else
tday=1;
Department of ISE, SCEM Page 35
Software testing laboratory 2019-20
tmonth=1;
if(year==2018)
else
tyear=year+1;
break;
case 2: if(day<28)
tday=day+1;
else if(isleap(year)&&day==28)
tday=day+1;
else if(day==28||day==29)
tday=1;
tmonth=3;
break;
return 0;
6.5 TESTING
Test Case design
Weak Robust:
Strong Robust:
Strong Normal:
Weak Normal:
6.6 EXECUTIONS
Execute the program and test the test cases in Table-1 against program and complete the table with
for Actual output column and Status column
Test Report:
6.6.1 No of TC‟s Executed:
6.6.2 No of Defects Raised:
6.7 SNAPSHOTS:
7.1 OBJECTIVES:
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. Derive test cases for your program based on decision-table approach, execute
the test cases and discuss the results.
R1. The system should accept 3 positive integer numbers (a, b, c) which represents 3 sides of
the triangle. Based on the input it should determine if a triangle can be formed or not.
R2. If the requirement R1 is satisfied then the system should determine the type of the triangle,
which can be
• Equilateral (i.e. all the three sides are equal)
• Isosceles (i.e Two sides are equal)
• Scalene (i.e All the three sides are unequal)
else suitable error message should be displayed. Here we assume that user gives three positive
integer numbers as input.
7.3 DESIGN:
Form the given requirements we can draw the following conditions:
C1: a<b+c?
C2: b<a+c?
C3: c<a+b?
C4: a=b?
C5: a=c?
C6: b=c?
According to the property of the triangle, if any one of the three conditions C1, C2 and C3 are
not satisfied then triangle cannot be constructed. So only when C1, C2 and C3 are true the
triangle can be formed, then depending on conditions C4, C5 and C6 we can decide what type
of triangle will be formed. (i.e requirement R2).
ALGORITHM:
Step 1: Input a, b & c i.e three integer values which represent three sides of the triangle.
Step 2: if (a < (b + c)) and (b < (a + c)) and (c < (a + b) then do
step 3
else
print not a triangle. do step 6.
Department of ISE, SCEM Page 41
Software testing laboratory 2019-20
scanf("%d%d%d",&a,&b
,&c);
if((a<1||a>10)||(b<1||b>10
)||(c<1||c>10))
{
printf("Out of range
values");
exit(0);
}
if((a<b+c)&&(b<a+c)&&
(c<a+b))
{
if((a==b)&&(b==c))
printf("Equilateral
traingle");
else
if((a!=b)&&(b!=c)&&(a!
=c))
printf("Scalene
traingle");
else
printf("Isosceles
Department of ISE, SCEM Page 42
Software testing laboratory 2019-20
traingle");
}
else
printf("Traingle cannot
be formed");
return 0;
}
1. TESTCASES:
Technique Used: Decision Table Approach
Decision Table-Based Testing has been around since the early 1960‟s; it is used to depict
complex logical relationships between input data. A Decision Table is the method used to build
a complete set of test cases without using the internal structure of the program in question. In
order to create test cases we use a table to contain the input and output values of a program.
The “--“ symbol in the table indicates don‟t care values. The table shows the six conditions and
5 actions. All the conditions in the decision table are binary; hence, it is called as “Limited
Entry decision table”.
Each column of the decision table represents a test case. That is,
The table is read as follows:
Action: Not a Triangle
TC Expected Actual
Test Case A BC Status
ID Output Output
Description
Testing for Not a
1 6 4 1
Rule 1 Triangle
Testing for Not a
2 1 5 3
Rule 2 Triangle
Testing for Not a
3 1 2 4
Rule 3 Triangle
2. EXECUTION
Execute the program against the designed test cases and complete the table for Actual output
column and status column.
Test Report:
7.2.1 No of TC‟s Executed: 08
7.2.2 No of Defects Raised:
7.2.3 No of TC‟s Pass:
7.2.4 No of TC‟s Failed:
The decision table technique is indicated for applications characterised by any of the following:
Prominent if-then-else logic
Logical relationships among input variables
Calculations involving subsets of the input variables
Cause-and-effect relationship between inputs and outputs
The decision table-based testing works well for triangle problem because a lot of decision
making i.e if-then-else logic takes place.
3. SNAPSHOTS:
1. Output screen of Triangle cannot be formed
8.1 Objectives:
Design, develop, code and run the program in any suitable language to solve the commission
problem. Analyze it from the perspective of decision table-based testing, derive different test cases,
execute these test cases and discuss the test results
8.3 DESIGN:
Form the given requirements we can draw the following conditions:
C1: 1≤locks≤70? Locks = -1? (occurs if locks = -1 is used to control input
iteration).
C2: 1≤stocks≤80?
C3: 1≤barrels≤90? Here C1 can be expanded
C4: sales>1800? as: C1a: 1≤locks
C6: sales≤1000?
ALGORITHM
Step 1: Input 3 integer numbers which represents number of Locks, Stocks and Barrels sold.
Step 2: compute the total sales =
(Number of Locks sold *45) + (Number of Stocks sold *30) + (Number of Barrels sold
*25)
Step 3: if a totals sale in dollars is less than or equal to $1000
then commission = 0.10* total Sales do step 6
Step 4: else if total sale is less than $1800
then commission1 = 0.10* 1000
commission = commission1 + (0.15 * (total sales – 1000))
do step 6
Step 5: else commission1 = 0.10* 1000
commission2 = commission1 + (0.15 * 800))
commission = commission2 + (0.20 * (total sales – 1800)) do step 6
Step 6: Print commission.
Step 7: Stop.
#include<stdio.h>
int main()
{
int locks,stocks,barrels,tlocks,tstocks,tbarrels;
float lprice,sprice,bprice,sales=0,comm;
int c1,c2,c3,temp;
tlocks=0,tstocks=0,tbarrels=0;
lprice=45.0,sprice=30.0,bprice=25.0;
printf("Enter the number of locks and to exit the loop press -1\n");
scanf("%d",&locks);
while(locks!=-1)
{
c1=(locks<=0||locks>70);
printf("Enter the number of stocks and barrels");
scanf("%d%d",&stocks,&barrels);
c2=(stocks<=0||stocks>80);
c3=(barrels<=0||barrels>90);
if(c1)
printf("Value of locks not in range 1--70");
else
{
Department of ISE, SCEM Page 48
Software testing laboratory 2019-20
temp=locks+tlocks;
if(temp>70)
printf("New value of locks = %d not in range 1--70",temp);
else
tlocks=temp;
}
printf("Total locks = %d\n",tlocks);
if(c2)
printf("Value of stocks not in range 1--80");
else
{
temp=stocks+tstocks;
if(temp>80)
printf("New value of stocks = %d not in range 1--80",temp);
else
tstocks=temp;
}
printf("Total stocks = %d\n",tstocks);
if(c3)
printf("Value of barrels not in range 1--90");
else
{
temp=barrels+tbarrels;
if(temp>90)
printf("New value of barrels = %d not in range 1--90",temp);
else
tbarrels=temp;
}
printf("Total barrels = %d\n",tbarrels);
printf("Enter the number of locks and press -1 to exit the loop\n");
scanf("%d",&locks);
}
if(tlocks>0&&tstocks>0&&tbarrels>0)
{
printf("Total locks = %d\nTotal stocks = %d\nTotal barrels = %d\n",tlocks,tstocks,tbarrels);
sales=((tlocks*lprice)+(tstocks*sprice)+(tbarrels*bprice));
printf("Total sales is %f\n",sales);
if(sales>0)
{
if(sales>1800)
{
comm=0.10*1000.0;
comm=comm+0.15*800.0;
comm=comm+0.20*(sales-1800);
}
else if(sales>1000)
{
comm=0.10*1000.0;
comm=comm+0.15*(sales-1000);
}
else
Department of ISE, SCEM Page 49
Software testing laboratory 2019-20
comm=0.10*sales;
printf("Commission is %f \n",comm);
}
}
else
printf("There is no sales\n");
return 0;
}
8.5 TESTCASES
Technique Used: Decision Table Approach
Test Cases:
8.7 SNAPSHOTS:
1. What is an error?
2. What is the use of testing software?
3. How is the decision table approach carried out?
4. What are the types of software testing?
5. What are the different black box testing techniques?
9.1 Objectives:
Design, develop, code and run the program in any suitable language to solve the
commission problem. Analyze it from the perspective of dataflow testing, derive
different test cases, execute these test cases and discuss the test results.
Locks- $45
Stocks- $30
Barrels- $25
The salesperson had to sell at least one complete rifle per month and production limits were
such that the most the salesperson could sell in a month was 70 locks, 80 stocks and 90
barrels.
After each town visit, the sales person sent a telegram to the Missouri gunsmith with the
number of locks, stocks and barrels sold in the town. At the end of the month, the
salesperson sent a very short telegram showing --1 lock sold. The gunsmith then knew the
sales for the month were complete and computed the salesperson‟s commission as follows:
On sales up to(and including) $1000= 10% On
the sales up to(and includes) $1800= 15% On
the sales in excess of $1800= 20%
The commission program produces a monthly sales report that gave the total number of
locks, stocks and barrels sold, the salesperson‟s total dollar sales and finally the
commission
9.3 DESIGN
Algorithm
STEP 1: Define lockPrice=45.0, stockPrice=30.0, barrelPrice=25.0
STEP12: exit
9.5 TESTCASES
DATA FLOW TESTING: KEY STEPS
Given a code (program or pseudo-code).
1. Number the lines.
2. List the variables.
3. List occurrences & assign a category to each variable.
4. Identify du-pairs and their use (p- or c- ).
5. Define test cases, depending on the required coverage.
9.6 EXECUTION
Execute the program and test the test cases in above Tables against program and complete
the table with for Actual output column and Status column
9.7 SNAPSHOTS:
8 What is an error?
9 What is the use of testing software?
10 What are the types of software testing?
11 What is boundary value analysis?
12 What is white box testing and list the types of white box testing?
13 What is black box testing? What are the different black box testing techniques?
10.1 Objectives:
Design, develop, code and run the program in any suitable language to implement the
binary search algorithm. Determine the basis paths and using them derive different test
cases, execute these test cases and discuss the test results.
10.3 DESIGN
We use integer array as a data structure to store „n‟ number of elements. Iterative programming
technique is used.
ALGORITHM
Step 1: Input value of „n‟. Enter „n‟ integer numbers in array int mid;
Step 2: Initialize low = 0, high = n -1
Step 3: until ( low <= high ) do
mid = (low + high) / 2
if ( a[mid] == key )
then do Step 5
else if ( a[mid] > key )
then do
high = mid - 1
else
low = mid + 1
Step 4: Print unsuccessful search do step 6.
Step 5: Print Successful search. Element found at position mid+1.
Step 6: Stop.
#include<stdio.h>
void main()
{
int i,n,a[100],low,high,mid,key,flag=0;
printf("Enter the value of n\n");
scanf("%d",&n);
printf("Enter the elements : ");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("Enter the key");
scanf("%d",&key);
low=0;
high=n-1;
while(low<=high)
{
mid=(low+high)/2;
if(key==a[mid])
{
flag=1;
break;
}
else if(key<a[mid])
high=mid-1;
else
low=mid+1;
}
if(flag==1)
printf("Key found at position %d",mid+1);
else
printf("key not found");
}
10.5 TESTCASES
Technique Used: Basis Path Testing
Basis path testing is a form of Structural testing (White Box testing). The method devised by
McCabe to carry out basis path testing has four steps. These are:
1. Compute the program graph.
2. Calculate the cyclomatic complexity.
3. Select a basis set of paths.
4. Generate test cases for each of these paths.
Program
graph node DD path name Case description
1 first 1
2-6 A 5
7 B 3
8 C 4
9-12 D 5
13 E 3
14-15 F 5
16 G 3
17-20 H 5
21 I 3
22 J 4
23-24 K 5
25 L 3
26 M 3
27 N 4
28-29 O 5
30 P 2
11.1 Objectives:
Design, develop, code and run the program in any suitable language to implement the
quicksort algorithm. Determine the basis paths and using them derive different test
cases, execute these test cases and discuss the test results.
11.2 REQUIREMENTS SPECIFICATION:
R1: The system should accept “n‟ number of elements and key element that is to be searched
among “n‟ elements.
R2: Check if the key element is present in the array and display the position if present
otherwise print unsuccessful search.
11.3 DESIGN:
We use integer array as a data structure to store „n‟ number of elements. Iterative programming
technique is used.
Cyclomatic complexity
The Cyclomatic complexity of the graph given by the equation
V(G)=e-n+2p
Where e is number of edges ,n is the number of nodes, and p is the number of connected
regions.
No. of edges e =27
No. of nodes n =21
number of connected regions p=1
V(G)=e-n+2p
=27-21+2(1)=8
9.5 TESTCASES
11.6 EXECUTION
Compile the program and enter inputs Test above table array elements for test cases.
Test Report:
11.6.1 No of TC‟s Executed:
11.6.2 No of Defects Raised:
11.6.3 No of TC‟s Pass:
11.6.4 No of TC‟s Failed:
11.7 SNAPSHOTS:
1 What is an error?
2 Explain quicksort algorithm
3 What is basis path testing
4 What is DD path
5 What is program graph
12.1 Objectives:
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 test cases, execute these test cases and discuss the
test results
12.2 REQUIREMENTS SPECIFICATION:
R1: The system should accept marks of 6 subjects, each marks in the range 1 to 100.
i.e., for example, 1<=marks<=100 1<=kannada<=100 1<=maths<=100 etc.
R2: If R1 is satisfied compute the average of marks scored and percentage
of the same and depending on percentage display the grade.
12.3DESIGN:
Structural representations of program statement, mathematical notations of the basis
has attracted.
Structural testing involves following steps:
13.4.1 Complete the program graph
13.4.2 Considering the program graph, draw the DD path graph
13.4.3 Calculate cyclomatic complexity
13.4.4 Select basis set of path
13.4.5 Generate the test case for each of the path.
12.5 TESTCASES:
Program
graph nodes DD path name Case description
1 first 1
2-6 A 5
7 B 3
8 C 4
68
Department of Information Science and Engineering, SCEM, Mangaluru.
9 D 3
Software testing laboratory 2019-20
10 E 4
11 F 3
12 G 4
13 H 3
14 I 4
15 J 3
16 K 4
17-18 L 5
19 M 3
20 N 3
21-22 O 5
23-24 P 5
25-26 Q 5
27-28 R 5
29-30 S 5
31 T 3
32-33 U 5
34-35 V 5
36 W 2
12.6EXECUTION
69
Department of Information Science and Engineering, SCEM, Mangaluru.
Software testing laboratory 2019-20
Execute the program and test the test cases in above Tables against program
and complete the table for Actual output column and Status column
12.7 SNAPSHOTS
70
Department of Information Science and Engineering, SCEM, Mangaluru.