Question

For the following program P3 written in pseudo-code, given the test set T: T = {t1...

For the following program P3 written in pseudo-code, given the test set T: T = {t1 = <‐5, 2>, t2 = <3, 1>, t3 = <9, 3>} a) What is the domain for statement coverage of P3? Note: do not include syntactical markers such as comments, {, }, else, begin, end. b) What is the statement coverage for T? c) What test cases should you add to T to provide 100% statement coverage? d) What is the domain for decision coverage of P3? e) What is the decision coverage for T? f) What test cases should you add to T to provide 100% decision coverage? g) What is the domain for condition coverage of P3? h) What is the condition coverage for T? i) What test cases should you add to T to provide 100% condition coverage? When measuring test coverage, normally coverage is expressed as a percentage. It can also be expressed as a fraction, and using an un-simplified fraction is preferred for this assignment. Note that when adding test cases, there are many possible test cases that satisfy the objective: provide 100% coverage for a given test criterion. Program P3 1) integer A, B, C; 2) input (A, B); 3) if (A<‐8 or A>8 or B<0 or B>3) 4) { 5) output (“Boundary condition failure on inputs.”); 6) } 7) else // valid input 8) { 9) C = A * B; 10) if (A < 0) 11) { 12) C = C + A + B; 13) if (B > 1) 14) { 15) C = C + 3; 16) } // end if (B>1) 17) C = C * C; 18) } // end if (A<0) 19) else 20) { 21) C = C – A – B; 22) if (B == 1) 23) { 24) C = B * C; 25) } // end if (B=1) 26) else 27) { 28) C = B / C; 29) } // end else !(B=1) 30) C = C + 2; 31) } // end else !(A<0) 32) output (A, B, C); 33) } // end else valid input 34) return 0; 35) end;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

a)

Domain for statement coverage:

t1={2,3,9,21,22,24,30,32}

t2={2,3,5}

Therefore

domain = {2,3,5,9,21,22,24,30,32}

b)Statement coverage for T :

For set t1 statement coverage = 8/9 = 88.08%

For set t2 statement coverage = 3/9 = 33.33%

c)

Domain for decision coverage:

Coverage domain De= {3,10,13,22}

d)

Decision coverage for T:

t1 = {3,10,13}

t2={3}

Coverage domain De = {3,10,13,22}

Decisions covered Dc = {3,10,13}

Infeasible decision Di = {13}

Decision coverage = 3/(4-1) = 1

1. Statement domain for P1: Statement domain of P1 will constitute all those line sequences which can possibly be executed depending on the inputted value of A. It can be given as follows:

{ (1,2,3), (1,2,3,5,8,16,17), (1,2,3,5,6,13,16,17)}

2. Statement coverage: Statement coverage refers to a test scenario (case) in which every statement of the program is executed at least once. It can be calculated as:

Statement coverage = (No. of executed statements/No. of total statements)*100;

T specifies three scenarios for P1. That is:

a) t1=<4>: For this, second line sequence of statement domain will be executed. Hence, executed statements=7, total statements (excluding syntactical markers as assumed) = 9. Therefore:

Statement coverage = (7/9)*100 = 77.78%

b) t2=<25>: For this again, second line sequence of statement domain will be executed. Hence in this case also:

Statement coverage = 77.78%

c) t3=<-1>: For this, first line sequence of statement domain will be executed. Hence for this case:

Statement coverage = (3/9)*100 = 33.33%

It is clear that third line sequence will never be executed with the given test cases and statement coverage is not 100%.

For 100% statement coverage, it will be required to add new test cases to T and new test case should be such that else part of condition at line 6 (third line sequence of statement domain) is executed. Such a test case can be for any value of A in range [20,30].

3. Decision domain: Decision domain refers to all possible decision paths that can be executed in a program. For P1, it can be specified as:

{ (3), (3,6), (3,5,6,8), (3,5,6,13)}

4. Decision coverage: Decision coverage refers to the scenario in which each condition takes on all possible results of condition at least once. Same as explained above, with the given test cases under T, decision coverage will not be 100% and it will be required to add new test cases to T. Such a test case can be for any value of A in range [20,30].

Add a comment
Know the answer?
Add Answer to:
For the following program P3 written in pseudo-code, given the test set T: T = {t1...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Question 1 Given the following composite condition (a>=0 && b==3) || c>b Generate a...

    Question 1 Given the following composite condition (a>=0 && b==3) || c>b Generate a set of test cases (just the input values for a, b, and c) that you need to have 100% MC/DC coverage. Question 2 Given the following fragment of code: int tent=0, x=92, num; cout<<"Guess the number :"; cin>>num; while ((tent<5)&&(num!=x)) { tent++; if (num>x) cout<<"Smaller\n"; else if (num cout<<"Bigger\n"; else cout<<”You won!\n” cout<<"Guess the number :"; cin>>num; } (1) Build the corresponding control flow graph. (2)...

  • Question 1 The following program asks the user for the current temperature (in Fahrenheit). Provide a...

    Question 1 The following program asks the user for the current temperature (in Fahrenheit). Provide a total of 7 valid test cases (one for each message). Do not provide invalid test cases. Add a series of if statements (if with multiple alternatives i.e. if/else if/else) so that one of the following messages is printed based on the temperature value: Temperature (F) Message >90 “Go swimming.” <=90, >80 “Turn on air conditioning.” <=80, >70 “Do nothing.” <=70, >55 “Turn on heat.”...

  • For the following code, write test cases that satisfy both condition and decision coverage. void func...

    For the following code, write test cases that satisfy both condition and decision coverage. void func (int a, int b, int x) { if (a > 1 && b == 0) { x = x / a; } if (a == 2 || x > 1) { x = x + 1; } }

  • Provide test-cases to ensure 100% Statement Coverage. Provide actual values in your test-cases. printSum(int a, int...

    Provide test-cases to ensure 100% Statement Coverage. Provide actual values in your test-cases. printSum(int a, int b) int result- ab; if (result > 0) print ("Possitive Number:"result)s else if (result<) print ("Negative Number:"+ result); ) else print ("Equal Zero:"+result)

  • This program should be written in C Thoroughly following the Code Conventions, write an efficient program,...

    This program should be written in C Thoroughly following the Code Conventions, write an efficient program, which ask the user for their numeric grade, and determines and displays the equivalent letter grade, based on the following information: Use appropriate data types and initialize the variables correctly Use the following grading scale: A: 90 - 100 B: 80 - < 90 C: 70 - < 80 D: 60 - < 70 F: 0 - < 60 If the input is invalid,...

  • Consider the following code: 1. float foo (int a, int b, int c, int d, float...

    Consider the following code: 1. float foo (int a, int b, int c, int d, float e) { 2. float e; 3. if (a == 0) { 4. return 0; 5. } 6. int x = 0; 7. if ((a==b) || ((c == d) && bug(a) )) { 8. x=1; 9. } 10. e = 1/x; 11. return e; 12. } Function bug(a) should return a value of true when passed a value of a=1. Build: • a test suite...

  • The following code is a C Program that is written for encrypting and decrypting a string....

    The following code is a C Program that is written for encrypting and decrypting a string. provide a full explanation of the working flow of the program. #include <stdio.h> int main() { int i, x; char str[100]; printf("\n Please enter a valid string: \t"); gets (str); printf ("\n Please choose one of the following options: \n"); printf ("1 = Encrypt the given string. \n"); printf("2 = Decrypt the entered string. \n"); scanf("%d",&x); // using switch case statements switch (x) {...

  • Question 4: Provide at least 4 test cases. Prompt the user to input 3 doubles, a,...

    Question 4: Provide at least 4 test cases. Prompt the user to input 3 doubles, a, b and c. Which will represent the coefficients in the quadratic equation ax2 + bx + c = 0. Print out the solutions (if any) of the quadratic equation. If no root exists (this happens if a == 0, or b2 <4ac) print the message No real root. Sample input/ user entries shown in red Corresponding output Enter a, b and c which represent...

  • C++ Object Oriented assignment Can you please check the program written below if it has appropriately...

    C++ Object Oriented assignment Can you please check the program written below if it has appropriately fulfilled the instructions provided below. Please do the necessary change that this program may need. I am expecting to get a full credit for this assignment so put your effort to correct and help the program have the most efficient algorithm within the scope of the instruction given. INSTRUCTIONS Create a fraction class and add your Name to the name fraction and use this...

  • Java Programming Language Edit and modify from the given code Perform the exact same logic, except...

    Java Programming Language Edit and modify from the given code Perform the exact same logic, except . . . The numeric ranges and corresponding letter grade will be stored in a file. Need error checking for: Being able to open the text file. The data makes sense: 1 text line of data would be 100 = A. Read in all of the numeric grades and letter grades and stored them into an array or arraylist. Then do the same logic....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT