diff --git a/TwoSumsTest.java b/TwoSumsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..d9a4b0e3ef0f456288eec3f8412121beaa7f8fb2 --- /dev/null +++ b/TwoSumsTest.java @@ -0,0 +1,38 @@ +import static org.junit.Assert.*; +import org.junit.Test; + +public class TwoSumsTest { + + @Test + public void testStudentOneSolution() { + int[] nums = { 2, 7, 11, 15 }; + int target = 18; + int[][] expectedPairs = {{2, 16}, {7, 11}}; + int[][] expectedIndices = {{0, 3}, {1, 2}}; + + // Replace StudentOneSolution with the actual name of the class submitted by the first student + int[][] actualPairs = StudentOneSolution.findPairs(nums, target); + int[][] actualIndices = StudentOneSolution.findIndices(nums, target); + + assertArrayEquals(expectedPairs, actualPairs); + assertArrayEquals(expectedIndices, actualIndices); + } + + @Test + public void testStudentTwoSolution() { + int[] nums = { 2, 7, 11, 15 }; + int target = 18; + int[][] expectedPairs = {{2, 16}, {7, 11}}; + int[][] expectedIndices = {{0, 3}, {1, 2}}; + + // Replace StudentTwoSolution with the actual name of the class submitted by the second student + int[][] actualPairs = StudentTwoSolution.findPairs(nums, target); + int[][] actualIndices = StudentTwoSolution.findIndices(nums, target); + + assertArrayEquals(expectedPairs, actualPairs); + assertArrayEquals(expectedIndices, actualIndices); + } + + @Test + public void testStudentThreeSolution() { + int[] nums = { 2, 7, 11, 15 };