Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Three Questions on the code below the questions: a) Provide a statement-coverage

ID: 3832909 • Letter: T

Question

Three Questions on the code below the questions:

a) Provide a statement-coverage-adequate test suite formain, by specifying several tests in terms of theirinputs. You do not need to specify outputs. (ii) List which statements each test case in your test suitecovers.

b) Provide a decision-coverage-adequate test suite formain, by specifying some tests in terms of theirinputs. You do not need to specify outputs. You may reuse tests from part (b). (ii) List which decisions(branches) each test case in your test suite covers.

(d) Is it possible to test (cover)all paths in main? If not, why not? If so, how many tests would you need at minimum?

1. main()
       2. {
           3. int x, y, z, m;
           4.
           5. print("Enter the 3 numbers");
           6. read(x, y, z);
           7. m = z;
           8. if(y < z)
               9. {
               10. if(x < y)
                   11. {
                   12. m = y;
                   13. }
               14. else
                   15. {
                   16. if(x < z)
                       17. {
                       18. m = x;
                       19. }
                   20. }
               21. }
           22. else
               23. {
               24. if(x > y)
                   25. {
                   26. m = y;
                   27. }
               28. else
                   29. {
                   30. if(x > z)
                       31. {
                       32. m = x;
                       33. }
                   34. }
               35. }
           36. print("Middle number is", m);
       }

Explanation / Answer

Three Questions on the code below the questions:
a) Provide a statement-coverage-adequate test suite formain, by specifying several tests in terms of theirinputs. You do not need to specify outputs. (ii) List which statements each test case in your test suitecovers.

Below are the list of tests to be executed to cover all the statements
x y z -- Statements covered in test case
---------------------------------------------
1 2 3 -- 1,2,3,4,5,6,7,8,9,10,11,12,13,36
2 1 3 -- 1,2,3,4,5,6,7,8,9,10,14,15,16,17,18,19,36
3 1 2 -- 1,2,3,4,5,6,7,8,9,10,14,15,16,36
3 2 1 -- 1,2,3,4,5,6,7,8,22,23,24,25,26,27,36
2 3 1 -- 1,2,3,4,5,6,7,8,22,23,24,28,29,30,31,32,33,36
1 3 2 -- 1,2,3,4,5,6,7,8,22,23,24,28,29,30,36

b) Provide a decision-coverage-adequate test suite formain, by specifying some tests in terms of theirinputs. You do not need to specify outputs. You may reuse tests from part (b). (ii) List which decisions(branches) each test case in your test suite covers.

Below are the list of tests to be executed to cover all the decisions

Test Case 1 :
x y z
-----
1 2 3

y<z - True
x<y - True

Test Case 2 :
x y z
-----
2 1 3
y<z - True
x<y - False
x<z - True


Test Case 3 :
x y z
-----
3 1 2
y<z - True
x<y - False
x<z - False


Test Case 4 :
x y z
-----
3 2 1
y<z - False
x>y - True


Test Case 5 :
x y z
-----
2 3 1
y<z - False
x>y - False
x<z - True


Test Case 6 :
x y z
-----
1 3 2
y<z - False
x>y - False
x<z - False


(d) Is it possible to test (cover)all paths in main? If not, why not? If so, how many tests would you need at minimum?

Yes, all paths in main can be tested. Minimum 6 test cases are required to cover all paths.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote