Question: a. Write a Test Case that exposes a major flaw (test fails) in the function MathOperation1. Explain the flaw, including what happens and the exact

a.Write a Test Case that exposes a major flaw (test fails) in the function MathOperation1. Explain the flaw, including what happens and the exact line.

Int MathMin(Integer-Vector X) { // X is a vector of Integers C++ std::vector

Int min = 0;

For (int I = 0; I < len(X); i++) // len(X) returns length of Vector

{ If (X[I] < min) min = X[I] }

Return min;

}

Int MathMax(Integer-Vector X) { // X is a vector of Integers. C++ std::vector; Assume

// 1st element of vector is at X[0]

Int max = 0;

For (int I = 0; I < len(X); i++) // len(X) returns length of Vector

{ If (X[I] > max) max = X[I] }

Return max;

}

MathOperation1(Integer-Vector X) { // X is a vector of Integers. C++ std::vector;

If (len(X) > 0) { // len(X) returns length of Vector

Int min = MathMin(X)

Int max = MathMax(X)

Int diff = 10

If (max != min) {

If (max > 0 && min < 0 ) { diff = max + min }

else { diff = (max + min) / 2 }

For (int I = 0; I < len(X); i++) // len(X) returns length of Vector

{ X[i] = X[i] / diff }

}

}

}

b.Write a Unit Test Case and an Oracle for the helper functions MathMin & MathMax; such that a flaw (test fails) is exposed in both of them.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!