Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java script public class Utils public static int[] StringToArrayInt(String inputString) { return output IntArray: import org.junit. Test; import static org.junit. Assert.*; // class public class
Java script
public class Utils public static int[] StringToArrayInt(String inputString) { return output IntArray: import org.junit. Test; import static org.junit. Assert.*; // class public class My Test { @Test // method public void testOne() { int returnedArray[] = {}; int answer IntegerTest1[] int answer IntegerTest2[] = {}; {}; = // Test 1 Input and Desired Output System.out.println("Subtest 1: input string is 1 2 3 4"); String myStringTest1 = new String("1 2 3 4"); answer IntegerTest1 = new int[]{1, 2, 3, 4); // desired returned int array. returnedArray = Utils.StringToArrayInt (myStringTest1); // Check that returned array is equal to the model. assertArrayEquals(returnedArray, answer IntegerTest1); // Test 2 Input and Desired Output System.out.println("Subtest 2: input string is 20 30 40 50 60 70 80"); String myStringTest2 = new String("20 30 40 50 60 70 80"); answer IntegerTest2 = new int[]{20, 30, 40, 50, 60, 70, 80}; // desired returned int array. returnedArray = Utils.StringToArrayInt(myStringTest2); 1/ Check that returned array is equal to the model. assertArray Equals(returnedArray, answer IntegerTest2); // //assertArrayEquals(expected, array); } // end method } // end class A String will be passed to your method by VPL's internal tester. The String contains a series of whole numbers, separated by spaces. Your method is expected to return an array of integers. These integers should be the same, and in the same order, as the numbers in the String. (download the Unit test file) One test will send String("1 2 3 4") to your method. It will expect int[]{1,2,3,4} back (you can see that in the Unit test file)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started