Sie sind auf Seite 1von 5

Practical No:-06

AIM:- Take a simple program in C/C++ and perform boundary value analysis by
writing test cases.

Example: 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.

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

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

PROGRAM CODE:

#include<stdio.h>

#include<ctype.h>

#include<conio.h>

#include<process.h>

int main()

int a, b, c;
clrscr();

printf("Enter three sides of the triangle");

scanf("%d%d%d", &a, &b, &c);

if((a > 10) || (b > 10) || (c > 10))

printf("Out of range");

getch();

exit(0);

if((a<b+c)&&(b<a+c)&&(c<a+b))

if((a==b)&&(b==c))

printf("Equilateral triangle");

else if((a!=b)&&(a!=c)&&(b!=c))

printf("Scalene triangle");

else

printf("Isosceles triangle");

else

printf("triangle cannot be formed");

getch();

return 0;

}
Test Report:

Case Id Description Input data Expected Actual output Comments


a b c output

T1 One side of 0 | 8 |8 Triangle should triangle cannot be Pass


triangle not formed formed
having value
0 and other
are less then
10
T2 all side of 0 | 0 | 0 Triangle should triangle cannot be Pass
triangle not formed formed
having value
0.
T3 all side of 11 | 20 |11 Triangle should Out of range pass
triangle be out of range
having
values
greater then
10
T4 all side of 5 | 7 | 9 Triangle should Scalene triangle Pass
triangle be scalene
having
values less
then 10 and
not equal
T5 If one side is 7 | 1 | 2 Triangle should triangle cannot be pass
greater then not formed formed
sum of two
another side
T6 All side are 8 | 8 |8 Triangle should Equilateral Pass
equal and be Equilateral triangle
less then 10
T7 Two side are 7 | 5 | 7 Triangle should Isosceles triangle Pass
equal and be Isosceles
less then 10
T8 Two side are 9 | 3 | 3 triangle cannot be Pass
equal and Triangle should formed
less then 10 not formed
but third are
greater then
sum of both
side
T9 All side are 10 | 10 | 10 Triangle should out of range Pass
equal to 10 be out of range
T10 One side is 12 | 6 | 8 Triangle should out of range Pass
Greater then be out of range
10 and other
are less the
10
Practical no-7

AIM:- Explore White Box Testing. Take a simple program in C/C++ and perform branch
coverage by writing test cases.

BRANCH COVERAGE

Branch coverage technique is used to cover all branches of the control flow graph. It covers all
the possible outcomes (true and false) of each condition of decision point at least once. Branch
coverage technique is a whitebox testing technique that ensures that every branch of each
decision point must be executed.

How to Calculate Branch Coverage ?

Branch coverage technique is used to cover all branches of the control flow graph. It covers all
the possible outcomes (true and false) of each condition of decision point at least once. Branch
coverage technique is a whitebox testing technique that ensures that every branch of each
decision point must be executed.

Example:

Read X
Read Y
IF X+Y > 100 THEN
Print "Large"
ENDIF
If X + Y<100 THEN
Print "Small"
ENDIF

This is the basic code structure where we took two variables X and Y and two conditions. If the
first condition is true, then print "Large" and if it is false, then go to the next condition. If the
second condition is true, then print "Small."
Control flow graph of code structure

In the above diagram, control flow graph of code is depicted. In the first case traversing through
"Yes "decision, the path is A1-B2-C4-D6-E8, and the number of covered edges is 1, 2, 4, 5, 6
and 8 but edges 3 and 7 are not covered in this path. To cover these edges, we have to traverse
through "No" decision. In the case of "No" decision the path is A1-B3-5-D7, and the number of
covered edges is 3 and 7. So by traveling through these two paths, all branches have covered.

Path 1 - A1-B2-C4-D6-E8
Path 2 - A1-B3-5-D7
Branch Coverage (BC) = Number of paths=2

Das könnte Ihnen auch gefallen