Software Testing (Anurag)
Software Testing (Anurag)
SOFTWARE TESTING
           PRACTICAL FILE
                 Bachelor of Technology in
                  Information Technology
Anurag
                            IT-1
                       (01413203120)
INDEX
                           EXPERIMENT – 1
Aim: To determine the nature of roots of a Quadratic Equation, its
input is triple of positive integers (say a, b, c) and values may be from
interval [1, 100]. The output may have one of the following:
Real & Distinct Roots, Imaginary Roots or Real & Equal Roots.
Design the Boundary Value Test Cases.
Algorithm:
Program:
#include <iostream>
#include <math.h>
int main()
{
    int min, max;
    int x, y, z;
    cout << "Enter Range : ";
    cin >> min >> max;
    if (min < 0 || max > 100)
    {
        cout << "Invalid Range";
        return 0;
    }
    int nominal = (min + max) / 2;
    int values[] = {min, min + 1, nominal, max - 1, max};
    cout << "a\tb\tc\tOutput\t\t\tRoots" << endl;
    for (int i = 0; i < 5; i++)
    {
Anurag                                 IT-1                          01413203120
    }
    return 0;
}
                              EXPERIMENT – 2
Aim: To determine the type of triangle. Its input is triple of positive
integers (say x, y, z) and the values may be from interval [1,100]. The
program output may be one of the following [Scalene, Isosceles,
Equilateral, Not a Triangle].
Algorithm:
int main()
{
       int side1, side2, side3;
         return 0;
}
Anurag    IT-1   01413203120
Outputs
Anurag                              IT-1                          01413203120
Domain:     Minimum = 1
            Above Minimum = 2
            Nominal = 50
            Below Maximum = 99
            Maximum = 100
 Test Id   A     B       C      Expected Output        Program Output         Tested
                                                                             Outcome
    1        1    50      50    Isosceles Triangle     Isosceles Triangle      Pass
    2        2    50      50    Isosceles Triangle     Isosceles Triangle      Pass
    3       99    50      50    Isosceles Triangle     Isosceles Triangle      Pass
    4      100    50      50      Not A Triangle         Not A Triangle        Pass
    5       50     1      50    Isosceles Triangle     Isosceles Triangle      Pass
    6       50     2      50    Isosceles Triangle     Isosceles Triangle      Pass
    7       50    99      50    Isosceles Triangle     Isosceles Triangle      Pass
    8       50   100      50      Not A Triangle         Not A Triangle        Pass
    9       50    50       1    Isosceles Triangle     Isosceles Triangle      Pass
   10       50    50       2    Isosceles Triangle     Isosceles Triangle      Pass
   11       50    50      99    Isosceles Triangle     Isosceles Triangle      Pass
   12       50    50     100      Not A Triangle         Not A Triangle        Pass
   13       50    50      50   Equilateral Triangle   Equilateral Triangle     Pass
Anurag                               IT-1                    01413203120
                           EXPERIMENT – 3
Aim: To determine the nature of roots of a quadratic equations, its inputis
triple of +ve integers (say x,y,z) and values may be from interval[1,10] the
program output may have one of the following
Program:
#include <iostream>
#include <math.h>
int main()
{
    int min, max;
    int x, y, z;
    cout << "Enter Range : ";
    cin >> min >> max;
    if (min < 0 || max > 100)
    {
        cout << "Invalid Range";
        return 0;
    }
    int nominal = (min + max) / 2;
    int values[] = {min, min + 1, nominal, max - 1, max};
    cout << "a\tb\tc\tOutput\t\t\tRoots" << endl;
    for (int i = 0; i < 5; i++)
    {
        bva(values[i], nominal, nominal);
    }
Output:
Anurag                                  IT-1                      01413203120
                                EXPERIMENT - 4
Aim: To write a program for classification of a triangle amongst right
angled triangle, acute angled triangle, obtuse angled triangle or invalid
and testing Range is [0,100].
Algorithm:
int main()
{
       int a, b, c;
         if(isTriangle(a, b, c) == false)
         {
             cout << "\nNot A Triangle" << endl;
             return 0;
         }
         int s1 = A[0];
         int s2 = A[1];
         int s3 = A[2];
         return 0;
}
Anurag    IT-1   01413203120
Outputs
Anurag                             IT-1                   01413203120
Robust Testing:
Range:      R [1, 100]
Domain:     Below Minimum = 0
            Minimum = 1
            Above Minimum = 2
            Nominal = 50
            Below Maximum = 99
            Maximum = 100
            Above Maximum = 101
                            EXPERIMENT - 5
Aim: To determine the area of the circle, triangle, square and rectangle
and write test cases by performing equivalence class testing.
Program:
#include <iostream>
#include <conio.h>
#include <math.h>
void main()
clrscr();
int ch;
char c;
float, b, h, a;
cout<<“n1.Triangle”;
cout<<“n2.Square”;
cout<<“n3.Rectangle”;
cout<<“n4.Circle”;
cout<<“n5.Exitn”;
cin>>ch;
switch(ch)
cin>>b;
if ((b<=0)||(b>200))
goto b;
if ((h<=0)||(h>200))
Anurag                                 IT-1                    01413203120
goto h;
a= 0.5*b*h;
cin>>c;
if((c==’y’)||(c==’Y’))
goto 1;
break
cin>>b;
if ((b<=0)||(b>200))
goto s;
a= b*b;
cin>>c;
if((c==’y’)||(c==’Y’))
goto 1;
break;
cin>>b;
if((b<=0)||(b>200))
goto d;
cin>>h;
Anurag                                 IT-1            01413203120
if ((h<=0)||(h>200))
goto p;
a=b*h;
cin>>c;
if((c==’y’)||(c==’Y’))
goto 1;
break;
cin>>b;
if ((b<=0)||(b>200))
goto t;
a= 3.14*b*b;
cin>>c;
if ((c==’y’)||(c==’Y’))
goto 1;
break;
case 5: exit(0);
break;
goto 1;
getch();}
Anurag                                IT-1                     01413203120
Test Cases:
Case 1: Triangle
Input Domain:
I1 = {h : h<=0}
I2 = {h : h>200}
I3 = {h : 1<=h<=200}
I4 = {b : b<=0}
I5 = {b : b>200}
I6 = {b : 1<=b<=2001}
Case 2: Square
Input Domain:
I1 = {s : s<=0}
I2 = {s : s>200}
I3 = {s : 1<=s<=200}
2 100 10000
O1 = {: Square if s>}
Case 3: Rectangle
Input Domain:
I1 = {l : l<=0}
I2 = {l : l>200}
I3 = {l : 1<=l<=200}
I4 = {b : b<=0}
I5 = {b : b>200}
Anurag                           IT-1                        01413203120
I6 = {b : 1<=b<=200}
Case 4: Circle
Input Domain:
I1 = {r : r<=0}
I2 = {r : r>200}
Anurag                                IT-1                     01413203120
I3 = {r : 1<=r<=200}
2 100 31400
O1 = {: Circle if 1<=r<=200}
                            EXPERIMENT - 6
