Question: 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) {](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66fa294a9980b_60266fa294a42401.jpg)


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
Get step-by-step solutions from verified subject matter experts
