Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please develop Junit tests for at least 3 of the methods in class ArrayOperations. Try to reach 1 0 0 % statement coverage and 1

Please develop Junit tests for at least 3 of the methods in class ArrayOperations. Try to reach 100% statement coverage and 100% branch coverage.
package inclass;
public class ArrayOperations
{
// Adapted from "Introduction to Software Testing",
// by Ammann and Offutt
public static int numZero(int[] x)
{
// Effects: if x == null throw NullPointerException
// else return the number of occurrences of 0 in x
int count =0;
for (int i=1; i0; i--)
{
if (x[i]== y)
return i;
}
return -1;
}
// test: x =[2,3,5]; y =2;
// expected =0
public static int countPositive (int[] x)
{
if (x == null)
throw new NullPointerException();
int count =0;
for (int i=0; i=0)
count++;
}
return count;
}
// test: x =[-4,2,0,2]
// expected =2
public static int lastZero (int[] x)
{
if (x == null)
throw new NullPointerException();
for (int i=0; i 0)
count++;
}
return count;
}
// test: x =[-3,-2,0,1,4]
// expected =3
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

Students also viewed these Databases questions

Question

=+impact member states and MNEs?

Answered: 1 week ago

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago