Question

public void TestValues( int a, int b, ref int x ) {     if (a > 0)...

public void TestValues( int a, int b, ref int x )
{
    if (a > 0) && (b > 0)
        x = 1;
    if (a < 0) && (b < 0)
        x = -1;
                    }


Generate test cases for the code based on MC/DC coverage criteria

Homework Answers

Answer #1

Please find below test cases for code provided. Don't forget to give a Like.

MC/DC coverage for the first if loop:

a>0 b>0 Decision
True(a=10) True(b=5) X=1(True)
False(a=-1) True(b=10) Exits if loop(False)-No solution
False(a=-10) False(b=-10) Exits if loop(False)-No solution
True(a=5) False(b=-1) Exits if loop(False)-No solution

MC/DC coverage for the second if loop:

a<0 b<0 Decision
True(a=-1) True(b=-3) X=-1(True)
False(b=10) False(b=9) Exits if loop-No solution
True(b=-7) False(b=19) Exits if loop - No solution
False(b=-20) True(b=-5) Exits if loop - No solution

Thank you.

Know the answer?
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
Similar Questions
Generate test cases for the following code by using MC/DC. a)       Draw the CFG. b)       What is MC/DC...
Generate test cases for the following code by using MC/DC. a)       Draw the CFG. b)       What is MC/DC logic coverage criteria? c)        List the test cases. d)       Validate the test cases can achieve MC/DC. public void TestValues( int a, int b, ref int x ) {     x = 0; if (a > 0 || b < 0)         x = 1;     else if (a > 10  && b > 10)         x = -1;                         }
Generate test cases for the following code by using Basic Path Testing. void sort(int a[ ],int...
Generate test cases for the following code by using Basic Path Testing. void sort(int a[ ],int N) {     int i,j,p,t;        for(i=0;i<N-1;i++)        {     p=i;               for(j=i+1;j<N;j++)                      if(a[j]>a[p]) p=j;               if(p!=i)               {     t=a[p];  a[p]=a[i];     a[i]=t;   }        } } a)       Draw CFG. b)       How many basic paths for the CFG? c)        List the basic paths. d)       Generate test cases from it.
Consider the following Java program : public static void main (string args [ ]) { int...
Consider the following Java program : public static void main (string args [ ]) { int result, x ; x = 1 ; result = 0; while (x < = 10) { if (x%2 == 0) result + = x ; + + x ; } System.out.println(result) ; } } Which of the following will be the output of the above program? A. 35 B. 30 C. 45 D. 35 2. public static void main(String args[]) { int i =...
Java public class Point {      protected int x;      protected int y;      public Point...
Java public class Point {      protected int x;      protected int y;      public Point (int x, int y) {           this.x = x;           this.y = y;      }      public int getX() {           return x;      }      public int getY() {           return y;      } } THE FOLLOWING 3 QUESTIONS REFER TO THE CODE FRAGMENT ABOVE     Based on the code above, the Point Class is immutable: (a) TRUE (b) FALSE Explain: ___________________________________________ Subclasses...
using System; public static class Lab5 { public static void Main() { // declare variables int...
using System; public static class Lab5 { public static void Main() { // declare variables int inpMark; string lastName; char grade = ' '; // enter the student's last name Console.Write("Enter the last name of the student => "); lastName = Console.ReadLine(); // enter (and validate) the mark do { Console.Write("Enter a mark between 0 and 100 => "); inpMark = Convert.ToInt32(Console.ReadLine()); } while (inpMark < 0 || inpMark > 100); // Use the method to convert the mark into...
public static int mystery(int[] elements, int target)   {     for (int j = 0; j <...
public static int mystery(int[] elements, int target)   {     for (int j = 0; j < elements.length; j++)      {    if (elements[j] == target)    {     return j;       }        }    return -1;    } What would the following code return from mystery ([90, -30, 50], -30)?
Give the output of the program using Call-By-Reference: int i, a[3]; void f (int x, int...
Give the output of the program using Call-By-Reference: int i, a[3]; void f (int x, int y){ x = (x*y) mod 3; y = y – x; } main(){ i = 0; a[0] = 1; a[1] = 2; a[2] = 0; f(i, a[i]); print(“%d %d %d %d\n”, i, a[0], a[1], a[2]); f(a[i], a[i]); print(“%d %d %d\n”, a[0], a[1], a[2]); }
public static void main(String[] args) { //Given the following code : int[][] array2D = {{3, 4,...
public static void main(String[] args) { //Given the following code : int[][] array2D = {{3, 4, 5, 1}, {3,6,1,2}, {1,3,6,5}; Answer : 1- All values ​​of array2D are automatically 0 ? Yes or No 2- What is the value of array2D [3] .length ?________ 3-  The value that array2D.length shows is 12: Yes or No ? 4- Assign the value of 12 to the element in the third row, fourth column : 5- the value obtained when calculating array2D [1] [1]...
2. Consider the following program written in C syntax: void swap(int a, int b) {   ...
2. Consider the following program written in C syntax: void swap(int a, int b) {    int temp;    temp = a;    a = b;    b = temp; } void main() {    int value = 2, list[5] = {1, 3, 5, 7, 9};    swap(value, list[0]);    swap(list[0], list[1]);    swap(value, list[value]); } For each of the following parameter-passing methods, what are all of the values of the variables value and list after each of the three...
In the attached FlexArray Java class, implement a method public int delete (int location) { }...
In the attached FlexArray Java class, implement a method public int delete (int location) { } that deletes the integer value stored at location in the array, returns it, and ensures that the array values are contiguous.  Make sure to handle the array empty situation.  What is the time-complexity of the method, if the array size is n. ***************************************************************************************************************************** public class FlexArray { int [] array; private int size; private int capacity; public FlexArray() { capacity=10; size=0; array=new int[10]; } public FlexArray(int...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT