Software Testing LAB Programs
Software Testing LAB Programs
PROGRAMME OUTCOME
PO-1 Students become knowledgeable academically to implement the principles and for rapid
growth of the IT industry.
PO-2 The programme offers face to face teaching with project-based learning, ensuring the graduate
with technical fluency.
PO - 1 This programme helps to develop academically competent and professionally motivated
personnel equipped with critical thinking that helps to improve the scientific temper with a sense
of social responsibility.
PO-2 This programme imbibes development of Software quality practices circumstances with an
understanding of the limitations.
PO - 2 To demonstrate the knowledge gained by understanding scientific and mathematical skills
to apply these in their own work.
PO - 3 They will be able to comprehend, write effective reports, design documentation and make
effective presentations. Students will be able to change their perspectives to the new
developments in the field of Computer Science.
PSO - 1 One of the most recognized UG degree B.Sc. Computer Science for employment
by applying in government exams and also in private sectors.
PSO - 2 The programme implements the knowledge attained in their own domain area of
programming to exhibit their skills and competencies in the following knowledge areas:
i) Data Structures and programming languages.
iii) Apply problem solving skills and the expertise in solving real world problems.
PSO-3 To prepare the students to become, well educated, ethical and responsible citizens.
COURSE OBJECTIVE
1. The objective of the problem is to find the sum of individual digits of a given ten digit
number by finding the remainder and dividing the number for the next term. Finally
adding all the digits until it reduces to a single digit.
2. The objective of the problem is to check whether the student’s result is PASS or FAIL
from the given marks list of various subjects. Declare the results as pass if the student
gets minimum 40 in each subject.
3. The objective of the problem is to generate the prime number series for the given number.
4. The objective of the problem is to merge the two ordered lists, so that the resultant is the
ordered one and this process is called merging. Two elements are taken and after
comparison, whichever is smaller that is added into the ordered list.
5. The objective of the problem includes in demonstrating the various operations of stack
using the array implementation. Stack is an ordered list in which all insertions and
deletions takes place at one end called top of stack.
6. The objective of the problem is to create an menu driven program to implement the queue
operations like insertions, deletions, modifications and listing of elements.
7. The objective of the program is to test the C++ program to check whether the given string
is palindrome or not using pointers.
COURSE OUTCOME:
2. To write manual test cases for the given functionality in the specified format for Unit
testing in projects.
LIST OF PROGRAMS
1. Test the C program: Finding the sum of individual digits of a 10-digit number until a
single digit is produced.
2. Test the C Program: Accept the inputs student name, marks in five subjects and
declare the result as PASS if the student gets minimum 40 in each subject; otherwise
declare the result as FAIL.
3. Test the C program: for generating n prime numbers.
4. Test the C program: Sort and store the elements of two arrays of integers into the
third list.
5. Test the C program: Experiment the operations of a stack using array implementation.
6. Test the C program: Menu-driven option for queue operations like add, remove and
display.
7. Test the C++ program: Palindrome string checking program (using pointers).
ENHANCEMENT:
1. Develop test cases for the project using white box testing.
2. Develop Software requirement Specification (SRS) document in IEEE format for the
project.
PRE-REQUISITE:
AIM:
To test a C program for finding the sum of individual digit of a 10 digit number until a
single digit is produced.
ALGORITHM:
Step 2: Open TC present in the program files to open the C programming environment.
Step 4: Get 10 digits from the user which is stored in the variable called temp for temporary
storage.
Step 5: Performing the operations of sum of individual digits given by the user.
#include<stdio.h>
int main(void)
{
long num;
int dig,sum;
printf("Enter any number : ");
scanf("%ld",&num);
printf("%ld-> ",num);
do
{
sum = 0;
while(num!=0)
{
dig=num%10;
sum+=dig;
num/=10;
}
printf("%d-> ",sum);
num=sum;
}while(num/10!=0);
return 0;
}
TEST CASES:
Ex.No.02
STUDENT MARKSHEET RESULT
AIM:
To test a C program to accept the inputs student name, marks in five subjects and declare the
results as pass if the student gets minimum 40 in each subject, otherwise declare the result as
FAIL.
ALGORITHM:
Step 3: Declare the main function under it declare the required variables such as
rollno,name,m1,m2,m3,m4,m5.
Step 4: Get the name and roll number and five subject marks from the user using get statement.
Step 5: The marks are checked using if statement and finally the result is displayed “pass” or
“Fail”.
#include<stdio.h>
#include<conio.h>
void main()
{
int rollno, m1,m2,m3,m4,m5;
char name[30];
printf(“enter roll no:”);
scanf(“%d”, &rollno);
printf(“enter name:”);
scanf(“%s”, &name);
printf((“enter marks for 5 subjects:”);
scanf(“%d%d%d%d%d”,&m1,&m2,&m3,&m4,&m5);
if ( (m1<40)||(m2<40)||(m3<40)||(m4<40)||(m5<40))
{
printf(“RESULT IS FAIL”);
}
else
{
printf(“RESULT IS PASS”);
}
getch();
}
TEST CASES:
OUTPUT :-
STUDENT MARKLIST
75
60
95
88
78
AIM:
ALGORITHM:
Step 3: Take the integer variable i, divide the variable i with (i-1 to 2)
Step 4: If variable i is divisible by any value (i-1 to 2 ) it is not prime, otherwise it is prime.
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,j,y;
clrscr();
printf("\n\t\t\t Generating prime numbers");
printf("\n\n\tEnter the value for n:");
scanf("%d",&n);
printf("\n\n\t**Prime numbers between 1 to \%d**\n",n);
printf("\n\t1 is neither or not prime number\n");
for(i=2;i<=n;i++)
{
y=0;
for(j=2;j<i;j++)
{
if(i%j==0)
{
y=1;
break;
}
}
if(y==0)
{
printf("\n\tprime number:%d",i);
}
}
getch();
}
TEST CASES:
2357
Ex.No: 4
AIM:
To test a C program to sort and store the elements of two arrays of type integers into the
third list.
ALGORITHM:
Step 3: Initialize the size for the input array variables to zero using a loop.
Step 4: Enter the size of an array and the elements in array 1 and array2 during runtime.
Step 5: Compare the elements of array1 and array 2 using decision making statement and sort the
elements.
Step 6: The sorted list of array1 and array2 are merged and stored as values in array3.
void main()
scanf("%d", &m);
scanf("%d", &array1[i]);
}
scanf("%d", &n);
scanf("%d", &array2[i]);
i = 0;
j = 0;
array3[k] = array1[i];
i++;
else
array3[k] = array2[j];
j++;
k++;
if (i >= m)
while (j < n)
array3[k] = array2[j];
j++;
k++;
if (j >= n)
while (i < m)
array3[k] = array1[i];
i++;
k++;
}
printf("\n After merging: \n");
printf("\n%d", array3[i]);
TEST CASES:
Ex.No: 5
STACK OPERATIONS
AIM:
ALGORITHM:
Step 2: Declare the variables as stack, top, i and choice for stack operation.
Step 3: Get the input for the size of the stack and the elements in the stack.
Step 4: Check using the if condition to validate when the maximum size of stack occurs in
overflow.
Step 5: Use top=top+1 to increment the top 1, to push the elements at the top of stack, and then
Step 6: Display the elements of stack and use exit() to exit from the screen.
SOURCE CODE:
",stack[TOP]);
for(i=TOP-1;i >=0;i--)
{
printf("\n%d",stack[i]);
}
printf("\n\n");
}
/* function : PUSH(),
to push an item into stack.
*/
void PUSH(int stack[],int item)
{
if(TOP==MAX-1)
{
printf("\nSTACK is FULL CAN't ADD ITEM\n");
return;
}
TOP++;
stack[TOP]=item;
}
/* function : POP(),
to pop an item from stack.
*/
void POP(int stack[])
{
int deletedItem;
if(TOP==-1)
{
printf("STACK is EMPTY.\n");
return;
}
deletedItem=stack[TOP];
TOP--;
printf("%d deleted successfully\n",deletedItem);
return;
}
TEST CASES:
TEST-
ID#in
clude
<stdi
o.h>
#incl
ude
<stdli
b.h>
TEST EXPECTED ACTUAL
TEST STEPS STATUS
DESCRIPTION OUTPUT OUTPUT
#defi
ne
MAX
10
int
STAC
K[M
AX],T
OP;
/*
displ
ay
stack
elem
ent*
/
void
displ
ay(in
t []);
/*
push
(inse
rt)
item
into
stack
*/
void
PUSH
(int
[],int
);
/*
pop
(rem
ove)
item
from
stack
*/
void
POP
(int
[]);
void
main
()
{
int
ITEM
=0;
int
choic
e=0;
TOP=
-1;
while
(1)
{
/*clr
scr();
*/
print
f("En
ter
Choic
e (1:
displ
ay, 2:
inser
t
(PUS
H), 3:
remo
ve(P
OP)),
4:
Exit..
:");
scanf
("%d
",&c
hoice
);
switc
h(ch
oice)
{
case
1:
displ
ay(ST
ACK);
brea
k;
case
2:
print
f("En
ter
Item
to be
inser
t :");
scanf
("%d
",&IT
EM);
PUSH
(STA
CK,IT
EM);
brea
k;
case
3:
POP(
STAC
K);
brea
k;
case
4:
exit(
0);
defa
ult:
print
f("\nI
nvali
d
choic
e.");
brea
k;
}
getch
();
}//
end
of
while
(1)
}
/*
funct
ion
:
displ
ay(),
to
displ
ay
stack
elem
ents.
*/
void
displ
ay(in
t
stack
[])
{
int
i=0;
if(TO
P==-
1)
{
print
f("St
ack is
Empt
y
.\n");
retur
n;
}
print
f("%
d <--
TOP
TC-01 Input case- Enter the It should be an integer Valid Valid SUCCESS
size of stack. value.
TC-02 Input case- Enter the If input is float or Invalid Invalid SUCCESS
size of stack. character.
TC-03 Input case -Enter the It should be an integer Valid Valid SUCCESS
choice to perform the value.
specified action.
TC-04 Input case -Enter the If input is float or Invalid Invalid SUCCESS
choice to perform the character.
specified action.
TC-05 Process case – Initialize the top=0 then Valid Valid SUCCESS
INSERTION: Enter it is incremented.
the choice as push.
TC-06 Process case – Initialize the top!=0 Invalid Invalid SUCCESS
INSERTION: Enter then it is decremented.
the choice as push.
TC-07 Process case – The top decremented by Valid Valid SUCCESS
DELETION: Enter one and it displays the
the choice as pop. popped element.
TC-08 Process case – The top incremented by Invalid Invalid SUCCESS
DELETION: Enter one and it displays the
the choice as pop. popped element.
TC-09 Output case –Check If valid choice is given Valid Valid SUCCESS
for the formatted perform the specific
output. task.
TC-10 Output case –Check If valid choice is given Invalid Invalid SUCCESS
for the formatted perform the specific
output. task.
OUTPUT :-
Enter the size of stack:3
Stack Operations
1.Push
2.Pop
3.Show
4.Exit
Enter your choice:1
Enter the item to push:1
QUEUE OPERATIONS
AIM:
1. Insertion
2. Deletion
3. Modification
4. List
ALGORITHM:
Step 1: Declare one-dimensional array and an integer pointer variable and variables for insertion,
loops, option and size.
Step 3: The queue operation is performed using menu driven program and the menu includes a
number of choice.
Step 4: If the choice is 1, and it checks the condition whether the rear is equal to size and if it is
false then, else part is executed, i.e., it increments the rear and the new element is added.
Step 5: If the choice is 2, and it checks the condition whether the rear is equal to zero and if it is
false then, else part is executed, i.e., it will delete an element from the front of queue and the
remaining elements are moved one position front and rear is decremented.
Step 6: If the choice is 3, and it checks the condition whether the rear is equal to zero and if it is
false then, else part is executed, i.e., it lists the elements present in the queue.
Step 7: If the choice is 4, and it checks the condition whether the rear is equal to zero and if it is
false then, else part is executed, i.e., it replaces the element in the queue by the new element.
Step 8: If the choice is Invalid, then it displays the statement choose the correct option.
SOURCE CODE:
#include<stdio.h>
#include<conio.h> //preprocessor directives
void main()
{
int *queue[15],q[15];
int n=0,i=0,opt,s=0,newval,size; //variable declaration
clrscr(); // clearing screen
printf("\n\t\t\t <=QUEUE OPERATIONS=>");
printf("\n\t\t\t ====================");
printf("\n\n Enter Size: ");
scanf("%d",&size); //To read size of queue
do
{
printf("\n\n\t MENU\n\t _______”);
printf(“\n\n\t 1.Insert"); // Displays menu
printf("\n\n\t 2.Delete\n\n\t 3.List\n\n\t 4.Modify\n\n\t 5.Exit");
printf("\n Enter your choice (1-5): ");
scanf("%d",&opt); //To read choice from menu
switch(opt)
{
case 1: // To insert an element
clrscr();
if(n==size) //If rear reaches maximum size then queue is full
printf("\n Queue Full");
else
{
n++; // Incrementing rear end
printf("\n Enter the new element: ");
scanf("%d",&q[n]); //read new element to insert
queue[n]=&q[n]; //new element is copied to queue
printf("\n The new element %d is added to queue",q[n]);
}
break;
case 2: // To delete an element
clrscr();
if(n==0) //If front is zero then queue empty
printf("\n Queue Empty");
else
{
printf("\n The Element %d is deleted",q[1]);
for(i=1;i<=n;i++)
{
*queue[i]=*queue[i+1]; //moving all elements one position front
}
queue[i]=0;
n--; // Decrementing rear end
}
break;
case 3: // To list the elements
if(n==0) //If front is zero then queue empty
printf("\n Queue is empty");
else
{
printf("\n Queue:(front)");
for(i=1;i<=n;i++) //To display the elements of queue
printf("%5d",*queue[i]);
printf(" (Rear)");
}
break;
case 4: //To modify the element of queue
if(n==0) //If front is zero then queue empty
printf("\n Queue Empty");
else
{
printf("\n Enter the position of element to be modified: ");
Re_enter:
scanf("%d",&s); //To read the position of queue
if(s>n) /*If position is greater than size of queue
it again pass the control to read valid position*/
{
printf("\n Enter position between [p1-%d]",n);
goto Re_enter;
}
printf("\n The element at %d is %d",s,*queue[s]);
printf("\n Enter new element: ");
scanf("%d",&newval); //Read the new element
*queue[s]=newval; //Insert the element in respective position
}
break;
case 5: //To exit from menu
exit(0);
default:
printf("\n Choose correct option");
}
}while(1);
}
TEST CASES:
OUTPUT :-
Enter Size: 3
MENU
1.Insert
2.Delete
3.List
4.Modify
5.Exit
Queue:(front) 77 3 (Rear)
Enter your choice (1-5): 5
Ex.No: 7
AIM:
To test the C++ program: Palindrome string checking program using pointers.
ALGORITHM:
Step 1: Declare two variables s and r and two pointer variables strt and estr of any size.
Step 5: Using for loop, swap the variable to temporary variable ch.
Step 6: The values of s is assigned to pointer variable strt. The values of r are assigned to pointer
variable rstr.
Step 9: If the condition is true, display strt is not a palindrome, else display strt is a palindrome.
SOURCE CODE:
#include <iostream.h>
//#include <math.h>
#include <string.h>
#include <conio.h>
void main()
{
char original[20],reversed[20];
int length;
clrscr();
cout <<"Enter a string"<<endl;
cin>>original;
length=strlen(original);
strcpy(reversed,original);
for (int i=0;i<=length-1;i++)
{
reversed[length-1-i]=original[i];
}
cout <<original<<" "<<reversed<<endl;
if(strcmp(reversed,original)==0)
cout<<"It is a palindrome";
else
cout<<"It is not a palindrome";
getch();
}
TEST CASES:
OUTPUT :-
ENHANCEMENT:
Ex. No. 1:
AIM:
To develop test cases for the C++ program using white box testing: To find the week day
from a given date.
ALGORITHM:
Step 1: Start the process.
Step 3: Using multi-way decision making statement, check the number given in variable n.
Step 4: If the given option is true, display the corresponding day given, else if the number is
invalid, display it as Invalid number.
Step 5: For the given decision making statement, develop the multiple condition coverage testing
for all cases.
SOURCE CODE:
#include<iostream.h>
#include<conio.h>
int main()
{
int n;
cout<<”Enter number for day: “;
cin>>n;
switch(n)
{
case 1: cout<<”Sunday”; break;
case 2:
cout<<”Monday”;
break;
case 3:
cout<<”Tuesday”;
break;
case 4:
cout<<”Wednesday”;
break;
case 5:
cout<<”Thursday”;
break;
case 6:
cout<<”Friday”;
break;
case 7:
cout<<”Saturday”;
break;
default:
cout<<”Invalid number!”;
break;
}
return 0;
}
TEST CASES:
READ N
IF (N= =1)
PRINT “SUNDAY”
IF (N= =2)
PRINT “MONDAY”
IF (N= =3)
PRINT “TUESDAY”
IF (N= =4 )
PRINT “WEDNESDAY”
IF (N= =5)
PRINT “THURSDAY”
IF (N= =6)
PRINT “FRIDAY”
IF (N= =7)
PRINT “SATURDAY”
ELSE
PRINT “INVALID NUMBER”
OUTPUT:
Enter number for day:1
Sunday
Ex. No. 2:
Overview:
The implementation of Library Management starts with entering and updating master records
like book details, library information. Any further transaction like book issue, book return will
automatically update the current books.
Overall Description:
Product Perspective:
The proposed Library Management System will take care of the current book detail at any point
of time. The book issue, book return will update the current book details automatically so that
user will get the update current book details.
Product function:
● The main purpose of this project is to reduce the manual work.
● This software is capable of managing Book Issues, Returns, and Calculating/Managing Fine.
● Generating various Reports for Record-Keeping according to end user requirements.
User characteristics:
They have 2 levels of users:
● User module: In the user module, user will check the availability of the books.
● Book return
● Administration module: The following are the sub module in the administration module.
● Register user
● Entry book details
● Book issue
General Constraints:
Any update regarding the book from the library is to be recorded to have update & correct
values.
Assumption and dependencies:
All the data entered will be correct and up to date. This software package is developed using java
as front end which is supported by sun micro system. Microsoft SQL server 2005 as the back end
which is supported by Window 7.
Specific Requirement:
External Interface Requirement:
The user should be simple and easy to understand and use. Also be an interactive
interface .The system should prompt for the user and administrator to login to the application and
for proper input criteria
User Interface:
The software provides good graphical interface for the user any administrator can operate on the
system, performing the required task such as create, update, viewing the details of the book.
● Allows user to view quick reports like Book Issues/Returned etc in between particular time.
● Stock verification and search facility based on different criteria.
Hardware interface:
Software interface :
● Java language
● Net beans IDE 7.0.1
● MS SQL server 2005
Communication interface:
● Window
Functional requirements:
● Book entry: In this module we can store the details of the books.
● Register student: in this module we can keep the details of the new student.
● Book issue: This module is used to keep a track of book issue details.
● Book return: This module enables to keep a track of return the books.
Performance requirements:
The capability of the computer depends on the performance of the software. The software
can take any number of inputs provided the database size is larger enough. This would depend on
the available memory space.
Design constraints:
Each member will be having a identity card which can be used for the library book issue,
fine payment etc. whenever library member wish to take a book, the book issued by the library
authority will be check both the book details as well as the student details and store it in library
database. In case of retrieval of book much of human intervention can be eliminated.
System Attributes:
● Maintainability: There will be no maintained requirement for the software. The database is
provided by the end user and therefore is maintained by this user.
● Portability: The system is developed for secured purpose, so it is can’t be portable.
● Availability: This system will available only until the system on which it is install, is running.
● Scalability: Applicable.