Experiment 11
Experiment 11
THEORY:
Control Flow Testing is a white-box testing technique used to design test cases by
analyzing the control flow of a program. It focuses on the logical paths and
decisions taken during program execution. The goal is to ensure that all possible
paths through the program's control structure (like decisions, loops, and branches)
are tested at least once.
CODE:
#include <iostream>
#include <cassert>
#include <string>
if (num > 0) {
return "Positive";
return "Negative";
} else {
return "Zero";
void controlFlowTesting() {
assert(numberCheck(10) == "Positive");
assert(numberCheck(0) == "Zero");
int main() {
controlFlowTesting();
int num;
cout << "The number is " << numberCheck(num) << "." << endl;
return 0;
OUTPUT:
EXPERIMENT 12
AIM: Write a program to program to perform Data Flow Testing.
THEORY:
Data Flow Testing is a white-box testing technique that focuses on the use and
definition of variables within a program. It examines how data flows through the
program, particularly analyzing the points where variables are defined, used, and
killed (become out of scope or reassigned).
CODE:
#include <iostream>
#include <cassert>
#include <vector>
int sum = 0;
sum += numbers[i];
return sum;
void dataFlowTesting() {
assert(calculateSum(test1) == 10);
assert(calculateSum(test2) == -10);
assert(calculateSum(test3) == 2);
assert(calculateSum(test4) == 0);
int main() {
dataFlowTesting();
int n;
cin >> n;
vector<int> userArray(n);
cout << "The sum of the array is: " << calculateSum(userArray) << endl;
return 0;
Output:
EXPERIMENT 13
AIM: Write a program to program to perform Data Flow Testing.
THEORY:
CODE:
#include <iostream>
#include <cassert>
void sliceBasedTesting() {
cout << "Slice 1 Test 1 passed: Area calculation is correct." << endl;
assert(calculateArea(7, 3) == 21);
cout << "Slice 1 Test 3 passed: Area calculation is correct." << endl;
cout << "Slice 2 Test 1 passed: Threshold comparison is correct." << endl;
cout << "Slice 2 Test 2 passed: Threshold comparison is correct." << endl;
cout << "Slice 2 Test 3 passed: Threshold comparison is correct." << endl;
int main() {
sliceBasedTesting();
cout << "The area of the rectangle is: " << area << endl;
if (isAboveThreshold(area, threshold)) {
cout << "The area meets or exceeds the threshold." << endl;
} else {
return 0;
Output