Question: White Box Testing Scenario: Given an array of no more than 1 0 0 unique integers sorted in ascending order, arr, and an integer x

White Box Testing Scenario:
Given an array of no more than 100 unique integers sorted in ascending order, arr, and an integer x, the function returns an integer that meets the following conditions:
If there is no such a value of j that arr[j] equals x, then return 1.
Otherwise, return the value of j that arr[j] equals x.
The function throws an Exception for any invalid input, e.g., arr is null, or x is not an integer.
Suppose we have already had implementations of the above function (Iterative Binary Search Algorithm) in different programming languages.
Solely based on the source code, can you design test cases using Java or Python language of the binarySearch() function by applying each of the following white box testing methods?
Statement Coverage
Decision Coverage
Loop Coverage
Path Coverage
Statement Coverage
Test cases do not miss any statement in the coverage; No redundant test cases.
Decision Coverage
Test cases do not miss any decisions in the coverage; No redundant test cases.
Loop Coverage
Test cases do not miss any loop cases in the coverage; No redundant test cases.
Path Coverage
Test cases do not miss any path in the coverage; No redundant test cases.
Decision Coverage
1. Please indicate which language version of source code you are using Java/Python?
2. Identify all sides of every decision point, and the inputs that result in each decision side:
Use the following template:
ID Decision arr input x input
D1 if (y ==0) true [1,2,3]2
D2 if (y ==0) false
......
3. List the tests you designed to cover the decisions in the above table. Test cases might be fewer than the decisions.
Test Decisions covered arr input x input output
T1 D1, D2
T2
...
Loop Coverage
4a. Please indicate which language version of source code you are using Java/Python?
4b. Identify different cases for the loop structure, design inputs to result in each case, and finally, figure out the expected output for each input.
Use the following template:
Test Loop body arr input x input Output
T1 zero times [1,2,3]21
T2 once
......
Path Coverage
5a. Please indicate which language version of source code you are using Java/Python?
5b. Identify all possible paths:
Use the following template:
Path Line# in the path
PT11,2,3,5,9
PT21,2,4,9
......
6. List the test cases you designed to cover all the identified paths:
Use the following template:
Test Paths covered by test arr input x input Output
T1 PT1[1,2,3]20
T2 PT2, PT4.........
......

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 Programming Questions!