Aim: Consider a program for determining the Previous Date. Its input is
triple of Day, Month and Year with values in the range:
                          1 ≤ Day ≤ 31
                          1 ≤ Month ≤ 12
                          1900 ≤ Year ≤ 2025
Possible outputs would be Previous Date or Invalid Date. Design the
Boundary Value Test Cases.
Algorithm:
   Take 3 inputs from the user for Day, Month and Year.
   Check whether they lie in the given intervals.
   If the condition is false, stop the program and exit.
   If the condition is true, calculate the date according to the given values.
   Subtract 1 day from it to get the Previous Date.
   According to the formula 4n+1, there will be 13 test cases, where n is
    number of inputs.
Program:
#include <iostream>
using namespace std;
void bva(int, int, int);
int main()
{   int amin, amax, bmin, bmax, cmin, cmax;
    int x, y, z;
    cout << "Enter Range for Day : ";
    cin >> amin >> amax;
    cout << "Enter Range for Month : ";
    cin >> bmin >> bmax;
    cout << "Enter Range for Year : ";
    cin >> cmin >> cmax;
    if (amin < 1 || amax > 31)
    {
        cout << "Invalid Day Range";
        return 0;
    }
    if (bmin < 1 || bmax > 12)
    {
        cout << "Invalid Month Range";
        return 0;
    }
    if (cmin < 1900 || amax > 2025)
Anurag                                   IT-1                     01413203120
    {
         cout << "Invalid Year Range";
         return 0;
    }
         cout << a << "-" << b - 1 << "-" << c << endl;
    }
}
Output
Anurag                              IT-1                        01413203120
                            EXPERIMENT – 7
Aim: Write a program in C/C++ to compute ab and perform its decision
table-based testing.
Source Code:
#include <iostream>
#include <cmath>
int main()
{
    int base, expo;
cout<< base << "^" << expo << " = " << pow(base, expo);
    return 0;
}
Output:
Decision Table:
Anurag                            IT-1                    01413203120
                         EXPERIMENT - 8
AIM: WAP in C/C++ to compute 3 sides of a triangle and to determine
whether they form scalene, isosceles, or equilateral triangle and
perform Cause effect testing, Decision table-based testing and
Equivalence Class testing
Code:
#include<conio.h>
#include<stdio.h>
void main()
{
  int a,b,c,result;
  printf("\n\tEnter the values of a, b and c : = ");
  scanf("\t%d %d %d", &a,&b,&c);
    if(((a+b)>c)&&((b+c)>a)&&((c+a)>b))
    {
      if((a==b)&&(b==c))
           printf("\n\t It is an Equilatral Triangle");
    else if((a==b)||(b==c)||(c==a))
        printf("\n\t It is an isosceles Triangle");
           else
               printf("\n\t It is a Scalene Triangle");
    }
    else
    printf("\n\t not a triangle");
  getch();
}
OUTPUT:
Anurag                            IT-1   01413203120
                         EXPERIMENT - 9
AIM: WAP in C/C++ to compute 3 sides of a triangle and to determine
whether they form scalene, isosceles, or equilateral triangle and
perform Cause effect testing, Decision table-based testing and
Equivalence Class testing
Code:
#include<conio.h>
#include<stdio.h>
void main()
{
  int a,b,c,result;
  printf("\n\tEnter the values of a, b and c : = ");
  scanf("\t%d %d %d", &a,&b,&c);
    if(((a+b)>c)&&((b+c)>a)&&((c+a)>b))
    {
      if((a==b)&&(b==c))
           printf("\n\t It is an Equilatral Triangle");
    else if((a==b)||(b==c)||(c==a))
        printf("\n\t It is an isosceles Triangle");
           else
               printf("\n\t It is a Scalene Triangle");
    }
    else
    printf("\n\t not a triangle");
  getch();
}
OUTPUT:
Anurag                                 IT-1        01413203120
                         EXPERIMENT - 10
Aim: Make a case study on static and dynamic testing tools
Daikon:
Diacon is an open source dynamic testing tool that detects likely invariants
of a program.
It can be used to detect invariants in C, C++, Java, Perl programs, and more.
The biggest advantage of this tool is that it is easily extendable to other
applications.